本文整理汇总了C++中Proxy::getJavaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Proxy::getJavaObject方法的具体用法?C++ Proxy::getJavaObject怎么用?C++ Proxy::getJavaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Proxy
的用法示例。
在下文中一共展示了Proxy::getJavaObject方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setIndexedProperty
void Proxy::setIndexedProperty(uint32_t index, Local<Value> value, const PropertyCallbackInfo<Value>& info)
{
Isolate* isolate = info.GetIsolate();
JNIEnv* env = JNIScope::getEnv();
if (!env) {
LOG_JNIENV_GET_ERROR(TAG);
// Returns undefined by default
return;
}
Proxy* proxy = NativeObject::Unwrap<Proxy>(info.Holder());
bool javaValueIsNew;
jobject javaValue = TypeConverter::jsValueToJavaObject(isolate, env, value, &javaValueIsNew);
jobject javaProxy = proxy->getJavaObject();
env->CallVoidMethod(javaProxy,
JNIUtil::krollProxySetIndexedPropertyMethod,
index,
javaValue);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
if (javaValueIsNew) {
env->DeleteLocalRef(javaValue);
}
info.GetReturnValue().Set(value);
}
示例2: hasListenersForEventType
void Proxy::hasListenersForEventType(const v8::FunctionCallbackInfo<v8::Value>& args)
{
Isolate* isolate = args.GetIsolate();
JNIEnv* env = JNIScope::getEnv();
if (!env) {
JSException::GetJNIEnvironmentError(isolate);
return;
}
Local<Object> holder = args.Holder();
// If holder isn't the JavaObject wrapper we expect, look up the prototype chain
if (!JavaObject::isJavaObject(holder)) {
holder = holder->FindInstanceInPrototypeChain(baseProxyTemplate.Get(isolate));
}
Proxy* proxy = NativeObject::Unwrap<Proxy>(holder);
Local<String> eventType = args[0]->ToString(isolate);
Local<Boolean> hasListeners = args[1]->ToBoolean(isolate);
jobject javaProxy = proxy->getJavaObject();
jobject krollObject = env->GetObjectField(javaProxy, JNIUtil::krollProxyKrollObjectField);
jstring javaEventType = TypeConverter::jsStringToJavaString(env, eventType);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
env->CallVoidMethod(krollObject,
JNIUtil::krollObjectSetHasListenersForEventTypeMethod,
javaEventType,
TypeConverter::jsBooleanToJavaBoolean(hasListeners));
env->DeleteLocalRef(krollObject);
env->DeleteLocalRef(javaEventType);
}
示例3: onPropertyChangedForProxy
static void onPropertyChangedForProxy(Isolate* isolate, Local<String> property, Local<Value> value, Local<Object> proxyObject)
{
Proxy* proxy = NativeObject::Unwrap<Proxy>(proxyObject);
JNIEnv* env = JNIScope::getEnv();
if (!env) {
LOG_JNIENV_GET_ERROR(TAG);
return;
}
jstring javaProperty = TypeConverter::jsStringToJavaString(env, property);
bool javaValueIsNew;
jobject javaValue = TypeConverter::jsValueToJavaObject(isolate, env, value, &javaValueIsNew);
jobject javaProxy = proxy->getJavaObject();
env->CallVoidMethod(javaProxy,
JNIUtil::krollProxyOnPropertyChangedMethod,
javaProperty,
javaValue);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
env->DeleteLocalRef(javaProperty);
if (javaValueIsNew) {
env->DeleteLocalRef(javaValue);
}
// Store new property value on JS internal map.
setPropertyOnProxy(isolate, property, value, proxyObject);
}
示例4: GetJNIEnvironmentError
Handle<Value> Proxy::hasListenersForEventType(const Arguments& args)
{
JNIEnv* env = JNIScope::getEnv();
if (!env) {
return JSException::GetJNIEnvironmentError();
}
Proxy* proxy = NativeObject::Unwrap<Proxy>(args.Holder());
Local<String> eventType = args[0]->ToString();
Local<Boolean> hasListeners = args[1]->ToBoolean();
jobject javaProxy = proxy->getJavaObject();
jobject krollObject = env->GetObjectField(javaProxy, JNIUtil::krollProxyKrollObjectField);
jstring javaEventType = TypeConverter::jsStringToJavaString(eventType);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
env->CallVoidMethod(krollObject,
JNIUtil::krollObjectSetHasListenersForEventTypeMethod,
javaEventType,
TypeConverter::jsBooleanToJavaBoolean(hasListeners));
env->DeleteLocalRef(krollObject);
env->DeleteLocalRef(javaEventType);
return Undefined();
}
示例5: Undefined
Handle<Value> Proxy::setIndexedProperty(uint32_t index, Local<Value> value, const AccessorInfo& info)
{
JNIEnv* env = JNIScope::getEnv();
if (!env) {
LOG_JNIENV_GET_ERROR(TAG);
return Undefined();
}
Proxy* proxy = NativeObject::Unwrap<Proxy>(info.Holder());
bool javaValueIsNew;
jobject javaValue = TypeConverter::jsValueToJavaObject(value, &javaValueIsNew);
jobject javaProxy = proxy->getJavaObject();
env->CallVoidMethod(javaProxy,
JNIUtil::krollProxySetIndexedPropertyMethod,
index,
javaValue);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
if (javaValueIsNew) {
env->DeleteLocalRef(javaValue);
}
return value;
}
示例6: getIndexedProperty
void Proxy::getIndexedProperty(uint32_t index, const PropertyCallbackInfo<Value>& info)
{
Isolate* isolate = info.GetIsolate();
JNIEnv* env = JNIScope::getEnv();
if (!env) {
JSException::GetJNIEnvironmentError(isolate);
return;
}
Proxy* proxy = NativeObject::Unwrap<Proxy>(info.Holder());
jobject javaProxy = proxy->getJavaObject();
jobject value = env->CallObjectMethod(javaProxy,
JNIUtil::krollProxyGetIndexedPropertyMethod,
index);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
Local<Value> result = TypeConverter::javaObjectToJsValue(isolate, env, value);
env->DeleteLocalRef(value);
info.GetReturnValue().Set(result);
}
示例7: proxyOnPropertiesChanged
void Proxy::proxyOnPropertiesChanged(const v8::FunctionCallbackInfo<v8::Value>& args)
{
Isolate* isolate = args.GetIsolate();
HandleScope scope(isolate);
Local<Object> jsProxy = args.Holder();
if (args.Length() < 1 || !(args[0]->IsArray())) {
JSException::Error(isolate, "Proxy.propertiesChanged requires a list of lists of property name, the old value, and the new value");
return;
}
JNIEnv *env = JNIScope::getEnv();
if (!env) {
JSException::GetJNIEnvironmentError(isolate);
return;
}
Proxy *proxy = unwrap(jsProxy);
if (!proxy) {
JSException::Error(isolate, "Failed to unwrap Proxy instance");
return;
}
Local<Array> changes = args[0].As<Array>();
uint32_t length = changes->Length();
jobjectArray jChanges = env->NewObjectArray(length, JNIUtil::objectClass, NULL);
for (uint32_t i = 0; i < length; ++i) {
Local<Array> change = changes->Get(i).As<Array>();
Local<String> name = change->Get(INDEX_NAME)->ToString(isolate);
Local<Value> oldValue = change->Get(INDEX_OLD_VALUE);
Local<Value> value = change->Get(INDEX_VALUE);
jobjectArray jChange = env->NewObjectArray(3, JNIUtil::objectClass, NULL);
jstring jName = TypeConverter::jsStringToJavaString(env, name);
env->SetObjectArrayElement(jChange, INDEX_NAME, jName);
env->DeleteLocalRef(jName);
bool isNew;
jobject jOldValue = TypeConverter::jsValueToJavaObject(isolate, env, oldValue, &isNew);
env->SetObjectArrayElement(jChange, INDEX_OLD_VALUE, jOldValue);
if (isNew) {
env->DeleteLocalRef(jOldValue);
}
jobject jValue = TypeConverter::jsValueToJavaObject(isolate, env, value, &isNew);
env->SetObjectArrayElement(jChange, INDEX_VALUE, jValue);
if (isNew) {
env->DeleteLocalRef(jValue);
}
env->SetObjectArrayElement(jChanges, i, jChange);
env->DeleteLocalRef(jChange);
}
jobject javaProxy = proxy->getJavaObject();
env->CallVoidMethod(javaProxy, JNIUtil::krollProxyOnPropertiesChangedMethod, jChanges);
env->DeleteLocalRef(jChanges);
if (!JavaObject::useGlobalRefs) {
env->DeleteLocalRef(javaProxy);
}
return;
}