mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 20:40:18 +00:00
up
This commit is contained in:
parent
991c4926d5
commit
d65636babb
@ -42,7 +42,7 @@ with open("amalgamated/pocketpy.h", "wt", encoding='utf-8') as f:
|
|||||||
final_text = \
|
final_text = \
|
||||||
r'''/*
|
r'''/*
|
||||||
* Copyright (c) 2022 blueloveTH
|
* Copyright (c) 2022 blueloveTH
|
||||||
* Distributed Under The GNU General Public License v2.0
|
* Distributed Under The LGPLv3 License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef POCKETPY_H
|
#ifndef POCKETPY_H
|
||||||
@ -51,4 +51,6 @@ r'''/*
|
|||||||
f.write(final_text)
|
f.write(final_text)
|
||||||
|
|
||||||
shutil.copy("src/main.cpp", "amalgamated/main.cpp")
|
shutil.copy("src/main.cpp", "amalgamated/main.cpp")
|
||||||
os.system("g++ -o pocketpy amalgamated/main.cpp --std=c++17 -O1 -pthread")
|
os.system("g++ -o pocketpy amalgamated/main.cpp --std=c++17 -O1 -pthread")
|
||||||
|
|
||||||
|
os.system("cp amalgamated/pocketpy.h plugins/flutter/src/pocketpy.h")
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 blueloveTH
|
* Copyright (c) 2022 blueloveTH
|
||||||
* Distributed Under The GNU General Public License v2.0
|
* Distributed Under The LGPLv3 License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef POCKETPY_H
|
#ifndef POCKETPY_H
|
||||||
@ -38,7 +38,7 @@
|
|||||||
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
#define UNREACHABLE() throw std::runtime_error( __FILE__ + std::string(":") + std::to_string(__LINE__) + " UNREACHABLE()!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PK_VERSION "0.4.6"
|
#define PK_VERSION "0.4.7"
|
||||||
|
|
||||||
|
|
||||||
namespace pkpy{
|
namespace pkpy{
|
||||||
@ -6732,8 +6732,8 @@ void __addModuleJson(VM* vm){
|
|||||||
|
|
||||||
void __addModuleMath(VM* vm){
|
void __addModuleMath(VM* vm){
|
||||||
PyVar mod = vm->newModule("math");
|
PyVar mod = vm->newModule("math");
|
||||||
vm->setAttr(mod, "pi", vm->PyFloat(3.14159265358979323846));
|
vm->setAttr(mod, "pi", vm->PyFloat(3.1415926535897932384));
|
||||||
vm->setAttr(mod, "e", vm->PyFloat(2.7182818284590452354));
|
vm->setAttr(mod, "e" , vm->PyFloat(2.7182818284590452354));
|
||||||
|
|
||||||
vm->bindFunc(mod, "log", [](VM* vm, const pkpy::ArgList& args) {
|
vm->bindFunc(mod, "log", [](VM* vm, const pkpy::ArgList& args) {
|
||||||
vm->__checkArgSize(args, 1);
|
vm->__checkArgSize(args, 1);
|
||||||
@ -6801,7 +6801,7 @@ public:
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__EXPORT
|
__EXPORT
|
||||||
/// Delete a class pointer allocated by `pkpy_xxx_xxx`.
|
/// Delete a pointer allocated by `pkpy_xxx_xxx`.
|
||||||
/// It can be `VM*`, `REPL*`, `ThreadedVM*`, `char*`, etc.
|
/// It can be `VM*`, `REPL*`, `ThreadedVM*`, `char*`, etc.
|
||||||
///
|
///
|
||||||
/// !!!
|
/// !!!
|
||||||
@ -6838,8 +6838,12 @@ extern "C" {
|
|||||||
char* pkpy_vm_get_global(VM* vm, const char* name){
|
char* pkpy_vm_get_global(VM* vm, const char* name){
|
||||||
auto it = vm->_main->attribs.find(name);
|
auto it = vm->_main->attribs.find(name);
|
||||||
if(it == vm->_main->attribs.end()) return nullptr;
|
if(it == vm->_main->attribs.end()) return nullptr;
|
||||||
_Str _json = vm->PyStr_AS_C(vm->asJson(it->second));
|
try{
|
||||||
return strdup(_json.c_str());
|
_Str _json = vm->PyStr_AS_C(vm->asJson(it->second));
|
||||||
|
return strdup(_json.c_str());
|
||||||
|
}catch(...){
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__EXPORT
|
__EXPORT
|
||||||
@ -6852,8 +6856,12 @@ extern "C" {
|
|||||||
if(code == nullptr) return nullptr;
|
if(code == nullptr) return nullptr;
|
||||||
PyVarOrNull ret = vm->exec(code);
|
PyVarOrNull ret = vm->exec(code);
|
||||||
if(ret == nullptr) return nullptr;
|
if(ret == nullptr) return nullptr;
|
||||||
_Str _json = vm->PyStr_AS_C(vm->asJson(ret));
|
try{
|
||||||
return strdup(_json.c_str());
|
_Str _json = vm->PyStr_AS_C(vm->asJson(ret));
|
||||||
|
return strdup(_json.c_str());
|
||||||
|
}catch(...){
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
__EXPORT
|
__EXPORT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user