Skip to content

Commit 180cd29

Browse files
BUGFIX: Functions did not have a 'prototype' object, used to construct objects.
1 parent b1cc91b commit 180cd29

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

JsVars.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,18 @@ Ref<JSFunction> JSFunction::createNative(const std::string& name, JSNativeFn fnP
639639
return refFromNew(new JSFunction(name, fnPtr));
640640
}
641641

642+
643+
JSFunction::JSFunction(const std::string& name, JSNativeFn pNative) :
644+
JSObject(DefaultPrototype),
645+
m_name(name),
646+
m_code(""),
647+
m_pNative(pNative)
648+
{
649+
//Prototype object, used when the function acts as a constructor.
650+
set("prototype", JSObject::create());
651+
}
652+
653+
642654
JSFunction::~JSFunction()
643655
{
644656
// printf ("Destroying function: %s\n", m_name.c_str());

0 commit comments

Comments
 (0)