Skip to content

Commit

Permalink
Add module::set_const() for another module as a read-only property
Browse files Browse the repository at this point in the history
According to nodejs/node#6216 only primitive values
and V8 templates are allowed to set in a v8::ObjectTemplate.
  • Loading branch information
pmed committed Oct 5, 2016
1 parent f9f29a2 commit fbc1776
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions v8pp/module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ class module
return *this;
}

/// Set another module as a read-only property
module& set_const(char const* name, module& m)
{
v8::HandleScope scope(isolate_);

obj_->Set(v8pp::to_v8(isolate_, name), m.obj_,
v8::PropertyAttribute(v8::ReadOnly | v8::DontDelete));
return *this;
}

/// Set a value convertible to JavaScript as a read-only property
template<typename Value>
module& set_const(char const* name, Value value)
Expand Down

0 comments on commit fbc1776

Please sign in to comment.