if (false)
return null;
else if (method.equals(Object$equals))
+ // XXX: this assumes there is only one proxy
return proxy == args[0];
else if (method == Object$hashCode)
- return System.identityHashCode(proxy);
+ // XXX: this assumes there is only one wrapper
+ return hashCode();
else
return handle(protect_, method.getName(), args);
}
}
-public static Object proxy(Class proxy, long protect) {
- return Proxy.newProxyInstance(proxy.getClassLoader(), new Class[] {proxy}, new Wrapper(protect));
+public static Object proxy(Class proxy, Wrapper wrapper) {
+ return Proxy.newProxyInstance(proxy.getClassLoader(), new Class[] {proxy}, wrapper);
}
}
#undef CYJavaForEachPrimitive_
};
+template <typename Type_>
+struct IsJavaPrimitive { static const bool value = false; };
+
+#define CYJavaForEachPrimitive_(T, t, Typ, Type, type) \
+ template <> \
+ struct IsJavaPrimitive<j ## type> { static const bool value = true; };
+CYJavaForEachPrimitive
+#undef CYJavaForEachPrimitive_
+
// Java References {{{
template <typename Value_>
struct CYJavaRef {
return jni_;
}
+ // XXX: this is only needed to support CYJavaEnv relying on C variadics
_finline Value_ get() const {
return value_;
}
#define CYJavaEnv_(Code) \
template <typename... Args_> \
- auto Code(Args_ &&... args) const -> decltype(jni->Code(args...)) { \
+ auto Code(Args_ &&... args) const -> decltype(jni->Code(cy::Forward<Args_>(args)...)) { \
return _envcall(jni, Code(cy::Forward<Args_>(args)...)); \
}
jclass _class(table->value_);
if (table->interface_ && count == 1) {
- JSObjectRef target(CYCastJSObject(context, arguments[0]));
auto Cycript$(jni.FindClass("Cycript"));
- auto Cycript$Make(jni.GetStaticMethodID(Cycript$, "proxy", "(Ljava/lang/Class;J)Ljava/lang/Object;"));
- auto protect(new CYProtect(context, target));
- return CYCastJSObject(context, jni.CallObjectMethod<jobject>(Cycript$, Cycript$Make, _class, reinterpret_cast<jlong>(protect)));
+ auto Cycript$Make(jni.GetStaticMethodID(Cycript$, "proxy", "(Ljava/lang/Class;LCycript$Wrapper;)Ljava/lang/Object;"));
+ return CYCastJSObject(context, jni.CallObjectMethod<jobject>(Cycript$, Cycript$Make, _class, CYCastJavaObject(jni, context, CYCastJSObject(context, arguments[0])).get()));
}
CYJavaSignature bound(count);