~unity-team/v8-cpp/trunk

« back to all changes in this revision

Viewing changes to src/module.h

  • Committer: Marcus Tomlinson
  • Date: 2015-06-10 06:20:49 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20150610062049-7zzi09xfldhch0l5
Added FindNode.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
public:
33
33
    explicit Module(v8::Isolate* isolate)
34
34
        : isolate_(isolate)
35
 
        , obj_(v8::ObjectTemplate::New(isolate))
 
35
        , object_(v8::ObjectTemplate::New(isolate))
36
36
    {
37
37
    }
38
38
 
40
40
    template <typename T>
41
41
    Module& add_class(char const* name, Class<T>& cl)
42
42
    {
43
 
        obj_->Set(to_v8(isolate_, name), cl.class_.proto_template()->GetFunction());
 
43
        object_->Set(to_v8(isolate_, name), cl.class_.proto_template()->GetFunction());
44
44
        return *this;
45
45
    }
46
46
 
48
48
    template <typename F>
49
49
    Module& add_function(char const* name, F func)
50
50
    {
51
 
        obj_->Set(to_v8(isolate_, name), internal::export_function(isolate_, func));
 
51
        object_->Set(to_v8(isolate_, name), internal::export_function(isolate_, func));
52
52
        return *this;
53
53
    }
54
54
 
55
55
    // Create an instance of this module in V8
56
56
    v8::Local<v8::Object> create_prototype()
57
57
    {
58
 
        return obj_->NewInstance();
 
58
        return object_->NewInstance();
59
59
    }
60
60
 
61
61
    // v8::Isolate where the module live
66
66
 
67
67
private:
68
68
    v8::Isolate* isolate_;
69
 
    v8::Handle<v8::ObjectTemplate> obj_;
 
69
    v8::Handle<v8::ObjectTemplate> object_;
70
70
};
71
71
 
72
72
}  // namespace v8cpp