本文整理汇总了C++中CInstance::getObject方法的典型用法代码示例。如果您正苦于以下问题:C++ CInstance::getObject方法的具体用法?C++ CInstance::getObject怎么用?C++ CInstance::getObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CInstance
的用法示例。
在下文中一共展示了CInstance::getObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant (KJS::ExecState *exec, const KJS::Value &value, NPVariant *result)
{
Type type = value.type();
if (type == StringType) {
UString ustring = value.toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8 *)cstring.c_str(), cstring.size() };
NPN_InitializeVariantWithStringCopy (result, &string );
}
else if (type == NumberType) {
NPN_InitializeVariantWithDouble (result, value.toNumber(exec));
}
else if (type == BooleanType) {
NPN_InitializeVariantWithBool (result, value.toBoolean(exec));
}
else if (type == UnspecifiedType) {
NPN_InitializeVariantAsUndefined(result);
}
else if (type == NullType) {
NPN_InitializeVariantAsNull(result);
}
else if (type == ObjectType) {
KJS::ObjectImp *objectImp = static_cast<KJS::ObjectImp*>(value.imp());
if (objectImp->classInfo() == &KJS::RuntimeObjectImp::info) {
KJS::RuntimeObjectImp *imp = static_cast<KJS::RuntimeObjectImp *>(value.imp());
CInstance *instance = static_cast<CInstance*>(imp->getInternalInstance());
NPN_InitializeVariantWithObject (result, instance->getObject());
}
else {
KJS::Interpreter *originInterpreter = exec->interpreter();
const Bindings::RootObject *originExecutionContext = rootForInterpreter(originInterpreter);
KJS::Interpreter *interpreter = 0;
if (originInterpreter->isGlobalObject(value)) {
interpreter = originInterpreter->interpreterForGlobalObject (value.imp());
}
if (!interpreter)
interpreter = originInterpreter;
const Bindings::RootObject *executionContext = rootForInterpreter(interpreter);
if (!executionContext) {
Bindings::RootObject *newExecutionContext = new KJS::Bindings::RootObject(0);
newExecutionContext->setInterpreter (interpreter);
executionContext = newExecutionContext;
}
NPObject *obj = (NPObject *)exec->interpreter()->createLanguageInstanceForValue (exec, Instance::CLanguage, value.toObject(exec), originExecutionContext, executionContext);
NPN_InitializeVariantWithObject (result, obj);
_NPN_ReleaseObject (obj);
}
}
else
NPN_InitializeVariantAsUndefined(result);
}
示例2: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant(ExecState *exec, JSValue *value, NPVariant *result)
{
JSLock lock;
JSType type = value->type();
VOID_TO_NPVARIANT(*result);
if (type == StringType) {
UString ustring = value->toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8 *)cstring.c_str(), static_cast<uint32_t>(cstring.size()) };
NPN_InitializeVariantWithStringCopy(result, &string);
} else if (type == NumberType) {
DOUBLE_TO_NPVARIANT(value->toNumber(exec), *result);
} else if (type == BooleanType) {
BOOLEAN_TO_NPVARIANT(value->toBoolean(exec), *result);
} else if (type == UnspecifiedType) {
VOID_TO_NPVARIANT(*result);
} else if (type == NullType) {
NULL_TO_NPVARIANT(*result);
} else if (type == ObjectType) {
JSObject* object = static_cast<JSObject*>(value);
if (object->classInfo() == &RuntimeObjectImp::info) {
RuntimeObjectImp* imp = static_cast<RuntimeObjectImp *>(value);
CInstance* instance = static_cast<CInstance*>(imp->getInternalInstance());
if (instance) {
NPObject* obj = instance->getObject();
_NPN_RetainObject(obj);
OBJECT_TO_NPVARIANT(obj, *result);
}
} else {
Interpreter* originInterpreter = exec->dynamicInterpreter();
RootObject* originRootObject = findRootObject(originInterpreter);
Interpreter* interpreter = 0;
if (originInterpreter->isGlobalObject(value)) {
interpreter = originInterpreter->interpreterForGlobalObject(value);
}
if (!interpreter)
interpreter = originInterpreter;
RootObject* rootObject = findRootObject(interpreter);
if (rootObject) {
NPObject* npObject = _NPN_CreateScriptObject(0, object, originRootObject, rootObject);
OBJECT_TO_NPVARIANT(npObject, *result);
}
}
}
}
示例3: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant(ExecState* exec, JSValue value, NPVariant* result)
{
JSLock lock(SilenceAssertionsOnly);
VOID_TO_NPVARIANT(*result);
if (value.isString()) {
UString ustring = value.toString(exec);
CString cstring = ustring.utf8();
NPString string = { (const NPUTF8*)cstring.data(), static_cast<uint32_t>(cstring.length()) };
NPN_InitializeVariantWithStringCopy(result, &string);
} else if (value.isNumber()) {
DOUBLE_TO_NPVARIANT(value.toNumber(exec), *result);
} else if (value.isBoolean()) {
BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), *result);
} else if (value.isNull()) {
NULL_TO_NPVARIANT(*result);
} else if (value.isObject()) {
JSObject* object = asObject(value);
if (object->classInfo() == &CRuntimeObject::s_info) {
CRuntimeObject* runtimeObject = static_cast<CRuntimeObject*>(object);
CInstance* instance = runtimeObject->getInternalCInstance();
if (instance) {
NPObject* obj = instance->getObject();
_NPN_RetainObject(obj);
OBJECT_TO_NPVARIANT(obj, *result);
}
} else {
#ifdef ANDROID
RootObject* rootObject = findRootObject(exec->dynamicGlobalObject());
if (!rootObject)
rootObject = findRootObject(exec->lexicalGlobalObject());
#else
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
RootObject* rootObject = findRootObject(globalObject);
#endif
if (rootObject) {
NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject);
OBJECT_TO_NPVARIANT(npObject, *result);
}
}
}
}
示例4: convertValueToNPVariant
// Variant value must be released with NPReleaseVariantValue()
void convertValueToNPVariant(ExecState* exec, JSValuePtr value, NPVariant* result)
{
JSLock lock(false);
VOID_TO_NPVARIANT(*result);
if (value.isString()) {
UString ustring = value.toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8*)cstring.c_str(), static_cast<uint32_t>(cstring.size()) };
NPN_InitializeVariantWithStringCopy(result, &string);
} else if (value.isNumber()) {
DOUBLE_TO_NPVARIANT(value.toNumber(exec), *result);
} else if (value.isBoolean()) {
BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), *result);
} else if (value.isNull()) {
NULL_TO_NPVARIANT(*result);
} else if (value.isObject()) {
JSObject* object = asObject(value);
if (object->classInfo() == &RuntimeObjectImp::s_info) {
RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(object);
CInstance* instance = static_cast<CInstance*>(imp->getInternalInstance());
if (instance) {
NPObject* obj = instance->getObject();
_NPN_RetainObject(obj);
OBJECT_TO_NPVARIANT(obj, *result);
}
} else {
JSGlobalObject* globalObject = exec->dynamicGlobalObject();
RootObject* rootObject = findRootObject(globalObject);
if (rootObject) {
NPObject* npObject = _NPN_CreateScriptObject(0, object, rootObject);
OBJECT_TO_NPVARIANT(npObject, *result);
}
}
}
}