diff --git a/src/better_sqlite3.cpp b/src/better_sqlite3.cpp index 4b93ab5f..1addc7f4 100644 --- a/src/better_sqlite3.cpp +++ b/src/better_sqlite3.cpp @@ -2,7 +2,7 @@ // #include "better_sqlite3.hpp" -#line 153 "./src/util/macros.lzz" +#line 150 "./src/util/macros.lzz" void SetPrototypeGetter( v8::Isolate* isolate, v8::Local data, @@ -11,7 +11,7 @@ void SetPrototypeGetter( v8::AccessorGetterCallback func ) { v8::HandleScope scope(isolate); - + #if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121 recv->InstanceTemplate()->SetAccessor( InternalizedFromLatin1(isolate, name), @@ -30,7 +30,7 @@ void SetPrototypeGetter( ); #endif } -#line 183 "./src/util/macros.lzz" +#line 180 "./src/util/macros.lzz" #ifndef V8_COMPRESS_POINTERS_IN_SHARED_CAGE #define SAFE_NEW_BUFFER(env, data, length, finalizeCallback, finalizeHint) node::Buffer::New(env, data, length, finalizeCallback, finalizeHint) #else @@ -103,33 +103,33 @@ namespace Data #line 70 "./src/util/data.lzz" static char const RAW = 3; } -#line 37 "./src/util/macros.lzz" +#line 34 "./src/util/macros.lzz" void ThrowError (char const * message) -#line 37 "./src/util/macros.lzz" +#line 34 "./src/util/macros.lzz" { v8 :: Isolate * isolate = v8 :: Isolate :: GetCurrent ( ) ; isolate->ThrowException(v8::Exception::Error(StringFromUtf8(isolate, message, -1))); } -#line 38 "./src/util/macros.lzz" +#line 35 "./src/util/macros.lzz" void ThrowTypeError (char const * message) -#line 38 "./src/util/macros.lzz" +#line 35 "./src/util/macros.lzz" { v8 :: Isolate * isolate = v8 :: Isolate :: GetCurrent ( ) ; isolate->ThrowException(v8::Exception::TypeError(StringFromUtf8(isolate, message, -1))); } -#line 39 "./src/util/macros.lzz" +#line 36 "./src/util/macros.lzz" void ThrowRangeError (char const * message) -#line 39 "./src/util/macros.lzz" +#line 36 "./src/util/macros.lzz" { v8 :: Isolate * isolate = v8 :: Isolate :: GetCurrent ( ) ; isolate->ThrowException(v8::Exception::RangeError(StringFromUtf8(isolate, message, -1))); } -#line 105 "./src/util/macros.lzz" +#line 102 "./src/util/macros.lzz" v8::Local NewConstructorTemplate (v8::Isolate * isolate, v8::Local data, v8::FunctionCallback func, char const * name) -#line 110 "./src/util/macros.lzz" +#line 107 "./src/util/macros.lzz" { v8::Local t = v8::FunctionTemplate::New(isolate, func, data); t->InstanceTemplate()->SetInternalFieldCount(1); t->SetClassName(InternalizedFromLatin1(isolate, name)); return t; } -#line 116 "./src/util/macros.lzz" +#line 113 "./src/util/macros.lzz" void SetPrototypeMethod (v8::Isolate * isolate, v8::Local data, v8::Local recv, char const * name, v8::FunctionCallback func) -#line 122 "./src/util/macros.lzz" +#line 119 "./src/util/macros.lzz" { v8::HandleScope scope(isolate); recv->PrototypeTemplate()->Set( @@ -137,9 +137,9 @@ void SetPrototypeMethod (v8::Isolate * isolate, v8::Local data, v v8::FunctionTemplate::New(isolate, func, data, v8::Signature::New(isolate, recv)) ); } -#line 129 "./src/util/macros.lzz" +#line 126 "./src/util/macros.lzz" void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local data, v8::Local recv, v8::Local symbol, v8::FunctionCallback func) -#line 135 "./src/util/macros.lzz" +#line 132 "./src/util/macros.lzz" { v8::HandleScope scope(isolate); recv->PrototypeTemplate()->Set( @@ -267,9 +267,9 @@ CS::CS (v8::Isolate * isolate) SetCode(isolate, SQLITE_OK_LOAD_PERMANENTLY, "SQLITE_OK_LOAD_PERMANENTLY"); } #line 140 "./src/util/constants.lzz" -void CS::SetString (v8::Isolate * isolate, CopyablePersistent & constant, char const * str) +void CS::SetString (v8::Isolate * isolate, v8::Global & constant, char const * str) #line 140 "./src/util/constants.lzz" - { + { constant.Reset(isolate, InternalizedFromLatin1(isolate, str)); } #line 144 "./src/util/constants.lzz" diff --git a/src/better_sqlite3.hpp b/src/better_sqlite3.hpp index 44bef308..99db7bdc 100644 --- a/src/better_sqlite3.hpp +++ b/src/better_sqlite3.hpp @@ -16,9 +16,7 @@ #include #include #include -#line 31 "./src/util/macros.lzz" -template using CopyablePersistent = v8::Global; -#line 144 "./src/util/macros.lzz" +#line 141 "./src/util/macros.lzz" void SetPrototypeGetter( v8::Isolate* isolate, v8::Local data, @@ -37,29 +35,29 @@ v8::Local InternalizedFromUtf8 (v8::Isolate * isolate, char const * v8::Local InternalizedFromUtf8OrNull (v8::Isolate * isolate, char const * data, int length); #line 26 "./src/util/macros.lzz" v8::Local InternalizedFromLatin1 (v8::Isolate * isolate, char const * str); -#line 33 "./src/util/macros.lzz" -void SetFrozen (v8::Isolate * isolate, v8::Local ctx, v8::Local obj, CopyablePersistent & key, v8::Local value); -#line 37 "./src/util/macros.lzz" +#line 30 "./src/util/macros.lzz" +void SetFrozen (v8::Isolate * isolate, v8::Local ctx, v8::Local obj, v8::Global & key, v8::Local value); +#line 34 "./src/util/macros.lzz" void ThrowError (char const * message); -#line 38 "./src/util/macros.lzz" +#line 35 "./src/util/macros.lzz" void ThrowTypeError (char const * message); -#line 39 "./src/util/macros.lzz" +#line 36 "./src/util/macros.lzz" void ThrowRangeError (char const * message); -#line 91 "./src/util/macros.lzz" +#line 88 "./src/util/macros.lzz" bool IS_SKIPPED (char c); -#line 96 "./src/util/macros.lzz" +#line 93 "./src/util/macros.lzz" template -#line 96 "./src/util/macros.lzz" +#line 93 "./src/util/macros.lzz" T * ALLOC_ARRAY (size_t count); -#line 101 "./src/util/macros.lzz" +#line 98 "./src/util/macros.lzz" template -#line 101 "./src/util/macros.lzz" +#line 98 "./src/util/macros.lzz" void FREE_ARRAY (T * array_pointer); -#line 105 "./src/util/macros.lzz" +#line 102 "./src/util/macros.lzz" v8::Local NewConstructorTemplate (v8::Isolate * isolate, v8::Local data, v8::FunctionCallback func, char const * name); -#line 116 "./src/util/macros.lzz" +#line 113 "./src/util/macros.lzz" void SetPrototypeMethod (v8::Isolate * isolate, v8::Local data, v8::Local recv, char const * name, v8::FunctionCallback func); -#line 129 "./src/util/macros.lzz" +#line 126 "./src/util/macros.lzz" void SetPrototypeSymbolMethod (v8::Isolate * isolate, v8::Local data, v8::Local recv, v8::Local symbol, v8::FunctionCallback func); #line 1 "./src/util/constants.lzz" class CS @@ -71,49 +69,49 @@ class CS #line 10 "./src/util/constants.lzz" explicit CS (v8::Isolate * isolate); #line 119 "./src/util/constants.lzz" - CopyablePersistent database; + v8::Global database; #line 120 "./src/util/constants.lzz" - CopyablePersistent reader; + v8::Global reader; #line 121 "./src/util/constants.lzz" - CopyablePersistent source; + v8::Global source; #line 122 "./src/util/constants.lzz" - CopyablePersistent memory; + v8::Global memory; #line 123 "./src/util/constants.lzz" - CopyablePersistent readonly; + v8::Global readonly; #line 124 "./src/util/constants.lzz" - CopyablePersistent name; + v8::Global name; #line 125 "./src/util/constants.lzz" - CopyablePersistent next; + v8::Global next; #line 126 "./src/util/constants.lzz" - CopyablePersistent length; + v8::Global length; #line 127 "./src/util/constants.lzz" - CopyablePersistent done; + v8::Global done; #line 128 "./src/util/constants.lzz" - CopyablePersistent value; + v8::Global value; #line 129 "./src/util/constants.lzz" - CopyablePersistent changes; + v8::Global changes; #line 130 "./src/util/constants.lzz" - CopyablePersistent lastInsertRowid; + v8::Global lastInsertRowid; #line 131 "./src/util/constants.lzz" - CopyablePersistent statement; + v8::Global statement; #line 132 "./src/util/constants.lzz" - CopyablePersistent column; + v8::Global column; #line 133 "./src/util/constants.lzz" - CopyablePersistent table; + v8::Global table; #line 134 "./src/util/constants.lzz" - CopyablePersistent type; + v8::Global type; #line 135 "./src/util/constants.lzz" - CopyablePersistent totalPages; + v8::Global totalPages; #line 136 "./src/util/constants.lzz" - CopyablePersistent remainingPages; + v8::Global remainingPages; #line 138 "./src/util/constants.lzz" private: #line 140 "./src/util/constants.lzz" - static void SetString (v8::Isolate * isolate, CopyablePersistent & constant, char const * str); + static void SetString (v8::Isolate * isolate, v8::Global & constant, char const * str); #line 144 "./src/util/constants.lzz" void SetCode (v8::Isolate * isolate, int code, char const * str); #line 150 "./src/util/constants.lzz" - std::unordered_map > codes; + std::unordered_map > codes; }; #line 1 "./src/util/bind-map.lzz" class BindMap @@ -138,7 +136,7 @@ class BindMap #line 22 "./src/util/bind-map.lzz" explicit Pair (v8::Isolate * isolate, Pair * pair); #line 25 "./src/util/bind-map.lzz" - CopyablePersistent const name; + v8::Global const name; #line 26 "./src/util/bind-map.lzz" int const index; }; @@ -305,7 +303,7 @@ class Database : public node::ObjectWrap #line 464 "./src/objects/database.lzz" Addon * const addon; #line 465 "./src/objects/database.lzz" - CopyablePersistent const logger; + v8::Global const logger; #line 466 "./src/objects/database.lzz" std::set stmts; #line 467 "./src/objects/database.lzz" @@ -519,7 +517,7 @@ class CustomFunction : protected DataConverter #line 56 "./src/util/custom-function.lzz" v8::Isolate * const isolate; #line 57 "./src/util/custom-function.lzz" - CopyablePersistent const fn; + v8::Global const fn; #line 58 "./src/util/custom-function.lzz" bool const safe_ints; }; @@ -541,7 +539,7 @@ class CustomAggregate : public CustomFunction #line 37 "./src/util/custom-aggregate.lzz" private: #line 39 "./src/util/custom-aggregate.lzz" - static void xStepBase (sqlite3_context * invocation, int argc, sqlite3_value * * argv, CopyablePersistent const CustomAggregate::* ptrtm); + static void xStepBase (sqlite3_context * invocation, int argc, sqlite3_value * * argv, v8::Global const CustomAggregate::* ptrtm); #line 58 "./src/util/custom-aggregate.lzz" static void xValueBase (sqlite3_context * invocation, bool is_final); #line 82 "./src/util/custom-aggregate.lzz" @@ -550,7 +548,7 @@ class CustomAggregate : public CustomFunction #line 82 "./src/util/custom-aggregate.lzz" public: #line 83 "./src/util/custom-aggregate.lzz" - CopyablePersistent value; + v8::Global value; #line 84 "./src/util/custom-aggregate.lzz" bool initialized; #line 85 "./src/util/custom-aggregate.lzz" @@ -567,11 +565,11 @@ class CustomAggregate : public CustomFunction #line 117 "./src/util/custom-aggregate.lzz" bool const invoke_start; #line 118 "./src/util/custom-aggregate.lzz" - CopyablePersistent const inverse; + v8::Global const inverse; #line 119 "./src/util/custom-aggregate.lzz" - CopyablePersistent const result; + v8::Global const result; #line 120 "./src/util/custom-aggregate.lzz" - CopyablePersistent const start; + v8::Global const start; }; #line 1 "./src/util/custom-table.lzz" class CustomTable @@ -608,7 +606,7 @@ class CustomTable #line 103 "./src/util/custom-table.lzz" bool const safe_ints; #line 104 "./src/util/custom-table.lzz" - CopyablePersistent const generator; + v8::Global const generator; #line 105 "./src/util/custom-table.lzz" std::vector const parameter_names; }; @@ -626,11 +624,11 @@ class CustomTable #line 122 "./src/util/custom-table.lzz" sqlite3_vtab_cursor base; #line 123 "./src/util/custom-table.lzz" - CopyablePersistent iterator; + v8::Global iterator; #line 124 "./src/util/custom-table.lzz" - CopyablePersistent next; + v8::Global next; #line 125 "./src/util/custom-table.lzz" - CopyablePersistent row; + v8::Global row; #line 126 "./src/util/custom-table.lzz" bool done; #line 127 "./src/util/custom-table.lzz" @@ -685,7 +683,7 @@ class CustomTable #line 402 "./src/util/custom-table.lzz" std::string const name; #line 403 "./src/util/custom-table.lzz" - CopyablePersistent const factory; + v8::Global const factory; }; #line 65 "./src/util/data.lzz" namespace Data @@ -793,13 +791,13 @@ struct Addon #line 52 "./src/better_sqlite3.lzz" sqlite3_uint64 NextId (); #line 56 "./src/better_sqlite3.lzz" - CopyablePersistent Statement; + v8::Global Statement; #line 57 "./src/better_sqlite3.lzz" - CopyablePersistent StatementIterator; + v8::Global StatementIterator; #line 58 "./src/better_sqlite3.lzz" - CopyablePersistent Backup; + v8::Global Backup; #line 59 "./src/better_sqlite3.lzz" - CopyablePersistent SqliteError; + v8::Global SqliteError; #line 60 "./src/better_sqlite3.lzz" v8::FunctionCallbackInfo const * privileged_info; #line 61 "./src/better_sqlite3.lzz" @@ -834,31 +832,31 @@ LZZ_INLINE v8::Local InternalizedFromLatin1 (v8::Isolate * isolate, { return v8::String::NewFromOneByte(isolate, reinterpret_cast(str), v8::NewStringType::kInternalized).ToLocalChecked(); } -#line 33 "./src/util/macros.lzz" -LZZ_INLINE void SetFrozen (v8::Isolate * isolate, v8::Local ctx, v8::Local obj, CopyablePersistent & key, v8::Local value) -#line 33 "./src/util/macros.lzz" - { +#line 30 "./src/util/macros.lzz" +LZZ_INLINE void SetFrozen (v8::Isolate * isolate, v8::Local ctx, v8::Local obj, v8::Global & key, v8::Local value) +#line 30 "./src/util/macros.lzz" + { obj->DefineOwnProperty(ctx, key.Get(isolate), value, static_cast(v8::DontDelete | v8::ReadOnly)).FromJust(); } -#line 91 "./src/util/macros.lzz" +#line 88 "./src/util/macros.lzz" LZZ_INLINE bool IS_SKIPPED (char c) -#line 91 "./src/util/macros.lzz" +#line 88 "./src/util/macros.lzz" { return c == ' ' || c == ';' || (c >= '\t' && c <= '\r'); } -#line 96 "./src/util/macros.lzz" +#line 93 "./src/util/macros.lzz" template -#line 96 "./src/util/macros.lzz" +#line 93 "./src/util/macros.lzz" LZZ_INLINE T * ALLOC_ARRAY (size_t count) -#line 96 "./src/util/macros.lzz" +#line 93 "./src/util/macros.lzz" { return static_cast(::operator new[](count * sizeof(T))); } -#line 101 "./src/util/macros.lzz" +#line 98 "./src/util/macros.lzz" template -#line 101 "./src/util/macros.lzz" +#line 98 "./src/util/macros.lzz" LZZ_INLINE void FREE_ARRAY (T * array_pointer) -#line 101 "./src/util/macros.lzz" +#line 98 "./src/util/macros.lzz" { ::operator delete[](array_pointer); } @@ -952,9 +950,9 @@ LZZ_INLINE bool Backup::Compare (Backup const * const a, Backup const * const b) return a->id < b->id; } #line 39 "./src/util/custom-aggregate.lzz" -LZZ_INLINE void CustomAggregate::xStepBase (sqlite3_context * invocation, int argc, sqlite3_value * * argv, CopyablePersistent const CustomAggregate::* ptrtm) +LZZ_INLINE void CustomAggregate::xStepBase (sqlite3_context * invocation, int argc, sqlite3_value * * argv, v8::Global const CustomAggregate::* ptrtm) #line 39 "./src/util/custom-aggregate.lzz" - { + { CustomAggregate * self = static_cast < CustomAggregate * > ( sqlite3_user_data ( invocation ) ) ; v8 :: Isolate * isolate = self -> isolate ; v8 :: HandleScope scope ( isolate ) ; Accumulator * acc = self -> GetAccumulator ( invocation ) ; if ( acc -> value . IsEmpty ( ) ) return ; v8::Local args_fast[5]; diff --git a/src/better_sqlite3.lzz b/src/better_sqlite3.lzz index aae5d10a..430991fc 100644 --- a/src/better_sqlite3.lzz +++ b/src/better_sqlite3.lzz @@ -53,10 +53,10 @@ struct Addon { return next_id++; } - CopyablePersistent Statement; - CopyablePersistent StatementIterator; - CopyablePersistent Backup; - CopyablePersistent SqliteError; + v8::Global Statement; + v8::Global StatementIterator; + v8::Global Backup; + v8::Global SqliteError; NODE_ARGUMENTS_POINTER privileged_info; sqlite3_uint64 next_id; CS cs; diff --git a/src/objects/database.lzz b/src/objects/database.lzz index 14e80f70..28294fa3 100644 --- a/src/objects/database.lzz +++ b/src/objects/database.lzz @@ -462,7 +462,7 @@ private: const bool has_logger; unsigned short iterators; Addon* const addon; - const CopyablePersistent logger; + const v8::Global logger; std::set stmts; std::set backups; }; diff --git a/src/util/bind-map.lzz b/src/util/bind-map.lzz index 66a73f13..766d0f94 100644 --- a/src/util/bind-map.lzz +++ b/src/util/bind-map.lzz @@ -22,7 +22,7 @@ public: explicit Pair(v8::Isolate* isolate, Pair* pair) : name(isolate, pair->name), index(pair->index) {} - const CopyablePersistent name; + const v8::Global name; const int index; }; diff --git a/src/util/constants.lzz b/src/util/constants.lzz index e1123c2f..94b3a52b 100644 --- a/src/util/constants.lzz +++ b/src/util/constants.lzz @@ -116,28 +116,28 @@ public: SetCode(isolate, SQLITE_OK_LOAD_PERMANENTLY, "SQLITE_OK_LOAD_PERMANENTLY"); } - CopyablePersistent database; - CopyablePersistent reader; - CopyablePersistent source; - CopyablePersistent memory; - CopyablePersistent readonly; - CopyablePersistent name; - CopyablePersistent next; - CopyablePersistent length; - CopyablePersistent done; - CopyablePersistent value; - CopyablePersistent changes; - CopyablePersistent lastInsertRowid; - CopyablePersistent statement; - CopyablePersistent column; - CopyablePersistent table; - CopyablePersistent type; - CopyablePersistent totalPages; - CopyablePersistent remainingPages; + v8::Global database; + v8::Global reader; + v8::Global source; + v8::Global memory; + v8::Global readonly; + v8::Global name; + v8::Global next; + v8::Global length; + v8::Global done; + v8::Global value; + v8::Global changes; + v8::Global lastInsertRowid; + v8::Global statement; + v8::Global column; + v8::Global table; + v8::Global type; + v8::Global totalPages; + v8::Global remainingPages; private: - static void SetString(v8::Isolate* isolate, CopyablePersistent& constant, const char* str) { + static void SetString(v8::Isolate* isolate, v8::Global& constant, const char* str) { constant.Reset(isolate, InternalizedFromLatin1(isolate, str)); } @@ -147,5 +147,5 @@ private: std::forward_as_tuple(isolate, InternalizedFromLatin1(isolate, str))); } - std::unordered_map > codes; + std::unordered_map > codes; }; diff --git a/src/util/custom-aggregate.lzz b/src/util/custom-aggregate.lzz index ab41477a..ec52ea82 100644 --- a/src/util/custom-aggregate.lzz +++ b/src/util/custom-aggregate.lzz @@ -36,7 +36,7 @@ public: private: - static inline void xStepBase(sqlite3_context* invocation, int argc, sqlite3_value** argv, const CopyablePersistent CustomAggregate::*ptrtm) { + static inline void xStepBase(sqlite3_context* invocation, int argc, sqlite3_value** argv, const v8::Global CustomAggregate::*ptrtm) { AGGREGATE_START(); v8::Local args_fast[5]; @@ -80,7 +80,7 @@ private: } struct Accumulator { public: - CopyablePersistent value; + v8::Global value; bool initialized; bool is_window; } @@ -115,7 +115,7 @@ private: const bool invoke_result; const bool invoke_start; - const CopyablePersistent inverse; - const CopyablePersistent result; - const CopyablePersistent start; + const v8::Global inverse; + const v8::Global result; + const v8::Global start; }; diff --git a/src/util/custom-function.lzz b/src/util/custom-function.lzz index 0f83e4c0..e9972663 100644 --- a/src/util/custom-function.lzz +++ b/src/util/custom-function.lzz @@ -54,6 +54,6 @@ private: Database* const db; protected: v8::Isolate* const isolate; - const CopyablePersistent fn; + const v8::Global fn; const bool safe_ints; }; diff --git a/src/util/custom-table.lzz b/src/util/custom-table.lzz index fc6fbbc6..89b7dff4 100644 --- a/src/util/custom-table.lzz +++ b/src/util/custom-table.lzz @@ -101,7 +101,7 @@ private: CustomTable * const parent; const int parameter_count; const bool safe_ints; - const CopyablePersistent generator; + const v8::Global generator; const std::vector parameter_names; }; @@ -120,9 +120,9 @@ private: } sqlite3_vtab_cursor base; - CopyablePersistent iterator; - CopyablePersistent next; - CopyablePersistent row; + v8::Global iterator; + v8::Global next; + v8::Global row; bool done; sqlite_int64 rowid; }; @@ -400,5 +400,5 @@ private: v8::Isolate* const isolate; Database* const db; const std::string name; - const CopyablePersistent factory; + const v8::Global factory; }; diff --git a/src/util/macros.lzz b/src/util/macros.lzz index 4763b3c3..432c2638 100644 --- a/src/util/macros.lzz +++ b/src/util/macros.lzz @@ -27,10 +27,7 @@ inline v8::Local InternalizedFromLatin1(v8::Isolate* isolate, const return v8::String::NewFromOneByte(isolate, reinterpret_cast(str), v8::NewStringType::kInternalized).ToLocalChecked(); } -#hdr -template using CopyablePersistent = v8::Global; -#end -inline void SetFrozen(v8::Isolate* isolate, v8::Local ctx, v8::Local obj, CopyablePersistent& key, v8::Local value) { +inline void SetFrozen(v8::Isolate* isolate, v8::Local ctx, v8::Local obj, v8::Global& key, v8::Local value) { obj->DefineOwnProperty(ctx, key.Get(isolate), value, static_cast(v8::DontDelete | v8::ReadOnly)).FromJust(); } @@ -149,7 +146,7 @@ void SetPrototypeGetter( v8::AccessorGetterCallback func ); #end -#src +#src void SetPrototypeGetter( v8::Isolate* isolate, v8::Local data, @@ -158,7 +155,7 @@ void SetPrototypeGetter( v8::AccessorGetterCallback func ) { v8::HandleScope scope(isolate); - + #if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 121 recv->InstanceTemplate()->SetAccessor( InternalizedFromLatin1(isolate, name),