/programs/develop/tinypy/tinypy/Makefile |
---|
2,8 → 2,6 |
CC = kos32-gcc |
LD = kos32-ld |
SDK_DIR:=$(abspath ../../../../contrib/sdk) |
LDFLAGS = -static -nostdlib -T $(SDK_DIR)/sources/newlib/app.lds \ |
--image-base 0 -lgcc -lSDLn -lc.dll -lsound |
10,7 → 8,7 |
SDL_DIR = $(SDK_DIR)/sources/SDL-1.2.2_newlib |
CFLAGS = -DCONIO -U_Win32 -U_WIN32 -U__MINGW32__ -mpreferred-stack-boundary=2 \ |
-mincoming-stack-boundary=2 -fno-builtin -fno-common -O0 |
-mincoming-stack-boundary=2 -fno-builtin -fno-common -O3 |
INCLUDES= -I. -I$(SDK_DIR)/sources/newlib/libc/include -I$(SDL_DIR)/include |
LIBPATH:= -L $(SDK_DIR)/lib -L /home/autobuild/tools/win32/mingw32/lib -L. |
17,7 → 15,7 |
STD_MODULES= ../std_modules/modules.o |
OBJECTS = $(STD_MODULES) tpmain.o |
OBJECTS = tpmain.o $(STD_MODULES) |
all:$(NAME) |
/programs/develop/tinypy/examples/rw_file.py |
---|
1,13 → 1,13 |
# Read/Write file example |
# Copyright (C) 2019-2021 Logaev Maxim (turbocat2001), GPLv3 |
import file |
import ksys # KolibriOS syscalls |
fw=file.open('my.txt','w') # Open file for writing |
fw=ksys.open('my.txt','w') # Open file for writing |
fw.write("I love KolibriOS") # Write symbols to my.txt file |
fw.close() # Close file |
fr=file.open('my.txt', 'r') # Open file for reading |
fr=ksys.open('my.txt', 'r') # Open file for reading |
str=fr.read() # Read symbols from file |
print(str) # Print to console |
fr.close() # Close file |
/programs/develop/tinypy/std_modules/file/fs.c |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/develop/tinypy/std_modules/file/init.c |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/develop/tinypy/std_modules/socket/init.c |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/programs/develop/tinypy/std_modules/socket/socket.c |
---|
File deleted |
/programs/develop/tinypy/std_modules/bitwise/bitwise.c |
---|
11,10 → 11,3 |
return tp_number(num1 | num2); |
} |
static tp_obj _mul(TP){ |
unsigned num1 = (unsigned)GET_NUM_ARG(); |
unsigned num2 = (unsigned)GET_NUM_ARG(); |
return tp_number(num1 & num2); |
} |
/programs/develop/tinypy/std_modules/bitwise/init.c |
---|
8,7 → 8,6 |
tp_obj bit_mod = tp_dict(tp); |
EXPORT(bit_mod, "add" , _add); |
EXPORT(bit_mod, "mul" , _mul); |
tp_set(tp, bit_mod, tp_string("__doc__"), tp_string("Bitwise operations for large numbers")); |
tp_set(tp, bit_mod, tp_string("__name__"), tp_string("bitwise")); |
/programs/develop/tinypy/std_modules/ksys/start_app.c |
---|
File deleted |
/programs/develop/tinypy/std_modules/ksys/fs.c |
---|
0,0 → 1,255 |
#include <string.h> |
#include "tinypy.h" |
#define call70(par, st) __asm__ __volatile__("int $0x40":"=a"(st):"a"(70), "b"(par)) |
#define call70_rw(par, st, cnt) __asm__ __volatile__ ("int $0x40":"=a"(st), "=b"(cnt):"a"(70), "b"(par)) |
#define GET_STR_ARG() TP_TYPE(TP_STRING).string.val |
typedef unsigned int uint32_t; |
typedef unsigned char uint8_t; |
#pragma pack(push, 1) |
typedef struct { |
uint32_t subfnc; |
uint32_t res1; |
uint32_t res2; |
uint32_t res3; |
uint8_t *data; |
uint8_t res4; |
char *fn; |
}info_params_t; |
#pragma pack(pop) |
#pragma pack(push,1) |
typedef struct { |
uint32_t subfnc; |
uint32_t pos; |
uint32_t res1; |
uint32_t cnt; |
char* data; |
uint8_t res2; |
char* fn; |
}rw_params_t; |
#pragma pack(pop) |
static tp_obj kolibri_close(TP) |
{ |
tp_obj self = TP_TYPE(TP_DICT); |
uint32_t size = tp_get(tp, self, tp_string("size")).number.val; |
char *mode = (char *)tp_get(tp, self, tp_string("mode")).string.val; |
tp_set(tp, self, tp_string("closed"), tp_True); |
return tp_None; |
} |
static tp_obj kolibri_read(TP) |
{ |
uint32_t status, num; |
tp_obj self = TP_TYPE(TP_DICT); |
uint32_t pos = tp_get(tp, self, tp_string("pos")).number.val; |
uint32_t size = tp_get(tp, self, tp_string("size")).number.val; |
uint32_t cnt; |
char *buf = (char *)malloc(size - pos); |
rw_params_t params = {0, pos, 0, size - pos, buf, 0, |
(char *)tp_get(tp, self, tp_string("name")).string.val}; |
char *mode = (char *)tp_get(tp, self, tp_string("mode")).string.val; |
if (*mode != 'r') |
tp_raise_f(tp_None, "IOError: file not open for reading", tp_None); |
if (!buf) |
return tp_None; |
call70_rw((¶ms), status, cnt); |
buf[cnt] = '\0'; |
return tp_string(buf); |
} |
#if 0 |
static tp_obj kolibri_readline(TP) |
{ |
return tp_string("Line"); |
} |
static tp_obj kolibri_readlines(TP) |
{ |
tp_obj result = tp_list(tp); |
int i; |
for(i=0; i < 5; i++) |
tp_add(result, tp_string("Line")); |
return result; |
} |
#endif |
/* Write object to file. |
* |
* tp TinyPy virtual machine structure. |
* |
* returns tp_True |
*/ |
static tp_obj kolibri_write(TP) |
{ |
tp_obj self = TP_TYPE(TP_DICT); |
tp_obj obj = TP_OBJ(); /* What to write. */ |
char *mode = (char *)tp_get(tp, self, tp_string("mode")).string.val; |
uint32_t pos = (uint32_t)tp_get(tp, self, tp_string("pos")).number.val; |
uint32_t size = (uint32_t)tp_get(tp, self, tp_string("size")).number.val; |
if (*mode != 'w' && *mode != 'a') |
{ |
tp_raise_f(tp_None, "IOError: file not open for writing", tp_None); |
} |
else |
{ |
char *data = (char *)TP_CSTR(obj); |
rw_params_t params = {3, pos, 0, strlen(data), data, 0, |
(char *)tp_get(tp, self, tp_string("name")).string.val}; |
uint32_t status; |
uint32_t cnt; |
call70_rw((¶ms), status, cnt); |
if (status) |
{ |
tp_raise_f(tp_None, "IOError: writing failed with status %d", status); |
} |
pos += cnt; |
tp_set(tp, self, tp_string("pos"), tp_number(pos)); |
if (pos > size) |
{ |
/* If writing has come beyond the file, increase its size. */ |
tp_set(tp, self, tp_string("size"), tp_number(pos)); |
} |
return tp_True; |
} |
} |
/* Write line list into file. |
* |
* tp TinyPy virtual machine structure. |
* |
* returns tp_None. |
*/ |
static tp_obj kolibri_writelines(TP) |
{ |
tp_obj result = tp_None; |
tp_obj self = TP_TYPE(TP_DICT); |
tp_obj list = TP_TYPE(TP_LIST); /* What to write. */ |
char *mode = (char *)tp_get(tp, self, tp_string("mode")).string.val; |
long pos = (long)tp_get(tp, self, tp_string("pos")).number.val; |
uint32_t size = (uint32_t)tp_get(tp, self, tp_string("size")).number.val; |
if (*mode != 'w' && *mode != 'a') |
{ |
tp_raise_f(tp_None, "IOError: file not open for writing", tp_None); |
} |
else |
{ |
int i; |
char *fn = (char *)tp_get(tp, self, tp_string("name")).string.val; |
rw_params_t params = {3, 0, 0, 0, NULL, 0, fn}; |
for (i = 0; i < list.list.val->len; i++) |
{ |
char *data = (char *)TP_CSTR(list.list.val->items[i]); |
uint32_t status; |
uint32_t cnt; |
params.data = data; |
params.cnt = strlen(data); |
params.pos = pos; |
call70_rw((¶ms), status, cnt); |
if (status) |
tp_raise_f(tp_None, "IOError: writing failed with status %d", status); |
pos += cnt; |
} |
tp_set(tp, self, tp_string("pos"), tp_number(pos)); |
if (pos > size) |
{ |
/* If writing has come beyond the file, increase its size. */ |
tp_set(tp, self, tp_string("size"), tp_number(pos)); |
} |
return tp_True; |
} |
} |
/* Get file size. |
* |
* fn ASCIIZ absolute file path. |
*/ |
long long int kolibri_filesize(const char *fn) |
{ |
uint8_t data[40]; |
uint32_t status; |
long long int result; |
info_params_t params = {5, 0, 0, 0, data, 0, (char *)fn}; |
call70((¶ms), status); |
/* File size is at offset 32. */ |
if (status == 0) |
result = *(long long*)(&data[32]); |
else |
result = -status; |
return result; |
} |
/* Open file. |
* |
* tp TinyPy virtual machine structure. |
* |
* returns file object. |
*/ |
tp_obj kolibri_open(TP) { |
tp_obj obj; |
char *fn = (char *)(TP_TYPE(TP_STRING).string.val); |
tp_obj mode_obj = TP_OBJ(); |
long long int size; |
long long int pos = 0; |
uint32_t status; |
info_params_t params = {2, 0, 0, 0, NULL, 0, fn}; |
if (mode_obj.type == TP_NONE) |
mode_obj = tp_string("r"); |
else if (mode_obj.type != TP_STRING) |
tp_raise_f(tp_None, "ValueError: bad file access mode %s", TP_CSTR(mode_obj)); |
switch(mode_obj.string.val[0]) |
{ |
case 'w': |
call70((¶ms), status); |
if (status) |
tp_raise_f(tp_None, "IOError: cannot open file for writing", tp_None); |
size = 0; |
break; |
case 'a': |
pos = size; |
break; |
case 'r': |
break; |
default: |
tp_raise_f(tp_None, "ValueError: mode string must begin with 'r', 'w', or 'a'", tp_None); |
} |
if ((size = kolibri_filesize(fn)) < 0) |
tp_raise_f(tp_None, "IOError: filesize returned %d", tp_number(size)); |
obj = tp_dict(tp); |
tp_set(tp, obj, tp_string("name"), tp_string(fn)); |
tp_set(tp, obj, tp_string("size"), tp_number(size)); |
tp_set(tp, obj, tp_string("pos"), tp_number(pos)); |
tp_set(tp, obj, tp_string("mode"), mode_obj); |
#if 0 |
tp_set(tp, obj, tp_string("__doc__"), |
tp_string("File object.\nAttributes:\n name: file name\n" |
" closed: boolean indicating whether file was closed\n" |
"Methods:\n read: read the entire file into string\n" |
" readlines: get list of lines\n" |
" close: close the file\n" |
)); |
#endif |
tp_set(tp, obj, tp_string("closed"), tp_False); |
tp_set(tp, obj, tp_string("close"), tp_method(tp, obj, kolibri_close)); |
tp_set(tp, obj, tp_string("read"), tp_method(tp, obj, kolibri_read)); |
tp_set(tp, obj, tp_string("write"), tp_method(tp, obj, kolibri_write)); |
tp_set(tp, obj, tp_string("writelines"), tp_method(tp, obj, kolibri_writelines)); |
return obj; |
} |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |
/programs/develop/tinypy/std_modules/ksys/init.c |
---|
1,5 → 1,6 |
#include "tinypy.h" |
#include "syscalls.c" |
#include "fs.c" |
#define EXPORT(MOD_NAME, F_NAME, F_POINT) tp_set(tp, MOD_NAME , tp_string(F_NAME), tp_fnc(tp, F_POINT)) |
20,7 → 21,8 |
EXPORT(ksys_mod, "get_event" , _get_event); |
EXPORT(ksys_mod, "get_button" ,_get_button); |
EXPORT(ksys_mod, "get_sys_colors",_get_sys_colors); |
EXPORT(ksys_mod, "get_key" , _get_key); |
// filesystem |
EXPORT(ksys_mod, "open", kolibri_open); |
tp_set(tp, ksys_mod, tp_string("__doc__"), tp_string("KolibriOS system specific functions.")); |
tp_set(tp, ksys_mod, tp_string("__name__"), tp_string("kolibri")); |
/programs/develop/tinypy/std_modules/ksys/net.c |
---|
0,0 → 1,296 |
#include <sys/socket.h> |
// #include <menuet/net.h> |
#include "tp.h" |
extern tp_obj tp_dict(TP); |
extern tp_obj tp_method(TP,tp_obj self,tp_obj v(TP)); |
extern tp_obj tp_fnc(TP,tp_obj v(TP)); |
extern tp_obj tp_get(TP,tp_obj self, tp_obj k); |
tp_obj tp_has(TP,tp_obj self, tp_obj k); |
// #define _cdecl __attribute__((cdecl)) |
extern int (* _cdecl con_printf)(const char* format,...); |
#define PRECISION 0.000001 |
#define GET_SOCKET_DESCRIPTOR(_obj, _sock) do{ \ |
if (fabs(tp_has(tp, _obj, tp_string("socket")).number.val) < PRECISION)\ |
tp_raise(tp_None, "Socket not open", tp_None); \ |
_sock = (__u32)(tp_get(tp, _obj, tp_string("socket")).number.val + PRECISION);\ |
} while(0) |
/* Socket close method. |
* |
* Example: |
* s.close() # s must be a socket object created by socket. |
* |
* Raises exception if socket was not opened. Otherwise returns True. |
*/ |
static tp_obj kolibri_close_socket(TP) |
{ |
// tp_obj self = TP_TYPE(TP_DICT); |
// __u32 socktype; |
// __u32 s; |
// GET_SOCKET_DESCRIPTOR(self, s); |
// socktype = (__u32)tp_get(tp, self, tp_string("type")).number.val; |
// GET_SOCKET_DESCRIPTOR(self, s); |
// if (socktype == SOCK_STREAM) |
// __menuet__close_TCP_socket(s); |
// else if (socktype == SOCK_DGRAM) |
// __menuet__close_UDP_socket(s); |
return tp_True; |
} |
/* Socket send method. |
* |
* Example: |
* data="<html><head><title>Preved!!!</title></head><body>Example.</body></html>" |
* s.send(data) |
* or: |
* s.send(data, 20) # Send just 20 bytes |
*/ |
static tp_obj kolibri_send(TP) |
{ |
// tp_obj self = TP_TYPE(TP_DICT); |
// tp_obj data_obj = TP_TYPE(TP_STRING); |
// __u32 datalen = TP_DEFAULT(tp_False).number.val; |
// __u32 socktype = (__u32)tp_get(tp, self, tp_string("type")).number.val; |
// __u32 s; |
// int result; |
// GET_SOCKET_DESCRIPTOR(self, s); |
// if (datalen < 0 || datalen > data_obj.string.len) |
// datalen = data_obj.string.len; |
// if (socktype == SOCK_STREAM) |
// result = __menuet__write_TCP_socket(s, datalen, (void *)data_obj.string.val); |
// else if (socktype == SOCK_DGRAM) |
// result = __menuet__write_UDP_socket(s, datalen, (void *)data_obj.string.val); |
// return tp_number(!(result != 0)); |
return tp_number(0); |
} |
#define __u32 unsigned int |
#define __u8 unsigned char |
/* Socket recv method. |
* |
* data="<html><head><title>Preved!!!</title></head><body>Example.</body></html>" |
* s.recv(data) |
* or: |
* s.recv(data, 20) # Send just 20 bytes |
*/ |
static tp_obj kolibri_recv(TP) |
{ |
tp_obj self = TP_TYPE(TP_DICT); |
__u32 datalen = TP_DEFAULT(tp_False).number.val; |
__u32 s; |
__u8 c; |
__u8 *buf, *p; |
__u32 buf_size; |
__u32 bytes_read = 0; |
int i; |
// GET_SOCKET_DESCRIPTOR(self, s); |
// if (datalen) |
// buf_size = datalen; |
// else |
// buf_size = 2048; |
// if (!(buf = malloc(datalen))) |
// tp_raise(tp_None, "Cannot allocate buffer for received data", tp_None); |
// p = buf; |
// while (__menuet__read_socket(s, &c) && bytes_read < buf_size) |
// { |
// *p++ = c; |
// bytes_read++; |
// if (bytes_read >= buf_size && !datalen) |
// { |
// buf_size += 1024; |
// buf = realloc(buf, buf_size); |
// } |
// } |
return tp_string_n(buf, bytes_read); |
} |
static void inet_pton(TP, const char *buf, int len, __u32 *addr) |
{ |
char *p = (char *)buf; |
int i = 0; |
__u32 val = 0; |
*addr = 0; |
while (*p && p < buf + len && i < 4) |
{ |
if (*p == '.' || !*p) |
{ |
if (val > 255) |
tp_raise(tp_None, "ValueError: number > 255 in IP address", tp_None); |
*addr += (val << ((i++) << 3)); |
val = 0; |
} |
else |
{ |
if (*p < '0' || *p > '9') |
tp_raise(tp_None, "ValueError: bad char in IP address, digit expected", tp_None); |
val = val * 10 + *p - '0'; |
} |
p++; |
} |
if (!*p) |
{ |
if (i == 3) |
*addr += (val << ((i++) << 3)); |
else |
tp_raise(tp_None, "ValueError: bad IP address", tp_None); |
} |
} |
/* Converter from string presentation to binary address. */ |
static tp_obj kolibri_inet_pton(TP) |
{ |
tp_obj obj; |
__u32 addr; |
obj = TP_TYPE(TP_STRING); |
// inet_pton(tp, (char *)obj.string.val, (int)obj.string.len, &addr); |
return tp_number(addr); |
} |
/* Socket bind method. |
* |
* In KolibriOS it just sets local address and port. |
* |
* Example: |
* s.bind('10.10.1.2', 6000) #Connects to 10.10.1.2:6000 |
*/ |
tp_obj kolibri_bind(TP) |
{ |
// tp_obj self = TP_TYPE(TP_DICT); |
// tp_obj local_addr_obj = TP_OBJ(); |
// __u32 local_port = (__u32)TP_TYPE(TP_NUMBER).number.val; |
// __u32 local_addr; |
// if (local_addr_obj.type == TP_NUMBER) |
// local_addr = local_addr_obj.number.val; |
// else if (local_addr_obj.type == TP_STRING) |
// inet_pton(tp, (const char *)local_addr_obj.string.val, local_addr_obj.string.len, &local_addr); |
// tp_set(tp, self, tp_string("local_addr"), tp_number(local_addr)); |
// tp_set(tp, self, tp_string("local_port"), tp_number(local_port)); |
return tp_None; |
} |
/* Socket connect method. |
* |
* Example: |
* s.connect('10.10.1.1', 7000) #Connects to 10.10.1.1:7000 |
*/ |
tp_obj kolibri_connect(TP) |
{ |
// tp_obj self = TP_TYPE(TP_DICT); |
// tp_obj remote_addr_obj = TP_OBJ(); |
// __u32 remote_addr; |
// __u32 remote_port = (__u32)TP_TYPE(TP_NUMBER).number.val; |
// __u32 local_port = tp_get(tp, self, tp_string("local_port")).number.val; |
// __u32 socktype = (__u32)tp_get(tp, self, tp_string("type")).number.val; |
// int s = -1; /* Socket descriptor */ |
// if (remote_addr_obj.type == TP_NUMBER) |
// remote_addr = remote_addr_obj.number.val; |
// else if (remote_addr_obj.type == TP_STRING) |
// inet_pton(tp, (const char *)remote_addr_obj.string.val, remote_addr_obj.string.len, &remote_addr); |
// if (socktype == SOCK_STREAM) |
// s = __menuet__open_TCP_socket(local_port, remote_port, remote_addr, 1); |
// else if (socktype == SOCK_DGRAM) |
// s = __menuet__open_UDP_socket(local_port, remote_port, remote_addr); |
// if (s >= 0) |
// { |
// tp_set(tp, self, tp_string("socket"), tp_number(s)); |
// return tp_True; |
// } |
// else |
return tp_False; |
} |
/* Socket listen method. |
* |
* Example: |
* s.listen('10.10.1.1', 5000) |
*/ |
tp_obj kolibri_listen(TP) |
{ |
// tp_obj self = TP_TYPE(TP_DICT); |
// tp_obj remote_addr_obj = TP_OBJ(); |
// __u32 remote_addr; |
// __u32 remote_port = (__u32)TP_TYPE(TP_NUMBER).number.val; |
// __u32 local_port = tp_get(tp, self, tp_string("local_port")).number.val; |
// __u32 socktype = (__u32)tp_get(tp, self, tp_string("type")).number.val; |
// int s = -1; /* Socket descriptor */ |
// if (socktype != SOCK_STREAM) |
// tp_raise(tp_None, "IOError: attempt to listen on non-TCP socket", tp_None); |
// if (remote_addr_obj.type == TP_NUMBER) |
// remote_addr = remote_addr_obj.number.val; |
// else if (remote_addr_obj.type == TP_STRING) |
// inet_pton(tp, (const char *)remote_addr_obj.string.val, remote_addr_obj.string.len, &remote_addr); |
// if ((s = __menuet__open_TCP_socket(local_port, remote_port, remote_addr, 0)) >= 0) |
// { |
// tp_set(tp, self, tp_string("socket"), tp_number(s)); |
// return tp_True; |
// } |
// else |
return tp_False; |
} |
/* Exported function. |
* |
* Example: |
* |
* s = socket(socket.AF_INET, socket.SOCK_DGRAM) |
* |
* Returns socket object. |
*/ |
tp_obj kolibri_socket(TP) |
{ |
tp_obj s; |
tp_obj sockfamily = TP_TYPE(TP_NUMBER); |
tp_obj socktype = TP_TYPE(TP_NUMBER); |
// if (fabs(sockfamily.number.val - AF_INET) > PRECISION || |
// (fabs(socktype.number.val - SOCK_STREAM) > PRECISION && |
// fabs(socktype.number.val - SOCK_DGRAM) > PRECISION)) |
// return tp_None; |
s = tp_dict(tp); |
// tp_set(tp, s, tp_string("family"), sockfamily); |
// tp_set(tp, s, tp_string("type"), socktype); |
// tp_set(tp, s, tp_string("bind"), tp_method(tp, s, kolibri_bind)); |
// tp_set(tp, s, tp_string("connect"), tp_method(tp, s, kolibri_connect)); |
// tp_set(tp, s, tp_string("send"), tp_method(tp, s, kolibri_send)); |
// tp_set(tp, s, tp_string("recv"), tp_method(tp, s, kolibri_recv)); |
// tp_set(tp, s, tp_string("close"), tp_method(tp, s, kolibri_close_socket)); |
// if (fabs(socktype.number.val - SOCK_STREAM) < PRECISION) |
// tp_set(tp, s, tp_string("listen"), tp_method(tp, s, kolibri_listen)); |
return s; |
} |
tp_obj kolibri_socket_module(TP) |
{ |
tp_obj socket_mod = tp_dict(tp); |
// tp_set(tp, socket_mod, tp_string("AF_INET"), tp_number(AF_INET)); |
// tp_set(tp, socket_mod, tp_string("SOCK_STREAM"), tp_number(SOCK_STREAM)); |
// tp_set(tp, socket_mod, tp_string("SOCK_DGRAM"), tp_number(SOCK_DGRAM)); |
tp_set(tp, socket_mod, tp_string("AF_INET"), tp_number(0)); |
tp_set(tp, socket_mod, tp_string("SOCK_STREAM"), tp_number(0)); |
tp_set(tp, socket_mod, tp_string("SOCK_DGRAM"), tp_number(0)); |
tp_set(tp, socket_mod, tp_string("inet_pton"), tp_fnc(tp, kolibri_inet_pton)); |
tp_set(tp, socket_mod, tp_string("socket"), tp_fnc(tp, kolibri_socket)); |
return socket_mod; |
} |
/programs/develop/tinypy/std_modules/ksys/syscalls.c |
---|
74,21 → 74,6 |
return tp_number(get_os_button()); |
} |
static tp_obj _get_key(TP){ |
tp_obj key_obj = tp_dict(tp); |
oskey_t key_info = get_key(); |
tp_set(tp, key_obj, tp_string("code"), tp_number(key_info.code)); |
tp_set(tp, key_obj, tp_string("ctrl_key"), tp_number(key_info.ctrl_key)); |
tp_set(tp, key_obj, tp_string("state"), tp_number(key_info.state)); |
tp_set(tp, key_obj, tp_string("val"), tp_number(key_info.val)); |
return key_obj; |
} |
static tp_obj _start_app(TP){ |
const char *prog_name = GET_STR_ARG(); |
const char *args = GET_STR_ARG(); |
} |
static tp_obj _get_sys_colors(TP){ |
tp_obj color_obj = tp_dict(tp); |
struct kolibri_system_colors colors; |
/programs/develop/tinypy/std_modules/math/math.c |
---|
1,5 → 1,5 |
#include <math.h> |
#include <tinypy.h> |
#include "tinypy.h" |
#ifndef M_E |
#define M_E 2.7182818284590452354 |
/programs/develop/tinypy/std_modules/modules.c |
---|
4,8 → 4,6 |
#include "ksys/init.c" |
#include "pygame/init.c" |
#include "bitwise/init.c" |
#include "file/init.c" |
//#include "socket/socket.c" |
void init_std_modules(TP){ |
math_init(tp); |
12,8 → 10,6 |
random_init(tp); |
re_init(tp); |
ksys_init(tp); |
file_init(tp); |
//socket_init(tp); |
pygame_init(tp); |
bitwise_init(tp); |
} |