michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "reflect.h" michael@0: #include "jsapi.h" michael@0: #include "mozilla/ModuleUtils.h" michael@0: #include "nsMemory.h" michael@0: #include "nsString.h" michael@0: #include "nsNativeCharsetUtils.h" michael@0: michael@0: #define JSREFLECT_CONTRACTID \ michael@0: "@mozilla.org/jsreflect;1" michael@0: michael@0: #define JSREFLECT_CID \ michael@0: { 0x1a817186, 0x357a, 0x47cd, { 0x8a, 0xea, 0x28, 0x50, 0xd6, 0x0e, 0x95, 0x9e } } michael@0: michael@0: namespace mozilla { michael@0: namespace reflect { michael@0: michael@0: NS_GENERIC_FACTORY_CONSTRUCTOR(Module) michael@0: michael@0: NS_IMPL_ISUPPORTS(Module, nsIXPCScriptable) michael@0: michael@0: Module::Module() michael@0: { michael@0: } michael@0: michael@0: Module::~Module() michael@0: { michael@0: } michael@0: michael@0: #define XPC_MAP_CLASSNAME Module michael@0: #define XPC_MAP_QUOTED_CLASSNAME "Module" michael@0: #define XPC_MAP_WANT_CALL michael@0: #define XPC_MAP_FLAGS nsIXPCScriptable::WANT_CALL michael@0: #include "xpc_map_end.h" michael@0: michael@0: NS_IMETHODIMP michael@0: Module::Call(nsIXPConnectWrappedNative* wrapper, michael@0: JSContext* cx, michael@0: JSObject* obj, michael@0: const JS::CallArgs& args, michael@0: bool* _retval) michael@0: { michael@0: JS::Rooted global(cx, JS::CurrentGlobalOrNull(cx)); michael@0: if (!global) michael@0: return NS_ERROR_NOT_AVAILABLE; michael@0: michael@0: *_retval = !!JS_InitReflect(cx, global); michael@0: return NS_OK; michael@0: } michael@0: michael@0: } michael@0: } michael@0: michael@0: NS_DEFINE_NAMED_CID(JSREFLECT_CID); michael@0: michael@0: static const mozilla::Module::CIDEntry kReflectCIDs[] = { michael@0: { &kJSREFLECT_CID, false, nullptr, mozilla::reflect::ModuleConstructor }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static const mozilla::Module::ContractIDEntry kReflectContracts[] = { michael@0: { JSREFLECT_CONTRACTID, &kJSREFLECT_CID }, michael@0: { nullptr } michael@0: }; michael@0: michael@0: static const mozilla::Module kReflectModule = { michael@0: mozilla::Module::kVersion, michael@0: kReflectCIDs, michael@0: kReflectContracts michael@0: }; michael@0: michael@0: NSMODULE_DEFN(jsreflect) = &kReflectModule;