redirect PikaStdDevice.Time to time, fix msc

This commit is contained in:
lyon 2023-01-10 11:41:21 +08:00
parent 1610574158
commit 8021938826
6 changed files with 25 additions and 8 deletions

View File

@ -98,8 +98,8 @@ class GPIO(BaseDev):
def platformRead(self): ...
# class Time(BaseDev):
# use time module instead
def Time() -> time:
""" # use time module instead """
class ADC(BaseDev):

View File

@ -3,7 +3,7 @@
extern PikaEventListener* g_pika_device_event_listener;
void _PikaStdDevice_event_handler(pika_dev* dev, int signal) {
pks_eventListener_sendSignal(g_pika_device_event_listener, (uintptr_t)dev,
signal);
signal);
}
void _PikaStdDevice_setCallBack(PikaObj* self,
@ -17,3 +17,14 @@ void _PikaStdDevice_setCallBack(PikaObj* self,
/* regist event to event listener */
pks_eventListener_registEvent(g_pika_device_event_listener, eventId, self);
}
extern volatile PikaObj* __pikaMain;
PikaObj* PikaStdDevice_Time(PikaObj* self) {
PikaObj* time = obj_getPtr((PikaObj*)__pikaMain, "time");
if(NULL == time){
obj_setErrorCode(self, -1);
obj_setSysOut(self, "Error: please install and import 'time' module");
return NULL;
}
return time;
}

View File

@ -98,8 +98,8 @@ class GPIO(BaseDev):
def platformRead(self): ...
# def Time() -> time:
# """ # use time module instead """
def Time() -> time:
""" # use time module instead """
class ADC(BaseDev):

View File

@ -20,5 +20,11 @@ void _PikaStdDevice_setCallBack(PikaObj* self,
extern volatile PikaObj* __pikaMain;
PikaObj* PikaStdDevice_Time(PikaObj* self) {
return obj_getPtr((PikaObj*)__pikaMain, "time");
PikaObj* time = obj_getPtr((PikaObj*)__pikaMain, "time");
if(NULL == time){
obj_setErrorCode(self, -1);
obj_setSysOut(self, "Error: please install and import 'time' module");
return NULL;
}
return time;
}

View File

@ -397,11 +397,11 @@ impl Compiler {
/* analyse function define */
if line.starts_with("def ") {
let package_now_name = match compiler.package_name_now.clone() {
let package_now_name = file_name.clone();
let package_now = match compiler.class_list.get_mut(&package_now_name) {
Some(s) => s,
None => return compiler,
};
let package_now = compiler.class_list.get_mut(&package_now_name).unwrap();
package_now.push_method(line, compiler.decorator_list_now.clone());
compiler.decorator_list_now.clear();
return compiler;