1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
2 : /* ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is js-reflect.
16 : *
17 : * The Initial Developer of the Original Code is
18 : * The Mozilla Foundation <http://www.mozilla.org/>.
19 : * Portions created by the Initial Developer are Copyright (C) 2011
20 : * the Initial Developer. All Rights Reserved.
21 : *
22 : * Contributor(s):
23 : * Dave Herman <dherman@mozilla.com>
24 : *
25 : * Alternatively, the contents of this file may be used under the terms of
26 : * either the GNU General Public License Version 2 or later (the "GPL"), or
27 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 : * in which case the provisions of the GPL or the LGPL are applicable instead
29 : * of those above. If you wish to allow use of your version of this file only
30 : * under the terms of either the GPL or the LGPL, and not to allow others to
31 : * use your version of this file under the terms of the MPL, indicate your
32 : * decision by deleting the provisions above and replace them with the notice
33 : * and other provisions required by the GPL or the LGPL. If you do not delete
34 : * the provisions above, a recipient may use your version of this file under
35 : * the terms of any one of the MPL, the GPL or the LGPL.
36 : *
37 : * ***** END LICENSE BLOCK ***** */
38 :
39 : #include "reflect.h"
40 : #include "jsapi.h"
41 : #include "mozilla/ModuleUtils.h"
42 : #include "nsMemory.h"
43 : #include "nsString.h"
44 : #include "nsNativeCharsetUtils.h"
45 :
46 : #define JSREFLECT_CONTRACTID \
47 : "@mozilla.org/jsreflect;1"
48 :
49 : #define JSREFLECT_CID \
50 : { 0x1a817186, 0x357a, 0x47cd, { 0x8a, 0xea, 0x28, 0x50, 0xd6, 0x0e, 0x95, 0x9e } }
51 :
52 : namespace mozilla {
53 : namespace reflect {
54 :
55 0 : NS_GENERIC_FACTORY_CONSTRUCTOR(Module)
56 :
57 0 : NS_IMPL_ISUPPORTS1(Module, nsIXPCScriptable)
58 :
59 0 : Module::Module()
60 : {
61 0 : }
62 :
63 0 : Module::~Module()
64 : {
65 0 : }
66 :
67 : #define XPC_MAP_CLASSNAME Module
68 : #define XPC_MAP_QUOTED_CLASSNAME "Module"
69 : #define XPC_MAP_WANT_CALL
70 : #define XPC_MAP_FLAGS nsIXPCScriptable::WANT_CALL
71 : #include "xpc_map_end.h"
72 :
73 : NS_IMETHODIMP
74 0 : Module::Call(nsIXPConnectWrappedNative* wrapper,
75 : JSContext* cx,
76 : JSObject* obj,
77 : PRUint32 argc,
78 : jsval* argv,
79 : jsval* vp,
80 : bool* _retval)
81 : {
82 0 : JSObject* global = JS_GetGlobalForScopeChain(cx);
83 0 : if (!global)
84 0 : return NS_ERROR_NOT_AVAILABLE;
85 :
86 0 : *_retval = !!JS_InitReflect(cx, global);
87 0 : return NS_OK;
88 : }
89 :
90 : }
91 : }
92 :
93 : NS_DEFINE_NAMED_CID(JSREFLECT_CID);
94 :
95 : static const mozilla::Module::CIDEntry kReflectCIDs[] = {
96 : { &kJSREFLECT_CID, false, NULL, mozilla::reflect::ModuleConstructor },
97 : { NULL }
98 : };
99 :
100 : static const mozilla::Module::ContractIDEntry kReflectContracts[] = {
101 : { JSREFLECT_CONTRACTID, &kJSREFLECT_CID },
102 : { NULL }
103 : };
104 :
105 : static const mozilla::Module kReflectModule = {
106 : mozilla::Module::kVersion,
107 : kReflectCIDs,
108 : kReflectContracts
109 : };
110 :
111 : NSMODULE_DEFN(jsreflect) = &kReflectModule;
|