Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static Handle<Value> TracedGetProperty(Local<String> property, const AccessorInfo &info)
- {
- HandleScope scope;
- String::AsciiValue property_name(property);
- if(strcmp(*property_name, "createElement"))
- cerr << "prop: " << *property_name << endl;
- return Handle<Value>();
- }
- // called when a TracedObject is constructed
- static Handle<Value> TracedObjectCallback(const Arguments &args)
- {
- HandleScope scope;
- assert(args.Data()->IsFunction());
- static Persistent<ObjectTemplate> traced_obj;
- if(traced_obj.IsEmpty()) {
- traced_obj = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
- traced_obj->SetNamedPropertyHandler(TracedGetProperty);
- }
- Handle<Object> result = traced_obj->NewInstance();
- Handle<Function> constructor = Handle<Function>::Cast(args.Data());
- vector<Handle<Value> > argvals;
- for(int i=0; i < args.Length(); ++i) argvals.push_back(args[i]);
- constructor->Call(result, argvals.size(), &argvals[0]);
- return scope.Close(result);
- }
- static Handle<Value> TracedObject(const Arguments &args)
- {
- if(args.Length() != 1 || !args[0]->IsFunction()) return v8::Undefined();
- HandleScope scope;
- Handle<Function> constructor = Handle<Function>::Cast(args[0]);
- Handle<FunctionTemplate> func = FunctionTemplate::New(TracedObjectCallback, constructor);
- Handle<Function> result = func->GetFunction();
- //result->Set(String::New("prototype"), constructor->Get(String::New("prototype")));
- return scope.Close(result);
- }
Add Comment
Please, Sign In to add comment