2011-06-28 21:57:16 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-06-28 21:57:16 +04:00
|
|
|
|
|
|
|
#include "reflect.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
#include "mozilla/ModuleUtils.h"
|
|
|
|
#include "nsMemory.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsNativeCharsetUtils.h"
|
2016-12-14 00:33:46 +03:00
|
|
|
#include "xpc_make_class.h"
|
2011-06-28 21:57:16 +04:00
|
|
|
|
|
|
|
#define JSREFLECT_CONTRACTID \
|
|
|
|
"@mozilla.org/jsreflect;1"
|
|
|
|
|
|
|
|
#define JSREFLECT_CID \
|
|
|
|
{ 0x1a817186, 0x357a, 0x47cd, { 0x8a, 0xea, 0x28, 0x50, 0xd6, 0x0e, 0x95, 0x9e } }
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace reflect {
|
|
|
|
|
|
|
|
NS_GENERIC_FACTORY_CONSTRUCTOR(Module)
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(Module, nsIXPCScriptable)
|
2011-06-28 21:57:16 +04:00
|
|
|
|
2016-11-16 20:26:14 +03:00
|
|
|
Module::Module() = default;
|
2011-06-28 21:57:16 +04:00
|
|
|
|
2016-11-16 20:26:14 +03:00
|
|
|
Module::~Module() = default;
|
2011-06-28 21:57:16 +04:00
|
|
|
|
|
|
|
#define XPC_MAP_CLASSNAME Module
|
|
|
|
#define XPC_MAP_QUOTED_CLASSNAME "Module"
|
2017-01-23 05:33:58 +03:00
|
|
|
#define XPC_MAP_FLAGS XPC_SCRIPTABLE_WANT_CALL
|
2011-06-28 21:57:16 +04:00
|
|
|
#include "xpc_map_end.h"
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
Module::Call(nsIXPConnectWrappedNative* wrapper,
|
|
|
|
JSContext* cx,
|
|
|
|
JSObject* obj,
|
2013-05-04 21:25:15 +04:00
|
|
|
const JS::CallArgs& args,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* _retval)
|
2011-06-28 21:57:16 +04:00
|
|
|
{
|
2014-01-22 05:03:20 +04:00
|
|
|
JS::Rooted<JSObject*> global(cx, JS::CurrentGlobalOrNull(cx));
|
2011-06-28 21:57:16 +04:00
|
|
|
if (!global)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2014-11-05 06:41:43 +03:00
|
|
|
*_retval = JS_InitReflectParse(cx, global);
|
2011-06-28 21:57:16 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace reflect
|
|
|
|
} // namespace mozilla
|
2011-06-28 21:57:16 +04:00
|
|
|
|
|
|
|
NS_DEFINE_NAMED_CID(JSREFLECT_CID);
|
|
|
|
|
|
|
|
static const mozilla::Module::CIDEntry kReflectCIDs[] = {
|
2013-10-11 00:38:05 +04:00
|
|
|
{ &kJSREFLECT_CID, false, nullptr, mozilla::reflect::ModuleConstructor },
|
|
|
|
{ nullptr }
|
2011-06-28 21:57:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const mozilla::Module::ContractIDEntry kReflectContracts[] = {
|
|
|
|
{ JSREFLECT_CONTRACTID, &kJSREFLECT_CID },
|
2013-10-11 00:38:05 +04:00
|
|
|
{ nullptr }
|
2011-06-28 21:57:16 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const mozilla::Module kReflectModule = {
|
|
|
|
mozilla::Module::kVersion,
|
|
|
|
kReflectCIDs,
|
|
|
|
kReflectContracts
|
|
|
|
};
|
|
|
|
|
|
|
|
NSMODULE_DEFN(jsreflect) = &kReflectModule;
|