diff options
Diffstat (limited to 'src/mongo/scripting/mozjs/objectwrapper.cpp')
-rw-r--r-- | src/mongo/scripting/mozjs/objectwrapper.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/mongo/scripting/mozjs/objectwrapper.cpp b/src/mongo/scripting/mozjs/objectwrapper.cpp index 5ca5cdeca97..2dc17726b37 100644 --- a/src/mongo/scripting/mozjs/objectwrapper.cpp +++ b/src/mongo/scripting/mozjs/objectwrapper.cpp @@ -343,7 +343,7 @@ void ObjectWrapper::writeThis(BSONObjBuilder* b) { auto scope = getScope(_context); BSONObj* originalBSON = nullptr; - if (scope->getBsonProto().instanceOf(_object)) { + if (scope->getProto<BSONInfo>().instanceOf(_object)) { bool altered; std::tie(originalBSON, altered) = BSONInfo::originalBSON(_context, _object); @@ -389,5 +389,17 @@ void ObjectWrapper::_writeField(BSONObjBuilder* b, Key key, BSONObj* originalPar x.writeThis(b, key.toString(_context)); } +std::string ObjectWrapper::getClassName() { + auto jsclass = JS_GetClass(_object); + + if (jsclass) + return jsclass->name; + + JS::RootedValue ctor(_context); + getValue("constructor", &ctor); + + return ObjectWrapper(_context, ctor).getString("name"); +} + } // namespace mozjs } // namespace mongo |