Skip to content

Commit 366915f

Browse files
spahnkeoliverbock
authored andcommitted
Set the class name of a function template
This is used for printing objects created with the function created from the FunctionTemplate as its constructor; e.g in the debug inspector protocol. Otherwise a class Foo is printed as "Object". Note that this does not alter the behavior of toString.
1 parent 2f3437f commit 366915f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: Source/Noesis.Javascript/JavascriptContext.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ void JavascriptContext::SetConstructor(System::String^ name, System::Type^ assoc
292292
v8::Isolate *isolate = JavascriptContext::GetCurrentIsolate();
293293
HandleScope handleScope(isolate);
294294

295+
Local<String> className = ToV8String(isolate, name);
295296
Handle<FunctionTemplate> functionTemplate = JavascriptInterop::GetFunctionTemplateFromSystemDelegate(constructor);
297+
functionTemplate->SetClassName(className);
296298
JavascriptInterop::InitObjectWrapperTemplate(functionTemplate->InstanceTemplate());
297299
mTypeToConstructorMapping[associatedType] = System::IntPtr(new Persistent<FunctionTemplate>(isolate, functionTemplate));
298-
Local<Context>::New(isolate, *mContext)->Global()->Set(isolate->GetCurrentContext(), ToV8String(isolate, name), functionTemplate->GetFunction());
300+
Local<Context>::New(isolate, *mContext)->Global()->Set(isolate->GetCurrentContext(), className, functionTemplate->GetFunction());
299301
}
300302

301303
////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)