diff --git a/lutin_rabbit-core.py b/lutin_rabbit-core.py index 2b32286..cd6cd8d 100644 --- a/lutin_rabbit-core.py +++ b/lutin_rabbit-core.py @@ -32,6 +32,7 @@ def configure(target, my_module): 'rabbit/sqapi.cpp', 'rabbit/sqlexer.cpp', 'rabbit/sqclass.cpp', + 'rabbit/AutoDec.cpp', 'rabbit/VirtualMachine.cpp', 'rabbit/sqtable.cpp', 'rabbit/sqstate.cpp', @@ -51,6 +52,7 @@ def configure(target, my_module): ]) my_module.add_header_file([ 'rabbit/sqclass.hpp', + 'rabbit/AutoDec.hpp', 'rabbit/VirtualMachine.hpp', 'rabbit/sqstate.hpp', 'rabbit/rabbit.hpp', diff --git a/rabbit/AutoDec.cpp b/rabbit/AutoDec.cpp new file mode 100644 index 0000000..8d36982 --- /dev/null +++ b/rabbit/AutoDec.cpp @@ -0,0 +1,18 @@ +/** + * @author Alberto DEMICHELIS + * @author Edouard DUPIN + * @copyright 2018, Edouard DUPIN, all right reserved + * @copyright 2003-2017, Alberto DEMICHELIS, all right reserved + * @license MPL-2 (see license file) + */ + +#include + +rabbit::AutoDec::AutoDec(int64_t* _count) { + m_countPointer = _count; +} + +rabbit::AutoDec::~AutoDec() { + (*m_countPointer)--; +} + diff --git a/rabbit/AutoDec.hpp b/rabbit/AutoDec.hpp new file mode 100644 index 0000000..bd9cc64 --- /dev/null +++ b/rabbit/AutoDec.hpp @@ -0,0 +1,22 @@ +/** + * @author Alberto DEMICHELIS + * @author Edouard DUPIN + * @copyright 2018, Edouard DUPIN, all right reserved + * @copyright 2003-2017, Alberto DEMICHELIS, all right reserved + * @license MPL-2 (see license file) + */ +#pragma once + +#include +#include + +namespace rabbit { + class AutoDec { + public: + AutoDec(int64_t* _count); + ~AutoDec(); + private: + int64_t* m_countPointer; + }; +} + diff --git a/rabbit/VirtualMachine.hpp b/rabbit/VirtualMachine.hpp index 34345a5..75e66e5 100644 --- a/rabbit/VirtualMachine.hpp +++ b/rabbit/VirtualMachine.hpp @@ -9,6 +9,7 @@ #include #include +#include #define MAX_NATIVE_CALLS 100 #define MIN_STACK_OVERHEAD 15 @@ -20,10 +21,11 @@ #define GET_FLAG_RAW 0x00000001 #define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002 + //base lib void sq_base_register(rabbit::VirtualMachine* v); -struct SQExceptionTrap{ +struct SQExceptionTrap { SQExceptionTrap() {} SQExceptionTrap(int64_t ss, int64_t stackbase,SQInstruction *ip, int64_t ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;} SQExceptionTrap(const SQExceptionTrap &et) { (*this) = et; } @@ -40,7 +42,6 @@ namespace rabbit { { public: struct callInfo{ - //callInfo() { _generator = NULL;} SQInstruction *_ip; SQObjectPtr *_literals; SQObjectPtr _closure; @@ -187,15 +188,6 @@ namespace rabbit { int64_t _suspended_traps; }; - struct AutoDec{ - AutoDec(int64_t *n) { - _n = n; - } - ~AutoDec() { - (*_n)--; - } - int64_t *_n; - }; inline SQObjectPtr &stack_get(rabbit::VirtualMachine* _vm,int64_t _idx) { if (_idx>=0) { @@ -204,6 +196,7 @@ namespace rabbit { return _vm->getUp(_idx); } } + #define _ss(_vm_) (_vm_)->_sharedstate #define PUSH_CALLINFO(v,nci){ \