meta: add project headers

On all but a few files that are not going to stay there.
This commit is contained in:
Lephenixnoir 2022-10-30 18:50:24 +01:00
parent 2c238906e7
commit 4e529b5788
Signed by: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
10 changed files with 96 additions and 20 deletions

View File

@ -1,3 +1,9 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
#include <gint/keyboard.h>
#include <gint/display.h>
#include <gint/defs/util.h>
@ -122,7 +128,7 @@ int console_line_render(int x, int y, console_line_t *line, int w, int dy,
return y;
}
//=== Console data storage ===//
//=== Terminal emulator ===//
console_t *console_create(int backlog_size)
{

View File

@ -1,3 +1,19 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.console: Terminal emulator
//
// This header implements a basic terminal emulator compatible with
// MicroPython's readline() implementation.
//
// The main features are:
// * Dynamically-sized lines with reflow
// * Cap memory usage based on the total amount of text, not just line count
// * Basic ANSI-escape-based edition features (but only on the last line)
//---
#ifndef __PYTHONEXTRA_CONSOLE_H
#define __PYTHONEXTRA_CONSOLE_H
@ -52,7 +68,7 @@ void console_line_delete(console_line_t *line, int p, int n);
/* Update the number of render lines for the chosen width. */
void console_line_update_render_lines(console_line_t *line, int width);
//=== Console data storage ===//
//=== Terminal emulator ===//
typedef struct
{

View File

@ -1,6 +1,11 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
#include "py/compile.h"
#include "py/gc.h"
#include "py/mperrno.h"
#include "py/stackctrl.h"
#include "py/builtin.h"
#include "shared/runtime/gchelper.h"
@ -17,9 +22,7 @@
#include "console.h"
#include "shell.h"
//=== Console-based standard streams ===//
ssize_t stdouterr_write(void *data, void const *buf, size_t size)
static ssize_t stdouterr_write(void *data, void const *buf, size_t size)
{
console_t *cons = data;
console_write_at_cursor(cons, buf, size);
@ -33,8 +36,6 @@ fs_descriptor_type_t stdouterr_type = {
.close = NULL,
};
//=== Main function ===//
int main(int argc, char **argv)
{
pe_shell_init();
@ -77,8 +78,9 @@ int main(int argc, char **argv)
return 0;
}
// Handle uncaught exceptions (should never be reached in a correct C implementation).
void nlr_jump_fail(void *val) {
/* Handle uncaught exceptions (normally unreachable). */
void nlr_jump_fail(void *val)
{
dclear(C_BLACK);
dtext(2, 2, C_WHITE, "nlr_jump_fail!");
dprint(2, 2, C_WHITE, "val = %p", val);
@ -87,8 +89,9 @@ void nlr_jump_fail(void *val) {
getkey();
}
// Do a garbage collection cycle.
void gc_collect(void) {
/* Do a garbage collection cycle. */
void gc_collect(void)
{
gc_collect_start();
gc_helper_collect_regs_and_stack();
gc_collect_end();

View File

@ -1,3 +1,14 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.modgint: `gint` module
//
// This module aims to wrap commonly-used gint functions (not all APIs are
// considered relevant for high-level Python development).
//---
#include "py/runtime.h"
#include "py/objtuple.h"
#include <gint/display.h>

View File

@ -1,3 +1,10 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.modtime: `time` module (based on the UNIX port under MIT)
/*
* This file is part of the MicroPython project, http://micropython.org/
*

View File

@ -1,3 +1,10 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.mpconfigport: MicroPython's main port configuration file
#include <stdint.h>
#include <alloca.h>

View File

@ -1,14 +1,17 @@
#include <unistd.h>
#include "py/mpconfig.h"
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
#include "py/mphal.h"
#include "../../shared/readline/readline.h"
#include "keymap.h"
#include "shell.h"
#include <gint/display.h>
#include <gint/keyboard.h>
#include <unistd.h>
// Receive single character, blocking until one is available.
int mp_hal_stdin_rx_chr(void)
{
while(1) {
@ -45,7 +48,6 @@ int mp_hal_stdin_rx_chr(void)
}
}
// Send the string of given length.
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len)
{
int r = write(STDOUT_FILENO, str, len);

View File

@ -1,34 +1,47 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.mphalport: MicroPython's Hardware Abstraction Layer
#include <gint/clock.h>
#include <time.h>
/* Set the interrupt character in the terminal. */
void mp_hal_set_interrupt_char(char c);
/* Receive a single character from shell (blocking). */
int mp_hal_stdin_rx_chr(void);
/* Send a string to shell. */
void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len);
/* Passive sleep. */
static inline void mp_hal_delay_ms(mp_uint_t ms)
{
sleep_ms(ms);
}
static inline void mp_hal_delay_us(mp_uint_t us)
{
sleep_us(us);
}
/* Time spent executing. */
static inline mp_uint_t mp_hal_ticks_ms(void)
{
return ((uint64_t)clock() * 1000) / CLOCKS_PER_SEC;
}
static inline mp_uint_t mp_hal_ticks_us(void)
{
return ((uint64_t)clock() * 1000000) / CLOCKS_PER_SEC;
}
static inline mp_uint_t mp_hal_ticks_cpu(void)
{
return clock();
}
/* Time since Epoch in nanoseconds. */
static inline uint64_t mp_hal_time_ns(void)
{
return (uint64_t)time(NULL) * 1000000000;

View File

@ -1,3 +1,9 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
#include "shell.h"
#include <gint/timer.h>
#include <gint/display.h>

View File

@ -1,3 +1,8 @@
//---------------------------------------------------------------------------//
// ____ PythonExtra //
//.-'`_ o `;__, A community port of MicroPython for CASIO calculators. //
//.-'` `---` ' License: MIT (except some files; see LICENSE) //
//---------------------------------------------------------------------------//
// pe.shell: Shell integration
//
// This header covers application-integration aspects of the shell. For the