Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend class #136

Merged
merged 1 commit into from
Aug 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
Expand Down
2 changes: 2 additions & 0 deletions test/test_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ void test_class_()
})
;

auto Y_class_find = v8pp::class_<Y, Traits>::extend_class(isolate);

check_ex<std::runtime_error>("already wrapped class X", [isolate]()
{
v8pp::class_<X, Traits> X_class(isolate);
Expand Down
5 changes: 5 additions & 0 deletions v8pp/class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class class_
{
}

static class_ extend_class(v8::Isolate* isolate) { return class_(isolate, detail::type_id<T>());}

/// Set class constructor signature
template<typename ...Args, typename Create = factory_create<Args...>>
class_& ctor(ctor_function create = &Create::call)
Expand Down Expand Up @@ -439,6 +441,9 @@ class class_
}

private:
explicit class_(v8::Isolate *isolate, detail::type_info const &ty) :
class_info_(detail::classes::find<Traits>(isolate, ty)) { }

template<typename Attribute>
static void member_get(v8::Local<v8::String>,
v8::PropertyCallbackInfo<v8::Value> const& info)
Expand Down