built-in implementation:
Handle<Value> native_example(const Arguments& a) {
return String::New("it works");
}
for the prototype (note that for some reason we need a prototype prototype)
Handle<Function> F = Handle<Function>::Cast(context->Global()->Get(String::New("Array")));
Handle<Object> P = Handle<Object>::Cast (F->GetPrototype());
P = Handle<Object>::Cast(P->GetPrototype());
P->Set(String::New("example"), FunctionTemplate::New(native_example)->GetFunction(), None);
Using javascript:
var A = [1,2,3]
log("A.example= " + A.example)
log("A.example()= " + JSON.stringify(A.example()))
source
share