mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
Merge branch 'master' of https://github.com/pikastech/pikascript
This commit is contained in:
commit
d897af834c
@ -119,7 +119,6 @@ https://pikadoc.readthedocs.io/en/latest/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E%E7
|
||||
|ch582 |√ |√ |√ |√ | |√ |√ |
|
||||
|ch32v103r8t6 |√ |√ |√ | | | | |
|
||||
|cm32m101a |√ | | | | | | |
|
||||
|w801 |√ | | | | | | |
|
||||
|w806 |√ |√ |√ |√ |√ |√ |√ |
|
||||
|apm32f030r8 |√ | | | | | | |
|
||||
|apm32e103vb |√ | | | | | | |
|
||||
|
@ -124,7 +124,6 @@ http://pikascript.com
|
||||
|ch582 |√ |√ |√ |√ | |√ |√ |
|
||||
|ch32v103r8t6 |√ |√ |√ | | | | |
|
||||
|cm32m101a |√ | | | | | | |
|
||||
|w801 |√ | | | | | | |
|
||||
|w806 |√ |√ |√ |√ |√ |√ |√ |
|
||||
|apm32f030r8 |√ | | | | | | |
|
||||
|apm32e103vb |√ | | | | | | |
|
||||
|
@ -15,7 +15,6 @@
|
||||
|ch582 |√ |√ |√ |√ | |√ |√ |
|
||||
|ch32v103r8t6 |√ |√ |√ | | | | |
|
||||
|cm32m101a |√ | | | | | | |
|
||||
|w801 |√ | | | | | | |
|
||||
|w806 |√ |√ |√ |√ |√ |√ |√ |
|
||||
|apm32f030r8 |√ | | | | | | |
|
||||
|apm32e103vb |√ | | | | | | |
|
||||
|
@ -277,7 +277,7 @@
|
||||
<OCR_RVCT4>
|
||||
<Type>1</Type>
|
||||
<StartAddress>0x8000000</StartAddress>
|
||||
<Size>0x10000</Size>
|
||||
<Size>0xf000</Size>
|
||||
</OCR_RVCT4>
|
||||
<OCR_RVCT5>
|
||||
<Type>1</Type>
|
||||
|
@ -1,25 +0,0 @@
|
||||
# dependency
|
||||
|
||||
1. W800 SDK
|
||||
|
||||
https://www.winnermicro.com/upload/1/editor/1637552741307.rar
|
||||
|
||||
2. W800 Serial download tool
|
||||
|
||||
https://www.winnermicro.com/upload/1/editor/1623809255593.rar
|
||||
|
||||
3. CDK IDE
|
||||
|
||||
https://occ.t-head.cn/community/download?id=575997419775328256
|
||||
|
||||
# usage
|
||||
|
||||
1. use "W800_SDK.cdkproj" to replace "wm_sdk_w800\tools\w800\projects\SDK_Project\project\CDK_WS\W800_SDK\W800_SDK.cdkproj"
|
||||
|
||||
2. use "app" folder to replace "wm_sdk_w800\app" folder
|
||||
|
||||
3. Run the app/pikascript/pikaPackage.exe to get source code of pikascript core and packages.
|
||||
|
||||
4. Run the app/pikascript/rust-msc-latest-win10.exe to pre-compile the packages of pikascript.
|
||||
|
||||
5. Enjoy.
|
File diff suppressed because one or more lines are too long
@ -1,15 +0,0 @@
|
||||
TOP_DIR = ..
|
||||
sinclude $(TOP_DIR)/tools/w800/conf.mk
|
||||
|
||||
ifndef PDIR
|
||||
GEN_LIBS = libuser$(LIB_EXT)
|
||||
endif
|
||||
|
||||
#DEFINES +=
|
||||
|
||||
sinclude $(TOP_DIR)/tools/w800/rules.mk
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
@ -1,28 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File Name : main.c
|
||||
*
|
||||
* Description: main
|
||||
*
|
||||
* Copyright (c) 2014 Winner Micro Electronic Design Co., Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Author : dave
|
||||
*
|
||||
* Date : 2014-6-14
|
||||
*****************************************************************************/
|
||||
#include "wm_include.h"
|
||||
#include "pikaScript.h"
|
||||
void UserMain(void)
|
||||
{
|
||||
printf("[info]: w801 system init ok.\r\n");
|
||||
PikaObj *pikaMain = pikaScriptInit();
|
||||
while(1){
|
||||
}
|
||||
|
||||
#if DEMO_CONSOLE
|
||||
CreateDemoTask();
|
||||
#endif
|
||||
//用户自己的task
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
import PikaStdLib
|
||||
|
||||
print('hello pikascript')
|
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
pikascript-core==v1.9.0
|
||||
PikaStdLib==v1.9.0
|
@ -1,91 +1,89 @@
|
||||
#api
|
||||
from PikaObj import *
|
||||
import PikaStdDevice
|
||||
import PikaStdTask
|
||||
|
||||
|
||||
class GPIO(PikaStdDevice.GPIO):
|
||||
# override
|
||||
def platformHigh():
|
||||
def platformHigh(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformLow():
|
||||
def platformLow(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformEnable():
|
||||
def platformEnable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformDisable():
|
||||
def platformDisable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformSetMode():
|
||||
def platformSetMode(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformRead():
|
||||
def platformRead(self):
|
||||
pass
|
||||
|
||||
|
||||
class Time(PikaStdDevice.Time):
|
||||
# override
|
||||
def sleep_s(s: int):
|
||||
def sleep_s(self, s: int):
|
||||
pass
|
||||
|
||||
# override
|
||||
def sleep_ms(ms: int):
|
||||
def sleep_ms(self, ms: int):
|
||||
pass
|
||||
|
||||
|
||||
class ADC(PikaStdDevice.ADC):
|
||||
# override
|
||||
def platformEnable():
|
||||
def platformEnable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformRead():
|
||||
def platformRead(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformDisable():
|
||||
def platformDisable(self):
|
||||
pass
|
||||
|
||||
|
||||
class UART(PikaStdDevice.UART):
|
||||
# override
|
||||
def platformEnable():
|
||||
def platformEnable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformWrite():
|
||||
def platformWrite(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformRead():
|
||||
def platformRead(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformDisable():
|
||||
def platformDisable(self):
|
||||
pass
|
||||
|
||||
|
||||
class IIC(PikaStdDevice.IIC):
|
||||
# override
|
||||
def platformEnable():
|
||||
def platformEnable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformDisable():
|
||||
def platformDisable(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformWrite():
|
||||
def platformWrite(self):
|
||||
pass
|
||||
|
||||
# override
|
||||
def platformRead():
|
||||
def platformRead(self):
|
||||
pass
|
||||
|
||||
|
@ -1,8 +1,5 @@
|
||||
#api
|
||||
from PikaObj import *
|
||||
import PikaStdDevice
|
||||
|
||||
|
||||
class GPIO(PikaStdDevice.GPIO):
|
||||
# override
|
||||
def platformHigh():
|
||||
@ -94,6 +91,6 @@ class IIC(PikaStdDevice.IIC):
|
||||
pass
|
||||
|
||||
|
||||
class lowLevel(TinyObj):
|
||||
class lowLevel:
|
||||
def readPin(pin: str) -> int:
|
||||
pass
|
||||
|
37
package/pika_lvgl/pika_lv_timer_t.c
Normal file
37
package/pika_lvgl/pika_lv_timer_t.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include "lvgl.h"
|
||||
#include "pika_lvgl_lv_timer_t.h"
|
||||
|
||||
PikaEventListener* g_pika_lv_timer_event_listener;
|
||||
|
||||
#define LV_TIMER_EVENT_ID 0
|
||||
|
||||
void __pika_timer_cb(lv_timer_t* timer) {
|
||||
PikaObj* eventHandleObj = pks_eventLisener_getEventHandleObj(
|
||||
g_pika_lv_timer_event_listener, LV_TIMER_EVENT_ID);
|
||||
obj_newDirectObj(eventHandleObj, "timer", New_pika_lvgl_lv_timer_t);
|
||||
obj_setPtr(obj_getPtr(eventHandleObj, "timer"), "lv_timer", timer);
|
||||
obj_run(eventHandleObj, "eventCallBack(timer)");
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t_set_period(PikaObj* self, int period) {
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_set_period(lv_timer, period);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t_set_cb(PikaObj* self, Arg* cb) {
|
||||
obj_setArg(self, "eventCallBack", cb);
|
||||
/* init event_listener for the first time */
|
||||
if (NULL == g_pika_lv_timer_event_listener) {
|
||||
pks_eventLisener_init(&g_pika_lv_timer_event_listener);
|
||||
}
|
||||
pks_eventLicener_registEvent(g_pika_lv_timer_event_listener,
|
||||
LV_TIMER_EVENT_ID, self);
|
||||
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_set_cb(lv_timer, __pika_timer_cb);
|
||||
}
|
||||
|
||||
void pika_lvgl_lv_timer_t__del(PikaObj *self){
|
||||
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
|
||||
lv_timer_del(lv_timer);
|
||||
}
|
@ -11,6 +11,7 @@
|
||||
#include "pika_lvgl_lv_color_t.h"
|
||||
#include "pika_lvgl_lv_obj.h"
|
||||
#include "pika_lvgl_indev_t.h"
|
||||
#include "pika_lvgl_lv_timer_t.h"
|
||||
|
||||
PikaObj* pika_lv_event_listener_g;
|
||||
|
||||
@ -182,3 +183,11 @@ PikaObj* pika_lvgl_indev_get_act(PikaObj *self){
|
||||
obj_setPtr(new_obj,"lv_indev", lv_indev);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
PikaObj* pika_lvgl_timer_create_basic(PikaObj *self){
|
||||
PikaObj* new_obj = newNormalObj(New_pika_lvgl_lv_timer_t);
|
||||
lv_timer_t *lv_timer = lv_timer_create_basic();
|
||||
obj_setPtr(new_obj,"lv_timer", lv_timer);
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
from PikaObj import *
|
||||
|
||||
|
||||
def __init__(): ...
|
||||
|
||||
|
||||
class EVENT(TinyObj):
|
||||
class EVENT:
|
||||
ALL: int
|
||||
PRESSED: int
|
||||
PRESSING: int
|
||||
@ -53,8 +51,7 @@ class EVENT(TinyObj):
|
||||
PREPROCESS: int
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class ALIGN(TinyObj):
|
||||
class ALIGN:
|
||||
DEFAULT: int
|
||||
TOP_LEFT: int
|
||||
TOP_MID: int
|
||||
@ -79,8 +76,7 @@ class ALIGN(TinyObj):
|
||||
OUT_RIGHT_BOTTOM: int
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class PALETTE(TinyObj):
|
||||
class PALETTE:
|
||||
RED: int
|
||||
PINK: int
|
||||
PURPLE: int
|
||||
@ -103,37 +99,34 @@ class PALETTE(TinyObj):
|
||||
NONE: int
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class OPA(TinyObj):
|
||||
class OPA:
|
||||
TRANSP: int
|
||||
COVER: int
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class ANIM(TinyObj):
|
||||
class ANIM:
|
||||
OFF: int
|
||||
ON: int
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class STATE(TinyObj):
|
||||
class STATE:
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class lv_event(TinyObj):
|
||||
class lv_event:
|
||||
def get_code(self) -> int: ...
|
||||
def get_target(self) -> lv_obj: ...
|
||||
|
||||
class lv_color_t: ...
|
||||
|
||||
class lv_color_t(TinyObj):
|
||||
...
|
||||
|
||||
class lv_timer_t:
|
||||
def set_period(period: int): ...
|
||||
def set_cb(cb: any): ...
|
||||
def _del(self): ...
|
||||
|
||||
def palette_lighten(p: int, lvl: int) -> lv_color_t: ...
|
||||
def palette_main(p: int) -> lv_color_t: ...
|
||||
|
||||
|
||||
class style_t(TinyObj):
|
||||
class style_t:
|
||||
def __init__(self): ...
|
||||
def init(self): ...
|
||||
def set_radius(self, radius: int): ...
|
||||
@ -146,8 +139,7 @@ class style_t(TinyObj):
|
||||
def set_shadow_spread(self, s: int): ...
|
||||
def set_shadow_color(self, color: lv_color_t): ...
|
||||
|
||||
|
||||
class lv_obj(TinyObj):
|
||||
class lv_obj:
|
||||
def center(self): ...
|
||||
def set_size(self, size_x: int, size_y: int): ...
|
||||
def align(self, align: int, x_ofs: int, y_ofs: int): ...
|
||||
@ -161,45 +153,36 @@ class lv_obj(TinyObj):
|
||||
def get_y(self) -> int: ...
|
||||
def set_pos(self, x: int, y: int): ...
|
||||
|
||||
|
||||
class indev_t(TinyObj):
|
||||
class indev_t:
|
||||
def get_vect(self, point: point_t): ...
|
||||
|
||||
|
||||
def obj(parent: lv_obj) -> lv_obj: ...
|
||||
def indev_get_act() -> indev_t: ...
|
||||
|
||||
|
||||
class point_t(TinyObj):
|
||||
class point_t:
|
||||
def __init__(self): ...
|
||||
|
||||
|
||||
class arc(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_end_angle(self, angle: int): ...
|
||||
def set_bg_angles(self, start: int, end: int): ...
|
||||
def set_angles(self, start: int, end: int): ...
|
||||
|
||||
|
||||
class bar(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_value(self, value: int, anim: int): ...
|
||||
|
||||
|
||||
class btn(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
|
||||
class checkbox(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_text(self, txt: str): ...
|
||||
|
||||
|
||||
class dropdown(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_options(self, options: str): ...
|
||||
|
||||
|
||||
class label(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_text(self, txt: str): ...
|
||||
@ -207,29 +190,24 @@ class label(lv_obj):
|
||||
def set_recolor(self, en: int): ...
|
||||
def set_style_text_align(self, value: int, selector: int): ...
|
||||
|
||||
|
||||
class roller(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_options(self, options: str, mode: int): ...
|
||||
def set_visible_row_count(self, row_cnt: int): ...
|
||||
|
||||
|
||||
class slider(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
|
||||
class switch(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
|
||||
|
||||
class table(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_cell_value(self, row: int, col: int, txt: str): ...
|
||||
|
||||
|
||||
class textarea(lv_obj):
|
||||
def __init__(self, parent: lv_obj): ...
|
||||
def set_one_line(en: int): ...
|
||||
|
||||
|
||||
def scr_act() -> lv_obj: ...
|
||||
def timer_create_basic() -> lv_timer_t: ...
|
||||
|
@ -58,7 +58,7 @@ releases = [
|
||||
"v1.9.1 e136c84c834e21d58edc896f0780a86ae179c0a8",
|
||||
"v1.9.2 cf7876efdaf92f9f92e25370066f811f6892a5cb",
|
||||
"v1.10.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v1.10.1 1578eacdea69766dcebc2017a99c4fade19ef53f",
|
||||
"v1.10.1 1578eacdea69766dcebc2017a99c4fade19ef53f"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -109,7 +109,7 @@ releases = [
|
||||
"v1.9.1 e136c84c834e21d58edc896f0780a86ae179c0a8",
|
||||
"v1.9.2 cf7876efdaf92f9f92e25370066f811f6892a5cb",
|
||||
"v1.10.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v1.10.1 1578eacdea69766dcebc2017a99c4fade19ef53f",
|
||||
"v1.10.1 1578eacdea69766dcebc2017a99c4fade19ef53f"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -129,28 +129,26 @@ releases = [
|
||||
"v1.8.6 e88cf95105343f3246ac76795d599d5c209c1ab3",
|
||||
"v1.8.7 88f015bcb2bc5dd1260f35125822b2ba4535d861",
|
||||
"v1.9.0 0892f1d426e3d69daaff1251d8e45d2ef60d1ad4",
|
||||
"v1.10.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v1.10.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "TemplateDevice"
|
||||
releases = [
|
||||
"v0.0.1 281600804a5393c6721eab8ec6160a376ba010b4",
|
||||
]
|
||||
releases = [ "v0.0.1 281600804a5393c6721eab8ec6160a376ba010b4" ]
|
||||
|
||||
[[packages]]
|
||||
name = "PikaMath"
|
||||
releases = [
|
||||
"v0.0.1 31146e2395e80b5785a4b2e526913a4590160e66",
|
||||
"v0.1.0 793634882044af25f30bb59c6511c615e56f85c5",
|
||||
"v0.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v0.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "PikaCV"
|
||||
releases = [
|
||||
"v0.0.1 b463e812bf0334b55835a3b31cda0c2f6c526e06",
|
||||
"v0.1.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v0.1.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -160,33 +158,30 @@ releases = [
|
||||
"v1.0.0 cbde99793b1e631ab7f54775cba3f5372895b560",
|
||||
"v1.1.0 0cf260fca1e7613dc5523fd09de00df952c9dbd3",
|
||||
"v1.1.1 68b28c780861190639452ed0642e2f4064fa44c3",
|
||||
"v1.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v1.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "unittest"
|
||||
releases = [
|
||||
"v0.1.0 cd6dfbbb714228e7e0f147515d58450644e7dadf",
|
||||
]
|
||||
releases = [ "v0.1.0 cd6dfbbb714228e7e0f147515d58450644e7dadf" ]
|
||||
|
||||
[[packages]]
|
||||
name = "configparser"
|
||||
releases = [
|
||||
"v0.1.0 d3a9f6e226bb9cfccbfc588cc465672cefea9e82",
|
||||
"v0.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v0.2.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "pika_lvgl"
|
||||
releases = [
|
||||
"v0.0.1 71364445e0894e660720f9a0c9e1db021663d6a1",
|
||||
"v0.1.0 027f06710e83ee3daa7b706fb8a9bf23b1ab14e4"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "pika_lua"
|
||||
releases = [
|
||||
"v0.0.1 b5da16e285a378a74fa7b7734cdd89be703d6f07",
|
||||
]
|
||||
releases = [ "v0.0.1 b5da16e285a378a74fa7b7734cdd89be703d6f07" ]
|
||||
|
||||
[[packages]]
|
||||
name = "ctypes"
|
||||
@ -195,14 +190,12 @@ releases = [
|
||||
"v0.0.2 3fae2b5e86a0de787f6785ccd72a6590b4984f88",
|
||||
"v1.0.0 cbde99793b1e631ab7f54775cba3f5372895b560",
|
||||
"v1.0.1 5148412411e2de0d23e9c5857b0b4843f479a5be",
|
||||
"v1.1.0 211569c5a0169dbb700885d21fbbe0c678126e9e",
|
||||
"v1.1.0 211569c5a0169dbb700885d21fbbe0c678126e9e"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "binascii"
|
||||
releases = [
|
||||
"v0.0.1 88896715867c2a89df3e3b733cba38cc84f5347c",
|
||||
]
|
||||
releases = [ "v0.0.1 88896715867c2a89df3e3b733cba38cc84f5347c" ]
|
||||
|
||||
[[packages]]
|
||||
name = "STM32G0"
|
||||
@ -213,7 +206,7 @@ releases = [
|
||||
"v1.1.1 f755ec10042f4deefef1c5491f5e91a651f71a1b",
|
||||
"v1.2.0 19e644a2ef411aa49016bf106f4be8beeb0827b1",
|
||||
"v1.3.0 9f3a52558338503571b37c034a12219566f27aa2",
|
||||
"v1.3.1 3119a938dac7a723be3775aaaff5bc337a165567",
|
||||
"v1.3.1 3119a938dac7a723be3775aaaff5bc337a165567"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -224,19 +217,18 @@ releases = [
|
||||
"v1.0.2 4d7209bb174b1df26d22352a757cc43faaff4012",
|
||||
"v1.0.3 86377d1a3c19cd01b1dc109180be437373ce7c5f",
|
||||
"v1.1.0 186b951078c76b1c80b8111d76097970c21a3004",
|
||||
"v1.1.1 567d0b19ce998a290fa538845d107c744ccd0258"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "ESP32"
|
||||
releases = [
|
||||
"v0.1.0 ee7e38e9422970bba86f5cd7774db8654edd38dc",
|
||||
]
|
||||
releases = [ "v0.1.0 ee7e38e9422970bba86f5cd7774db8654edd38dc" ]
|
||||
|
||||
[[packages]]
|
||||
name = "STM32F4"
|
||||
releases = [
|
||||
"v0.0.1 5f992314b5ec9f201302eea8df8620e0cde600ae",
|
||||
"v0.0.2 8bcb5ad868ec8961f2a3f08329a46ab0b780596b",
|
||||
"v0.0.2 8bcb5ad868ec8961f2a3f08329a46ab0b780596b"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -253,7 +245,7 @@ releases = [
|
||||
"v1.1.2 0052a28582ac8a85cc48e1d676d9a3be5cb1b93f",
|
||||
"v1.1.3 f755ec10042f4deefef1c5491f5e91a651f71a1b",
|
||||
"v1.2.0 9f3a52558338503571b37c034a12219566f27aa2",
|
||||
"v1.3.0 9d7b155af3260c0fc00be05598c807b71d7cc198",
|
||||
"v1.3.0 9d7b155af3260c0fc00be05598c807b71d7cc198"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -268,15 +260,12 @@ releases = [
|
||||
"v0.3.3 bcee87c3d7d09db093f92ba825019dd3ec8726a7",
|
||||
"v0.3.4 7345c222bd446bad6eb32a32f38cad36867fba7c",
|
||||
"v0.4.0 9f3a52558338503571b37c034a12219566f27aa2",
|
||||
"v0.4.1 0892f1d426e3d69daaff1251d8e45d2ef60d1ad4",
|
||||
"v0.4.1 0892f1d426e3d69daaff1251d8e45d2ef60d1ad4"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "CH32V103"
|
||||
releases = [
|
||||
"v1.0.0 4ce839297f208b0ac4fc1e7f16fef16ab605e70d",
|
||||
]
|
||||
|
||||
releases = [ "v1.0.0 4ce839297f208b0ac4fc1e7f16fef16ab605e70d" ]
|
||||
|
||||
[[packages]]
|
||||
name = "pikaRTThread"
|
||||
@ -286,7 +275,7 @@ releases = [
|
||||
"v1.1.0 ff2e72ccb08c6a5935ed7ed77dfaa3a074ff120f",
|
||||
"v1.1.1 ac4247e5fd3e221eb110a1b41276849c623049ec",
|
||||
"v1.2.0 e2e94bb3a349985641fa686341757cfbd18207e2",
|
||||
"v1.3.0 9f3a52558338503571b37c034a12219566f27aa2",
|
||||
"v1.3.0 9f3a52558338503571b37c034a12219566f27aa2"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -295,27 +284,23 @@ releases = [
|
||||
"v0.0.1 fe900b79d8d1075bb7e4e3dd9d4e1e187e0c9195",
|
||||
"v1.0.0 ac4247e5fd3e221eb110a1b41276849c623049ec",
|
||||
"v1.0.1 61e6a7352b656adbce0f2ad82ea1fc992dcbb603",
|
||||
"v1.1.0 9f3a52558338503571b37c034a12219566f27aa2",
|
||||
"v1.1.0 9f3a52558338503571b37c034a12219566f27aa2"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "SmartLoong"
|
||||
releases = [
|
||||
"v0.0.1 a5437de66e8cff600be247eae63ac9114b6b153f",
|
||||
]
|
||||
releases = [ "v0.0.1 a5437de66e8cff600be247eae63ac9114b6b153f" ]
|
||||
|
||||
[[packages]]
|
||||
name = "PikaVSF"
|
||||
releases = [
|
||||
"v0.0.1 f755ec10042f4deefef1c5491f5e91a651f71a1b",
|
||||
]
|
||||
releases = [ "v0.0.1 f755ec10042f4deefef1c5491f5e91a651f71a1b" ]
|
||||
|
||||
[[packages]]
|
||||
name = "W801Device"
|
||||
releases = [
|
||||
"v0.0.1 88f4e507f1665ca7ceda149aabf029f4e21e22c7",
|
||||
"v1.0.0 7ae9cd062fa48ecfe4b843c9f13b0daef0efd79d",
|
||||
"v1.1.0 c53bf1483d015555b4823f129864444198227403",
|
||||
"v1.1.0 c53bf1483d015555b4823f129864444198227403"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
@ -323,16 +308,13 @@ name = "CH582"
|
||||
releases = [
|
||||
"v1.0.0 7cdb0cf9ed161c3fc6802028a9e34c9f94b56244",
|
||||
"v1.1.0 bfc01e09fd71c26a7140d23864c1d3052f23d087",
|
||||
"v1.1.1 268c8433a1add8c902d694808682890a2df8c1fc"
|
||||
]
|
||||
|
||||
[[packages]]
|
||||
name = "PLOOC"
|
||||
releases = [
|
||||
"v1.0.0 e2a630358c0d490b198f7e8682fb61569eb7ec56",
|
||||
]
|
||||
releases = [ "v1.0.0 e2a630358c0d490b198f7e8682fb61569eb7ec56" ]
|
||||
|
||||
[[packages]]
|
||||
name="MM32F5277E9P"
|
||||
releases = [
|
||||
"v0.0.1 176232225939eccfaedfea412699a2e53c38ace1",
|
||||
]
|
||||
name = "MM32F5277E9P"
|
||||
releases = [ "v0.0.1 176232225939eccfaedfea412699a2e53c38ace1" ]
|
||||
|
@ -1174,3 +1174,28 @@ TEST(VM, list_add) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(VM, science_num){
|
||||
char* line =
|
||||
"a = 1.0e-3\n"
|
||||
"b = 2e-5\n"
|
||||
"c = -3e-5\n"
|
||||
"d = 0.4e2\n"
|
||||
;
|
||||
PikaObj* self = newRootObj("root", New_PikaStdLib_SysObj);
|
||||
obj_run(self, line);
|
||||
/* collect */
|
||||
double a = obj_getFloat(self, "a");
|
||||
double b = obj_getFloat(self, "b");
|
||||
double c = obj_getFloat(self, "c");
|
||||
double d = obj_getFloat(self, "d");
|
||||
/* assert */
|
||||
EXPECT_DOUBLE_EQ(a, 1.0e-3);
|
||||
EXPECT_DOUBLE_EQ(b, 2.0e-5);
|
||||
EXPECT_DOUBLE_EQ(c, -3e-5);
|
||||
EXPECT_DOUBLE_EQ(d, 0.4e2);
|
||||
/* deinit */
|
||||
obj_deinit(self);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
|
@ -120,3 +120,21 @@ TEST(builtin, nofound) {
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
#if PIKA_SYNTAX_LEVEL == PIKA_SYNTAX_LEVEL_MAXIMAL
|
||||
TEST(builtin, callback_1) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
PikaObj* pikaMain = newRootObj("pikaMain", New_PikaMain);
|
||||
/* run */
|
||||
__platform_printf("BEGIN\r\n");
|
||||
pikaVM_runSingleFile(pikaMain, "test/python/callback/test1.py");
|
||||
/* collect */
|
||||
/* assert */
|
||||
EXPECT_STREQ(log_buff[0], "b\r\n");
|
||||
EXPECT_STREQ(log_buff[1], "a\r\n");
|
||||
/* deinit */
|
||||
obj_deinit(pikaMain);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
#endif
|
||||
|
@ -8,7 +8,7 @@ char* AST_toPikaASM(AST* ast, Args* outBuffs);
|
||||
AST* AST_parseLine(char* line, Stack* blockStack);
|
||||
char* Parser_LineToAsm(Args* buffs, char* line, Stack* blockStack);
|
||||
int32_t AST_deinit(AST* ast);
|
||||
char* Lexer_getTokens(Args* outBuffs, char* stmt);
|
||||
char* Lexer_parseLine(Args* outBuffs, char* stmt);
|
||||
char* Lexer_printTokens(Args* outBuffs, char* tokens);
|
||||
char* strsPopTokenWithSkip_byStr(Args* buffs,
|
||||
char* stmts,
|
||||
@ -856,7 +856,7 @@ TEST(parser, signed_num) {
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
char* tokens_print =
|
||||
Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s", tokens_print);
|
||||
EXPECT_STREQ(tokens_print, "{sym}a{opt}={opt}-{lit}1\n");
|
||||
printf("%s", pikaAsm);
|
||||
@ -897,7 +897,7 @@ TEST(lexser, symbol_add) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, " res = add(1,2)");
|
||||
char* tokens = Lexer_parseLine(buffs, " res = add(1,2)");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -916,7 +916,7 @@ TEST(lexser, symbol_1) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "a(");
|
||||
char* tokens = Lexer_parseLine(buffs, "a(");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
|
||||
/* assert */
|
||||
@ -933,7 +933,7 @@ TEST(lexser, operator_not) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "not not not ");
|
||||
char* tokens = Lexer_parseLine(buffs, "not not not ");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -951,7 +951,7 @@ TEST(lexser, symbol_Nag) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "-10-20");
|
||||
char* tokens = Lexer_parseLine(buffs, "-10-20");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -969,7 +969,7 @@ TEST(lexser, operator_all) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs,
|
||||
char* tokens = Lexer_parseLine(buffs,
|
||||
"not or and "
|
||||
"+ += - -="
|
||||
"* ** *= **="
|
||||
@ -1000,7 +1000,7 @@ TEST(lexser, symbol_2) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "a+b-c(25**=ek)!=-28");
|
||||
char* tokens = Lexer_parseLine(buffs, "a+b-c(25**=ek)!=-28");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -1020,7 +1020,7 @@ TEST(lexser, symbol_and) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, " res = add(1 and lkj,2)");
|
||||
char* tokens = Lexer_parseLine(buffs, " res = add(1 and lkj,2)");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -1040,7 +1040,7 @@ TEST(lexser, sting) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, " a= 'elk 2'");
|
||||
char* tokens = Lexer_parseLine(buffs, " a= 'elk 2'");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -1058,7 +1058,7 @@ TEST(lexser, num_1) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "1");
|
||||
char* tokens = Lexer_parseLine(buffs, "1");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -1076,7 +1076,7 @@ TEST(lexser, jjcc) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "a = (1 + 1.1) * 3 - 2 /4.0");
|
||||
char* tokens = Lexer_parseLine(buffs, "a = (1 + 1.1) * 3 - 2 /4.0");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -2402,7 +2402,7 @@ TEST(lexser, a_j) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "a=");
|
||||
char* tokens = Lexer_parseLine(buffs, "a=");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -2479,7 +2479,7 @@ TEST(parser, a_cuohao_j) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = (3 - 4) - 4\n";
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines)));
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines)));
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
EXPECT_STREQ(pikaAsm,
|
||||
@ -2501,7 +2501,7 @@ TEST(parser, _3_3) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "-3+3\n";
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines)));
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines)));
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
EXPECT_STREQ(pikaAsm,
|
||||
@ -2521,7 +2521,7 @@ TEST(parser, list_init) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = [1, 2, 3]\n";
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines)));
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines)));
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
EXPECT_STREQ(pikaAsm,
|
||||
@ -2541,7 +2541,7 @@ TEST(parser, list_init_fun) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "test([1, 2, 3])\n";
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines)));
|
||||
printf("%s\n", Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines)));
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
EXPECT_STREQ(pikaAsm,
|
||||
@ -2562,7 +2562,7 @@ TEST(parser, bytes_iteral) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = b'\\x00\\x01'\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2581,7 +2581,7 @@ TEST(parser, import_as) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "import PikaStdLib as std\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2602,7 +2602,7 @@ TEST(parser, str_equ) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = 'num ='\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2621,7 +2621,7 @@ TEST(parser, bytes_index) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "res2 = b'eqrt'[2]\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2642,7 +2642,7 @@ TEST(parser, hex_iteral) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = "a = 0b10\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2663,7 +2663,7 @@ TEST(parser, tab) {
|
||||
"for i in range(0, 100):\n"
|
||||
"\tprint(i)\n"
|
||||
"\n";
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
char* tokens_str = Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\n", tokens_str);
|
||||
printf("%s", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
@ -2697,7 +2697,7 @@ TEST(parser, parse_issue2) {
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
char* lines = " recv_buf[1] = dat \n";
|
||||
char* tokens = Lexer_getTokens(buffs, lines);
|
||||
char* tokens = Lexer_parseLine(buffs, lines);
|
||||
uint16_t token_size = Tokens_getSize(tokens);
|
||||
EXPECT_EQ(token_size, 8);
|
||||
char* tokens_str = Lexer_printTokens(buffs, tokens);
|
||||
@ -2778,7 +2778,7 @@ TEST(parser, str_add1) {
|
||||
printf("%s\r\n", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
char* tokens_print =
|
||||
Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\r\n", tokens_print);
|
||||
EXPECT_STREQ(tokens_print,
|
||||
"{sym}msg{opt}={lit}\"device_names[\"{opt}+{sym}str{dvd}({sym}"
|
||||
@ -2805,7 +2805,7 @@ TEST(parser, str_add2) {
|
||||
printf("%s\r\n", lines);
|
||||
char* pikaAsm = Parser_linesToAsm(buffs, lines);
|
||||
char* tokens_print =
|
||||
Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\r\n", tokens_print);
|
||||
EXPECT_STREQ(tokens_print,
|
||||
"{sym}msg{opt}={lit}\"device_names[\"{opt}+{sym}str{dvd}({sym}"
|
||||
@ -2998,7 +2998,7 @@ TEST(parser, json_literal) {
|
||||
"}'";
|
||||
printf("%s\r\n", lines);
|
||||
char* tokens_print =
|
||||
Lexer_printTokens(buffs, Lexer_getTokens(buffs, lines));
|
||||
Lexer_printTokens(buffs, Lexer_parseLine(buffs, lines));
|
||||
printf("%s\r\n", tokens_print);
|
||||
|
||||
EXPECT_STREQ(tokens_print,
|
||||
@ -3265,7 +3265,7 @@ TEST(lexser, import_issue1) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "my_import = import_test");
|
||||
char* tokens = Lexer_parseLine(buffs, "my_import = import_test");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -3283,7 +3283,7 @@ TEST(lexser, dict_literal1) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(
|
||||
char* tokens = Lexer_parseLine(
|
||||
buffs,
|
||||
"tinydict = {'name': 'runoob', 'likes': 123, 'url': 'www.runoob.com'}");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
@ -3407,7 +3407,7 @@ TEST(lexser, function_chain) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "String('a,b,c').split(',')");
|
||||
char* tokens = Lexer_parseLine(buffs, "String('a,b,c').split(',')");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -3860,7 +3860,7 @@ TEST(lexser, connet_part1) {
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_getTokens(buffs, "method(a,");
|
||||
char* tokens = Lexer_parseLine(buffs, "method(a,");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
@ -3946,3 +3946,23 @@ TEST(parser, issues_I5MIFO) {
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(lexser, science_num) {
|
||||
/* init */
|
||||
pikaMemInfo.heapUsedMax = 0;
|
||||
Args* buffs = New_strBuff();
|
||||
|
||||
/* run */
|
||||
char* tokens = Lexer_parseLine(buffs, "1.0e-2, 10e2, 0.1e-2, aie2, aie-2");
|
||||
char* printTokens = Lexer_printTokens(buffs, tokens);
|
||||
printf("%s\n", printTokens);
|
||||
|
||||
/* assert */
|
||||
EXPECT_STREQ(printTokens,
|
||||
"{lit}1.0e-2{dvd},{lit}10e2{dvd},{lit}0.1e-2{dvd},{sym}aie2{"
|
||||
"dvd},{sym}aie{opt}-{lit}2");
|
||||
|
||||
/* deinit */
|
||||
args_deinit(buffs);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
25
port/linux/test/python/callback/test1.py
Normal file
25
port/linux/test/python/callback/test1.py
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
class Demo():
|
||||
def __init__(self):
|
||||
print("__init__")
|
||||
self.funcs = []
|
||||
self.funcs.append(self.a)
|
||||
self.funcs.append(self.b)
|
||||
|
||||
|
||||
def a(self):
|
||||
print('a')
|
||||
|
||||
def b(self):
|
||||
print('b')
|
||||
|
||||
def get_funcs(self):
|
||||
return self.funcs
|
||||
|
||||
|
||||
demo = Demo()
|
||||
funcs = demo.get_funcs()
|
||||
print('----------------------------')
|
||||
for func in funcs:
|
||||
func()
|
@ -1181,6 +1181,11 @@ void pks_printVersion(void) {
|
||||
PIKA_VERSION_MINOR, PIKA_VERSION_MICRO, PIKA_EDIT_TIME);
|
||||
}
|
||||
|
||||
void pks_getVersion(char *buff)
|
||||
{
|
||||
__platform_sprintf(buff, "%d.%d.%d", PIKA_VERSION_MAJOR, PIKA_VERSION_MINOR, PIKA_VERSION_MICRO);
|
||||
}
|
||||
|
||||
void* obj_getStruct(PikaObj* self, char* name) {
|
||||
return args_getStruct(self->list, name);
|
||||
}
|
||||
|
@ -286,6 +286,7 @@ PikaObj* Obj_linkLibraryFile(PikaObj* self, char* input_file_name);
|
||||
NewFun obj_getClass(PikaObj* obj);
|
||||
|
||||
void pks_printVersion(void);
|
||||
void pks_getVersion(char *buff);
|
||||
void* obj_getStruct(PikaObj* self, char* name);
|
||||
|
||||
#define obj_refcntDec(self) (((self)->refcnt--))
|
||||
|
@ -36,7 +36,7 @@
|
||||
/* local head */
|
||||
typedef QueueObj AST;
|
||||
char* AST_toPikaASM(AST* ast, Args* outBuffs);
|
||||
char* Lexer_getTokens(Args* outBuffs, char* stmt);
|
||||
char* Lexer_parseLine(Args* outBuffs, char* stmt);
|
||||
int32_t AST_deinit(AST* ast);
|
||||
char* Parser_linesToAsm(Args* outBuffs, char* multiLine);
|
||||
uint8_t Parser_isContainToken(char* tokens,
|
||||
@ -138,7 +138,7 @@ char* strsDeleteBetween(Args* buffs_p, char* strIn, char begin, char end) {
|
||||
static uint8_t Lexer_isError(char* line) {
|
||||
Args buffs = {0};
|
||||
uint8_t res = 0; /* not error */
|
||||
char* tokens = Lexer_getTokens(&buffs, line);
|
||||
char* tokens = Lexer_parseLine(&buffs, line);
|
||||
if (NULL == tokens) {
|
||||
res = 1; /* lex error */
|
||||
goto exit;
|
||||
@ -350,7 +350,7 @@ char* Lexer_printTokens(Args* outBuffs, char* tokens) {
|
||||
|
||||
uint8_t Parser_checkIsDirect(char* str) {
|
||||
Args buffs = {0};
|
||||
char* tokens = Lexer_getTokens(&buffs, str);
|
||||
char* tokens = Lexer_parseLine(&buffs, str);
|
||||
uint8_t res = 0;
|
||||
pika_assert(NULL != tokens);
|
||||
if (Parser_isContainToken(tokens, TOKEN_operator, "=")) {
|
||||
@ -427,7 +427,7 @@ exit:
|
||||
|
||||
/* tokens is devided by space */
|
||||
/* a token is [TOKENTYPE|(CONTENT)] */
|
||||
char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
char* Lexer_parseLine(Args* outBuffs, char* stmt) {
|
||||
/* init */
|
||||
Arg* tokens_arg = New_arg(NULL);
|
||||
tokens_arg = arg_setStr(tokens_arg, "", "");
|
||||
@ -443,6 +443,7 @@ char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
uint8_t c6 = 0;
|
||||
int32_t symbol_start_index = -1;
|
||||
int is_in_string = 0;
|
||||
int is_number = 0;
|
||||
char* tokens;
|
||||
|
||||
/* process */
|
||||
@ -478,6 +479,10 @@ char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
c6 = stmt[i + 6];
|
||||
}
|
||||
if (-1 == symbol_start_index) {
|
||||
is_number = 0;
|
||||
if ((c0 >= '0') && (c0 <= '9')) {
|
||||
is_number = 1;
|
||||
}
|
||||
symbol_start_index = i;
|
||||
}
|
||||
|
||||
@ -538,6 +543,11 @@ char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
('+' == c0) || ('-' == c0) || ('!' == c0) || ('=' == c0) ||
|
||||
('%' == c0) || ('&' == c0) || ('|' == c0) || ('^' == c0) ||
|
||||
('~' == c0)) {
|
||||
if ('-' == c0 && is_number) {
|
||||
if ((cn1 == 'e') || (cn1 == 'E')) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (('*' == c0) || ('/' == c0)) {
|
||||
/*
|
||||
=, **=, //
|
||||
@ -687,7 +697,7 @@ char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
if (' ' == c0) {
|
||||
/* not get symbal */
|
||||
if (i == symbol_start_index) {
|
||||
symbol_start_index++;
|
||||
symbol_start_index = -1;
|
||||
} else {
|
||||
/* already get symbal */
|
||||
tokens_arg =
|
||||
@ -752,7 +762,7 @@ static const char operators[][9] = {
|
||||
char* Lexer_getOperator(Args* outBuffs, char* stmt) {
|
||||
Args buffs = {0};
|
||||
char* operator= NULL;
|
||||
char* tokens = Lexer_getTokens(&buffs, stmt);
|
||||
char* tokens = Lexer_parseLine(&buffs, stmt);
|
||||
|
||||
// use parse state foreach to get operator
|
||||
for (uint32_t i = 0; i < sizeof(operators) / 9; i++) {
|
||||
@ -888,7 +898,7 @@ void Cursor_parse(struct Cursor* ps, char* stmt) {
|
||||
ps->result = PIKA_RES_ERR_SYNTAX_ERROR;
|
||||
return;
|
||||
}
|
||||
ps->tokens = Lexer_getTokens(ps->buffs_p, stmt);
|
||||
ps->tokens = Lexer_parseLine(ps->buffs_p, stmt);
|
||||
if (NULL == ps->tokens) {
|
||||
ps->result = PIKA_RES_ERR_SYNTAX_ERROR;
|
||||
return;
|
||||
@ -1180,7 +1190,7 @@ uint8_t Parser_solveSelfOperator(Args* outbuffs,
|
||||
Args buffs = {0};
|
||||
char _operator[2] = {0};
|
||||
char* operator=(char*) _operator;
|
||||
char* tokens = Lexer_getTokens(&buffs, stmt);
|
||||
char* tokens = Lexer_parseLine(&buffs, stmt);
|
||||
uint8_t is_right = 0;
|
||||
if (Parser_isContainToken(tokens, TOKEN_operator, "+=")) {
|
||||
operator[0] = '+';
|
||||
|
@ -1167,8 +1167,9 @@ static Arg* VM_instruction_handler_NUM(PikaObj* self,
|
||||
return arg_setInt(numArg, "", strtol(strtol_buff, NULL, 2));
|
||||
}
|
||||
/* float */
|
||||
if (strIsContain(data, '.')) {
|
||||
return arg_setFloat(numArg, "", atof(data));
|
||||
if (strIsContain(data, '.') ||
|
||||
(strIsContain(data, 'e') || strIsContain(data, 'E'))) {
|
||||
return arg_setFloat(numArg, "", strtod(data, NULL));
|
||||
}
|
||||
/* int */
|
||||
return arg_setInt(numArg, "", fast_atoi(data));
|
||||
|
@ -153,4 +153,3 @@ uint8_t argType_isObject(ArgType type);
|
||||
arg_init_stack(&__name, __##__name##_buff, __size)
|
||||
|
||||
void arg_init_stack(Arg* self, uint8_t* buffer, uint32_t size);
|
||||
Arg* arg_setNameHash(Arg* self, Hash nameHash);
|
||||
|
@ -42,12 +42,9 @@ void args_deinit_stack(Args* self) {
|
||||
}
|
||||
|
||||
PIKA_RES args_setFloat(Args* self, char* name, double argFloat) {
|
||||
Arg* arg = args_getArg(self, name);
|
||||
Arg* arg_new = arg_setFloat(arg, name, argFloat);
|
||||
if (arg == arg_new) {
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
args_setArg(self, arg_new);
|
||||
Arg* argNew = New_arg(NULL);
|
||||
argNew = arg_setFloat(argNew, name, argFloat);
|
||||
args_setArg(self, argNew);
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
@ -63,7 +60,11 @@ void* args_getPtr(Args* self, char* name) {
|
||||
}
|
||||
|
||||
PIKA_RES args_setPtr(Args* self, char* name, void* argPointer) {
|
||||
return args_setPtrWithType(self, name, ARG_TYPE_POINTER, argPointer);
|
||||
PIKA_RES errCode = PIKA_RES_OK;
|
||||
Arg* argNew = New_arg(NULL);
|
||||
argNew = arg_setPtr(argNew, name, ARG_TYPE_POINTER, argPointer);
|
||||
args_setArg(self, argNew);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
PIKA_RES args_setRef(Args* self, char* name, void* argPointer) {
|
||||
@ -153,13 +154,9 @@ size_t args_getBytesSize(Args* self, char* name) {
|
||||
}
|
||||
|
||||
PIKA_RES args_setInt(Args* self, char* name, int64_t int64In) {
|
||||
Arg* arg = args_getArg(self, name);
|
||||
Arg* arg_new = arg_setInt(arg, name, int64In);
|
||||
if (arg_new == arg) {
|
||||
/* arg_new is a new alloced arg */
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
args_setArg(self, arg_new);
|
||||
Arg* argNew = New_arg(NULL);
|
||||
argNew = arg_setInt(argNew, name, int64In);
|
||||
args_setArg(self, argNew);
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
@ -331,15 +328,12 @@ PIKA_RES args_setArg(Args* self, Arg* arg) {
|
||||
#endif
|
||||
|
||||
LinkNode* args_getNode_hash(Args* self, Hash nameHash) {
|
||||
LinkNode** pnode = &self->firstNode;
|
||||
// uint8_t n = 0;
|
||||
while (NULL != (*pnode)) {
|
||||
Arg* arg = (Arg*)(*pnode);
|
||||
Hash thisNameHash = arg->name_hash;
|
||||
// n++;
|
||||
LinkNode* node = self->firstNode;
|
||||
int_fast8_t n = 0;
|
||||
while (NULL != node) {
|
||||
Arg* arg = (Arg*)node;
|
||||
Hash thisNameHash = arg_getNameHash(arg);
|
||||
if (thisNameHash == nameHash) {
|
||||
Arg* tmp = (Arg*)(*pnode);
|
||||
#if 0
|
||||
if (n > __PIKA_CFG_HASH_LIST_CACHE_SIZE) {
|
||||
/* the first __PIKA_CFG_HASH_LIST_CACHE_SIZE items in the list
|
||||
* is considered as a cache.
|
||||
@ -348,16 +342,15 @@ LinkNode* args_getNode_hash(Args* self, Hash nameHash) {
|
||||
*/
|
||||
|
||||
/*! remove current node from the list */
|
||||
*pnode = (LinkNode*)arg_getNext(tmp);
|
||||
node = (LinkNode*)arg_getNext((Arg*)arg);
|
||||
|
||||
/*! move the node to the cache */
|
||||
arg_setNext(tmp, (Arg*)(self->firstNode));
|
||||
self->firstNode = (LinkNode*)tmp;
|
||||
arg_setNext(arg, (Arg*)(self->firstNode));
|
||||
self->firstNode = (LinkNode*)arg;
|
||||
}
|
||||
#endif
|
||||
return (LinkNode*)tmp;
|
||||
return (LinkNode*)arg;
|
||||
}
|
||||
pnode = (LinkNode**)&(arg_getNext((Arg*)(*pnode)));
|
||||
node = (LinkNode*)arg_getNext((Arg*)node);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -478,14 +471,10 @@ PIKA_RES args_setPtrWithType(Args* self,
|
||||
char* name,
|
||||
ArgType type,
|
||||
void* objPtr) {
|
||||
PIKA_RES errCode = PIKA_RES_OK;
|
||||
Arg* arg = args_getArg(self, name);
|
||||
Arg* arg_new = arg_setPtr(arg, name, type, objPtr);
|
||||
if (arg == arg_new) {
|
||||
return errCode;
|
||||
}
|
||||
args_setArg(self, arg_new);
|
||||
return errCode;
|
||||
Arg* argNew = New_arg(NULL);
|
||||
argNew = arg_setPtr(argNew, name, type, objPtr);
|
||||
args_setArg(self, argNew);
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
PIKA_RES args_foreach(Args* self,
|
||||
@ -554,18 +543,22 @@ PikaList* New_list(void) {
|
||||
}
|
||||
|
||||
PIKA_RES list_setArg(PikaList* self, int index, Arg* arg) {
|
||||
char buff[11];
|
||||
char* i_str = fast_itoa(buff, index);
|
||||
int top = args_getInt(&self->super, "top");
|
||||
if (index > top) {
|
||||
return PIKA_RES_ERR_OUT_OF_RANGE;
|
||||
}
|
||||
Arg* new_arg = arg_copy(arg);
|
||||
new_arg = arg_setNameHash(new_arg, index);
|
||||
new_arg = arg_setName(new_arg, i_str);
|
||||
args_setArg(&self->super, new_arg);
|
||||
return PIKA_RES_OK;
|
||||
}
|
||||
|
||||
Arg* list_getArg(PikaList* self, int index) {
|
||||
return args_getArg_hash(&self->super, index);
|
||||
char buff[11];
|
||||
char* i_str = fast_itoa(buff, index);
|
||||
return args_getArg(&self->super, i_str);
|
||||
}
|
||||
|
||||
int list_getInt(PikaList* self, int index) {
|
||||
@ -590,8 +583,10 @@ void* list_getPtr(PikaList* self, int index) {
|
||||
|
||||
PIKA_RES list_append(PikaList* self, Arg* arg) {
|
||||
int top = args_getInt(&self->super, "top");
|
||||
char buff[11];
|
||||
char* topStr = fast_itoa(buff, top);
|
||||
Arg* arg_to_push = arg_copy(arg);
|
||||
arg_setNameHash(arg_to_push, (Hash)top);
|
||||
arg_setName(arg_to_push, topStr);
|
||||
args_setArg(&self->super, arg_to_push);
|
||||
/* top++ */
|
||||
return args_setInt(&self->super, "top", top + 1);
|
||||
|
@ -122,7 +122,6 @@ Args* New_args(Args* args);
|
||||
typedef struct PikaList PikaList;
|
||||
struct PikaList {
|
||||
Args super;
|
||||
uint32_t top;
|
||||
};
|
||||
|
||||
typedef struct PikaTuple PikaTuple;
|
||||
@ -177,7 +176,8 @@ char* strsFormatArg(Args* out_buffs, char* fmt, Arg* arg);
|
||||
#define tuple_getArg(self, index) (list_getArg((&((self)->super)), (index)))
|
||||
#define tuple_getSize(self) (list_getSize((&((self)->super))))
|
||||
#define tuple_getInt(self, index) (list_getInt((&((self)->super)), (index)))
|
||||
#define tuple_getFloat(self, index) (list_getFloat((&((self)->super)), (index)))
|
||||
#define tuple_getFloat(self, index) \
|
||||
(list_getFloat((&((self)->super)), (index)))
|
||||
#define tuple_getStr(self, index) (list_getStr((&((self)->super)), (index)))
|
||||
#define tuple_getPtr(self, index) (list_getPtr((&((self)->super)), (index)))
|
||||
#define tuple_getType(self, index) (list_getType((&((self)->super)), (index)))
|
||||
|
@ -51,7 +51,8 @@ int32_t queue_pushArg(Queue* queue, Arg* arg) {
|
||||
uint64_t top = args_getInt(args, "__t");
|
||||
/* add top */
|
||||
args_setInt(args, "__t", top + 1);
|
||||
arg = arg_setNameHash(arg, top);
|
||||
char buff[11];
|
||||
arg = arg_setName(arg, fast_itoa(buff, top));
|
||||
return args_setArg(args, arg);
|
||||
}
|
||||
|
||||
@ -64,7 +65,8 @@ Arg* __queue_popArg_noRmoveArg(Queue* queue) {
|
||||
}
|
||||
/* add bottom */
|
||||
args_setInt(args, "__b", bottom + 1);
|
||||
Arg* res = args_getArg_hash(args, bottom);
|
||||
char buff[11];
|
||||
Arg* res = args_getArg(args, fast_itoa(buff, bottom));
|
||||
/* not deinit arg to keep str buff */
|
||||
return res;
|
||||
}
|
||||
|
@ -1,11 +1,3 @@
|
||||
#undef PIKA_LINE_BUFF_SIZE
|
||||
#undef PIKA_SPRINTF_BUFF_SIZE
|
||||
#undef PIKA_STACK_BUFF_SIZE
|
||||
#undef PIKA_NAME_BUFF_SIZE
|
||||
#undef PIKA_PATH_BUFF_SIZE
|
||||
#undef PIKA_BYTES_DEFAULT_SIZE
|
||||
#undef PIKA_READ_FILE_BUFF_SIZE
|
||||
|
||||
#define PIKA_LINE_BUFF_SIZE 1280
|
||||
#define PIKA_SPRINTF_BUFF_SIZE 2560
|
||||
#define PIKA_STACK_BUFF_SIZE 2560
|
||||
|
Loading…
x
Reference in New Issue
Block a user