From 7b14cc37e95560a1f1a22b9e1561b35c19b7163b Mon Sep 17 00:00:00 2001 From: Yonatan Striem-Amit Date: Mon, 30 Dec 2019 13:32:25 +0200 Subject: [PATCH] Extend class --- Makefile | 2 +- test/test_class.cpp | 2 ++ v8pp/class.hpp | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9940bdb4..8504e956 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ AR = ar ARFLAGS = rcs INCLUDES = -I. -I./v8pp -isystem./v8/include -isystem./v8 -isystem/usr -isystem/usr/lib -isystem/opt/libv8-${V8_VERSION}/include -LIBS = -L./v8/lib -L/opt/libv8-${V8_VERSION}/lib -Wl,-rpath,/opt/libv8-${V8_VERSION}/lib -lv8 -lv8_libplatform -lv8_libbase -licui18n -licuuc -L. -Wl,-whole-archive -lv8pp -Wl,-no-whole-archive -ldl -lpthread +LIBS += -L./v8/lib -L/opt/libv8-${V8_VERSION}/lib -Wl,-rpath,/opt/libv8-${V8_VERSION}/lib -lv8 -lv8_libplatform -lv8_libbase -licui18n -licuuc -L. -lv8pp -ldl -lpthread .cpp.o: $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ diff --git a/test/test_class.cpp b/test/test_class.cpp index fad90be5..1e31677d 100644 --- a/test/test_class.cpp +++ b/test/test_class.cpp @@ -174,6 +174,8 @@ void test_class_() }) ; + auto Y_class_find = v8pp::class_::extend_class(isolate); + check_ex("already wrapped class X", [isolate]() { v8pp::class_ X_class(isolate); diff --git a/v8pp/class.hpp b/v8pp/class.hpp index 6345f725..75a99357 100644 --- a/v8pp/class.hpp +++ b/v8pp/class.hpp @@ -191,6 +191,8 @@ class class_ { } + static class_ extend_class(v8::Isolate* isolate) { return class_(isolate, detail::type_id());} + /// Set class constructor signature template> class_& ctor(ctor_function create = &Create::call) @@ -439,6 +441,9 @@ class class_ } private: + explicit class_(v8::Isolate *isolate, detail::type_info const &ty) : + class_info_(detail::classes::find(isolate, ty)) { } + template static void member_get(v8::Local, v8::PropertyCallbackInfo const& info)