diff options
Diffstat (limited to 'src/mongo/scripting/mozjs/nativefunction.cpp')
-rw-r--r-- | src/mongo/scripting/mozjs/nativefunction.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mongo/scripting/mozjs/nativefunction.cpp b/src/mongo/scripting/mozjs/nativefunction.cpp index 010b6a13587..5ffdc5f902d 100644 --- a/src/mongo/scripting/mozjs/nativefunction.cpp +++ b/src/mongo/scripting/mozjs/nativefunction.cpp @@ -67,15 +67,15 @@ NativeHolder* getHolder(JS::CallArgs args) { } // namespace -void NativeFunctionInfo::construct(JSContext* cx, JS::CallArgs args) { - auto scope = getScope(cx); - - scope->getNativeFunctionProto().newObject(args.rval()); -} - void NativeFunctionInfo::call(JSContext* cx, JS::CallArgs args) { auto holder = getHolder(args); + if (! holder) { + // Calling the prototype + args.rval().setUndefined(); + return; + } + BSONObjBuilder bob; for (unsigned i = 0; i < args.length(); i++) { @@ -115,7 +115,7 @@ void NativeFunctionInfo::make(JSContext* cx, void* data) { auto scope = getScope(cx); - scope->getNativeFunctionProto().newInstance(obj); + scope->getNativeFunctionProto().newObject(obj); JS_SetPrivate(obj, new NativeHolder(function, data)); } |