toolkit/components/reflect/reflect.cpp

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "reflect.h"
michael@0 7 #include "jsapi.h"
michael@0 8 #include "mozilla/ModuleUtils.h"
michael@0 9 #include "nsMemory.h"
michael@0 10 #include "nsString.h"
michael@0 11 #include "nsNativeCharsetUtils.h"
michael@0 12
michael@0 13 #define JSREFLECT_CONTRACTID \
michael@0 14 "@mozilla.org/jsreflect;1"
michael@0 15
michael@0 16 #define JSREFLECT_CID \
michael@0 17 { 0x1a817186, 0x357a, 0x47cd, { 0x8a, 0xea, 0x28, 0x50, 0xd6, 0x0e, 0x95, 0x9e } }
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20 namespace reflect {
michael@0 21
michael@0 22 NS_GENERIC_FACTORY_CONSTRUCTOR(Module)
michael@0 23
michael@0 24 NS_IMPL_ISUPPORTS(Module, nsIXPCScriptable)
michael@0 25
michael@0 26 Module::Module()
michael@0 27 {
michael@0 28 }
michael@0 29
michael@0 30 Module::~Module()
michael@0 31 {
michael@0 32 }
michael@0 33
michael@0 34 #define XPC_MAP_CLASSNAME Module
michael@0 35 #define XPC_MAP_QUOTED_CLASSNAME "Module"
michael@0 36 #define XPC_MAP_WANT_CALL
michael@0 37 #define XPC_MAP_FLAGS nsIXPCScriptable::WANT_CALL
michael@0 38 #include "xpc_map_end.h"
michael@0 39
michael@0 40 NS_IMETHODIMP
michael@0 41 Module::Call(nsIXPConnectWrappedNative* wrapper,
michael@0 42 JSContext* cx,
michael@0 43 JSObject* obj,
michael@0 44 const JS::CallArgs& args,
michael@0 45 bool* _retval)
michael@0 46 {
michael@0 47 JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
michael@0 48 if (!global)
michael@0 49 return NS_ERROR_NOT_AVAILABLE;
michael@0 50
michael@0 51 *_retval = !!JS_InitReflect(cx, global);
michael@0 52 return NS_OK;
michael@0 53 }
michael@0 54
michael@0 55 }
michael@0 56 }
michael@0 57
michael@0 58 NS_DEFINE_NAMED_CID(JSREFLECT_CID);
michael@0 59
michael@0 60 static const mozilla::Module::CIDEntry kReflectCIDs[] = {
michael@0 61 { &kJSREFLECT_CID, false, nullptr, mozilla::reflect::ModuleConstructor },
michael@0 62 { nullptr }
michael@0 63 };
michael@0 64
michael@0 65 static const mozilla::Module::ContractIDEntry kReflectContracts[] = {
michael@0 66 { JSREFLECT_CONTRACTID, &kJSREFLECT_CID },
michael@0 67 { nullptr }
michael@0 68 };
michael@0 69
michael@0 70 static const mozilla::Module kReflectModule = {
michael@0 71 mozilla::Module::kVersion,
michael@0 72 kReflectCIDs,
michael@0 73 kReflectContracts
michael@0 74 };
michael@0 75
michael@0 76 NSMODULE_DEFN(jsreflect) = &kReflectModule;

mercurial