#include <dlfcn.h>
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(__arm__)
#include <JavaVM/jni.h>
#else
#include <jni.h>
return value; \
}
-static JNIEnv *GetJNI(JSContextRef context);
-
#define CYJavaForEachPrimitive \
CYJavaForEachPrimitive_(Z, z, Boolean, Boolean, boolean) \
CYJavaForEachPrimitive_(B, b, Byte, Byte, byte) \
return jni.CallObjectMethod<jstring>(value, Object$toString);
}
-template <typename Internal_, typename Value_>
-struct CYJavaValue :
- CYPrivate<Internal_>
-{
- CYJavaGlobal<Value_> value_;
-
- CYJavaValue(const CYJavaRef<Value_> &value) :
- value_(value)
- {
- }
-
- CYJavaValue(const CYJavaValue &) = delete;
-};
-
static JSValueRef CYCastJSValue(JSContextRef context, const CYJavaRef<jobject> &value);
template <typename Other_>
typedef std::multiset<CYJavaSignature> CYJavaOverload;
struct CYJavaMethod :
- CYPrivate<CYJavaMethod>
+ CYRoot
{
CYJavaOverload overload_;
};
struct CYJavaStaticMethod :
- CYPrivate<CYJavaStaticMethod>
+ CYRoot
{
CYJavaOverload overload_;
};
struct CYJavaClass :
- CYJavaValue<CYJavaClass, jclass>
+ CYRoot
{
+ CYJavaGlobal<jclass> value_;
bool interface_;
CYJavaFieldMap static_;
CYJavaOverload overload_;
CYJavaClass(const CYJavaRef<jclass> &value, bool interface) :
- CYJavaValue(value),
+ value_(value),
interface_(interface)
{
}
static JSObjectRef CYGetJavaClass(JSContextRef context, const CYJavaRef<jclass> &_class);
struct CYJavaObject :
- CYJavaValue<CYJavaObject, jobject>
+ CYRoot
{
+ CYJavaGlobal<jobject> value_;
CYJavaClass *table_;
CYJavaObject(const CYJavaRef<jobject> &value, CYJavaClass *table) :
- CYJavaValue(value),
+ value_(value),
table_(table)
{
}
};
struct CYJavaInterior :
- CYJavaValue<CYJavaInterior, jobject>
+ CYRoot
{
+ CYJavaGlobal<jobject> value_;
CYJavaClass *table_;
CYJavaInterior(const CYJavaRef<jobject> &value, CYJavaClass *table) :
- CYJavaValue(value),
+ value_(value),
table_(table)
{
}
};
struct CYJavaStaticInterior :
- CYJavaValue<CYJavaStaticInterior, jclass>
+ CYRoot
{
+ CYJavaGlobal<jclass> value_;
CYJavaClass *table_;
CYJavaStaticInterior(const CYJavaRef<jclass> &value, CYJavaClass *table) :
- CYJavaValue(value),
+ value_(value),
table_(table)
{
}
};
struct CYJavaArray :
- CYJavaValue<CYJavaArray, jarray>
+ CYRoot
{
+ CYJavaGlobal<jarray> value_;
CYJavaPrimitive primitive_;
CYJavaArray(const CYJavaRef<jarray> &value, CYJavaPrimitive primitive) :
- CYJavaValue(value),
+ value_(value),
primitive_(primitive)
{
}
};
struct CYJavaPackage :
- CYPrivate<CYJavaPackage>
+ CYRoot
{
+ JNIEnv *jni_;
+
typedef std::vector<std::string> Path;
Path package_;
- _finline CYJavaPackage(const Path &package) :
+ _finline CYJavaPackage(JNIEnv *jni, const Path &package) :
+ jni_(jni),
package_(package)
{
}
auto Class$getComponentType(jni.GetMethodID(Class$, "getComponentType", "()Ljava/lang/Class;"));
auto component(jni.CallObjectMethod<jclass>(_class, Class$getComponentType));
auto Class$getName(jni.GetMethodID(Class$, "getName", "()Ljava/lang/String;"));
- return CYJavaArray::Make(context, value.cast<jarray>(), CYJavaGetPrimitive(context, component, Class$getName));
+ return CYPrivate<CYJavaArray>::Make(context, value.cast<jarray>(), CYJavaGetPrimitive(context, component, Class$getName));
}
auto Wrapper$(jni.FindClass("Cycript$Wrapper"));
}
CYJavaClass *table(reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(CYGetJavaClass(context, _class))));
- return CYJavaObject::Make(context, value, table);
+ return CYPrivate<CYJavaObject>::Make(context, value, table);
}
static _finline JSObjectRef CYCastJSObject(JSContextRef context, const CYJavaRef<jobject> &value) {
CYCastJava$(D, Double, jdouble, CYCastDouble)
static CYJavaClass *CYGetJavaTable(JSContextRef context, JSObjectRef object) {
- if (!JSValueIsObjectOfClass(context, object, CYJavaClass::Class_))
+ if (!JSValueIsObjectOfClass(context, object, CYPrivate<CYJavaClass>::Class_))
return NULL;
return reinterpret_cast<CYJavaClass *>(JSObjectGetPrivate(object));
}
static CYJavaObject *CYGetJavaObject(JSContextRef context, JSObjectRef object) {
- if (!JSValueIsObjectOfClass(context, object, CYJavaObject::Class_))
+ if (!JSValueIsObjectOfClass(context, object, CYPrivate<CYJavaObject>::Class_))
return NULL;
return reinterpret_cast<CYJavaObject *>(JSObjectGetPrivate(object));
}
}
}
- constructor = JSObjectMake(context, CYJavaClass::Class_, table);
+ constructor = JSObjectMake(context, CYPrivate<CYJavaClass>::Class_, table);
prototype = JSObjectMake(context, NULL, NULL);
CYSetProperty(context, constructor, prototype_s, prototype, kJSPropertyAttributeDontEnum);
CYJSString name(entry.first.second);
auto &overload(entry.second);
if (instance)
- CYSetProperty(context, prototype, name, CYJavaMethod::Make(context, overload), kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete);
+ CYSetProperty(context, prototype, name, CYPrivate<CYJavaMethod>::Make(context, overload), kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete);
else
- CYSetProperty(context, constructor, name, CYJavaStaticMethod::Make(context, overload), kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete);
+ CYSetProperty(context, constructor, name, CYPrivate<CYJavaStaticMethod>::Make(context, overload), kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete);
}
}
}
static JSValueRef JavaMethod_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- auto internal(CYJavaMethod::Get(context, object));
+ auto internal(CYPrivate<CYJavaMethod>::Get(context, object));
CYJavaObject *self(CYGetJavaObject(context, _this));
+ _assert(self != NULL);
CYJavaEnv jni(self->value_);
CYJavaSignature bound(count);
} CYCatch(NULL) }
static JSValueRef JavaStaticMethod_callAsFunction(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- auto internal(CYJavaStaticMethod::Get(context, object));
+ auto internal(CYPrivate<CYJavaStaticMethod>::Get(context, object));
CYJavaClass *table(CYGetJavaTable(context, _this));
CYJavaEnv jni(table->value_);
} CYCatch(NULL) }
static JSObjectRef JavaClass_callAsConstructor(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- auto table(CYJavaClass::Get(context, object));
+ auto table(CYPrivate<CYJavaClass>::Get(context, object));
CYJavaEnv jni(table->value_);
jclass _class(table->value_);
}
CYThrow("invalid constructor call");
-} CYCatch(NULL) }
+} CYCatchObject() }
static bool JavaStaticInterior_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) {
- auto internal(CYJavaStaticInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaStaticInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
CYPool pool;
auto name(CYPoolUTF8String(pool, context, property));
}
static JSValueRef JavaStaticInterior_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaStaticInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaStaticInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
CYJavaEnv jni(table->value_);
CYPool pool;
} CYCatch(NULL) }
static bool JavaStaticInterior_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- auto internal(CYJavaStaticInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaStaticInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
CYJavaEnv jni(table->value_);
CYPool pool;
} CYCatch(false) }
static void JavaStaticInterior_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
- auto internal(CYJavaStaticInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaStaticInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
for (const auto &field : table->static_)
JSPropertyNameAccumulatorAddName(names, CYJSString(field.first));
}
static JSValueRef JavaClass_getProperty_class(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto table(CYJavaClass::Get(context, object));
+ auto table(CYPrivate<CYJavaClass>::Get(context, object));
return CYCastJSValue(context, table->value_);
} CYCatch(NULL) }
static bool JavaInterior_hasProperty(JSContextRef context, JSObjectRef object, JSStringRef property) {
- auto internal(CYJavaInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
CYPool pool;
auto name(CYPoolUTF8String(pool, context, property));
}
static JSValueRef JavaInterior_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaInterior>::Get(context, object));
CYJavaEnv jni(internal->value_);
CYJavaClass *table(internal->table_);
CYPool pool;
} CYCatch(NULL) }
static bool JavaInterior_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- auto internal(CYJavaInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaInterior>::Get(context, object));
CYJavaEnv jni(internal->value_);
CYJavaClass *table(internal->table_);
CYPool pool;
} CYCatch(false) }
static void JavaInterior_getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef names) {
- auto internal(CYJavaInterior::Get(context, object));
+ auto internal(CYPrivate<CYJavaInterior>::Get(context, object));
CYJavaClass *table(internal->table_);
for (const auto &field : table->instance_)
JSPropertyNameAccumulatorAddName(names, CYJSString(field.first));
}
static JSValueRef JavaObject_getProperty_constructor(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaObject::Get(context, object));
+ auto internal(CYPrivate<CYJavaObject>::Get(context, object));
CYJavaEnv jni(internal->value_);
return CYGetJavaClass(context, jni.GetObjectClass(internal->value_));
} CYCatch(NULL) }
static JSValueRef JavaClass_getProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaClass::Get(context, object));
- return CYJavaStaticInterior::Make(context, internal->value_, internal);
+ auto internal(CYPrivate<CYJavaClass>::Get(context, object));
+ return CYPrivate<CYJavaStaticInterior>::Make(context, internal->value_, internal);
} CYCatch(NULL) }
static JSValueRef JavaObject_getProperty_$cyi(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaObject::Get(context, object));
- return CYJavaInterior::Make(context, internal->value_, internal->table_);
+ auto internal(CYPrivate<CYJavaObject>::Get(context, object));
+ return CYPrivate<CYJavaInterior>::Make(context, internal->value_, internal->table_);
} CYCatch(NULL) }
static JSValueRef JavaClass_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- auto internal(CYJavaClass::Get(context, _this));
+ auto internal(CYPrivate<CYJavaClass>::Get(context, _this));
CYJavaEnv jni(internal->value_);
auto Class$(jni.FindClass("java/lang/Class"));
auto Class$getCanonicalName(jni.GetMethodID(Class$, "getCanonicalName", "()Ljava/lang/String;"));
} CYCatch(NULL) }
static JSValueRef JavaArray_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaArray::Get(context, object));
+ auto internal(CYPrivate<CYJavaArray>::Get(context, object));
CYJavaEnv jni(internal->value_);
if (JSStringIsEqual(property, length_s))
return CYCastJSValue(context, jni.GetArrayLength(internal->value_));
} CYCatch(NULL) }
static bool JavaArray_setProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef value, JSValueRef *exception) { CYTry {
- auto internal(CYJavaArray::Get(context, object));
+ auto internal(CYPrivate<CYJavaArray>::Get(context, object));
CYJavaEnv jni(internal->value_);
CYPool pool;
return true;
} CYCatch(false) }
+static JNIEnv *GetJNI(JSContextRef context, JNIEnv *&env);
+
static JSValueRef JavaPackage_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
- auto internal(CYJavaPackage::Get(context, _this));
+ auto internal(CYPrivate<CYJavaPackage>::Get(context, _this));
std::ostringstream name;
for (auto &package : internal->package_)
name << package << '.';
}
static JSValueRef CYJavaPackage_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
- auto internal(CYJavaPackage::Get(context, object));
+ auto internal(CYPrivate<CYJavaPackage>::Get(context, object));
CYJavaPackage::Path package(internal->package_);
CYPool pool;
name << package << '/';
name << next;
- JNIEnv *jni(GetJNI(context));
+ if (internal->jni_ == NULL)
+ GetJNI(context, internal->jni_);
+ JNIEnv *jni(internal->jni_);
+
if (auto _class = jni->FindClass(name.str().c_str()))
return CYGetJavaClass(context, CYJavaLocal<jclass>(jni, _class));
jni->ExceptionClear();
package.push_back(next);
- return CYJavaPackage::Make(context, package);
+ return CYPrivate<CYJavaPackage>::Make(context, jni, package);
} CYCatch(NULL) }
static void Cycript_delete(JNIEnv *env, jclass api, jlong jprotect) { CYJavaTry {
jint CYJavaVersion(JNI_VERSION_1_4);
-static JNIEnv *CYGetCreatedJava(jint (*$JNI_GetCreatedJavaVMs)(JavaVM **, jsize, jsize *)) {
+static JavaVM *CYGetJavaVM(jint (*$JNI_GetCreatedJavaVMs)(JavaVM **, jsize, jsize *)) {
jsize capacity(16);
JavaVM *jvms[capacity];
jsize size;
_jnicall($JNI_GetCreatedJavaVMs(jvms, capacity, &size));
if (size == 0)
return NULL;
- JavaVM *jvm(jvms[0]);
- JNIEnv *jni;
- _jnicall(jvm->GetEnv(reinterpret_cast<void **>(&jni), CYJavaVersion));
- return jni;
+ return jvms[0];
}
-static JNIEnv *GetJNI_(JSContextRef context) {
- static JavaVM *jvm(NULL);
- static JNIEnv *jni(NULL);
-
- if (jni != NULL)
- return jni;
-
+static JavaVM *CYGetJavaVM(JSContextRef context) {
CYPool pool;
void *handle(RTLD_DEFAULT);
std::string library;
dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", handle);
if ($JNI_GetCreatedJavaVMs != NULL) {
- if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs))
- return jni;
+ if (JavaVM *jvm = CYGetJavaVM($JNI_GetCreatedJavaVMs))
+ return jvm;
} else {
std::vector<const char *> guesses;
guesses.push_back(android);
#endif
+ guesses.push_back("/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/jli/libjli.dylib");
+ //guesses.push_back("/System/Library/Frameworks/JavaVM.framework/JavaVM");
+ guesses.push_back("libjvm.dylib");
+
guesses.push_back("libart.so");
guesses.push_back("libdvm.so");
guesses.push_back("libjvm.so");
}
}
- _assert(library.size() != 0);
+ if (library.size() == 0)
+ return NULL;
dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", handle);
- if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs))
- return jni;
+ if (JavaVM *jvm = CYGetJavaVM($JNI_GetCreatedJavaVMs))
+ return jvm;
}
std::vector<JavaVMOption> options;
JniInvocation$Init(invocation, NULL);
dlset($JNI_GetCreatedJavaVMs, "JNI_GetCreatedJavaVMs", libnativehelper);
- if (JNIEnv *jni = CYGetCreatedJava($JNI_GetCreatedJavaVMs))
- return jni;
+ if (JavaVM *jvm = CYGetJavaVM($JNI_GetCreatedJavaVMs))
+ return jvm;
}
}
+ JavaVM *jvm;
+ JNIEnv *env;
+
if (void *libandroid_runtime = dlopen("libandroid_runtime.so", RTLD_LAZY | RTLD_GLOBAL)) {
class AndroidRuntime$;
AndroidRuntime$ *(*AndroidRuntime$$init$)(AndroidRuntime$ *self, char *args, unsigned int size)(NULL);
- int (*AndroidRuntime$startVm)(AndroidRuntime$ *self, JavaVM **jvm, JNIEnv **jni)(NULL);
- int (*AndroidRuntime$startReg)(JNIEnv *jni)(NULL);
+ int (*AndroidRuntime$startVm)(AndroidRuntime$ *self, JavaVM **jvm, JNIEnv **env)(NULL);
+ int (*AndroidRuntime$startReg)(JNIEnv *env)(NULL);
int (*AndroidRuntime$addOption)(AndroidRuntime$ *self, const char *option, void *extra)(NULL);
int (*AndroidRuntime$addVmArguments)(AndroidRuntime$ *self, int, const char *const argv[])(NULL);
AndroidRuntime$ *(*AndroidRuntime$finalize)(AndroidRuntime$ *self)(NULL);
int failure;
_assert(AndroidRuntime$startVm != NULL);
- failure = AndroidRuntime$startVm(runtime, &jvm, &jni);
+ failure = AndroidRuntime$startVm(runtime, &jvm, &env);
_assert(failure == 0);
_assert(AndroidRuntime$startReg != NULL);
- failure = AndroidRuntime$startReg(jni);
+ failure = AndroidRuntime$startReg(env);
_assert(failure == 0);
- return jni;
+ return jvm;
}
jint (*$JNI_CreateJavaVM)(JavaVM **jvm, void **, void *);
args.version = CYJavaVersion;
args.nOptions = options.size();
args.options = options.data();
- _jnicall($JNI_CreateJavaVM(&jvm, reinterpret_cast<void **>(&jni), &args));
- return jni;
+ _jnicall($JNI_CreateJavaVM(&jvm, reinterpret_cast<void **>(&env), &args));
+ return jvm;
}
-static JNIEnv *GetJNI(JSContextRef context) {
- CYJavaEnv jni(GetJNI_(context));
+static JNIEnv *GetJNI(JSContextRef context, JNIEnv *&env) {
+ auto jvm(CYGetJavaVM(context));
+ _assert(jvm != NULL);
+ _jnicall(jvm->GetEnv(reinterpret_cast<void **>(&env), CYJavaVersion));
+ CYJavaEnv jni(env);
+
+ // XXX: this happens once per stub :/
+
auto Cycript$(jni.FindClass("Cycript"));
jni.RegisterNatives(Cycript$, Cycript_, sizeof(Cycript_) / sizeof(Cycript_[0]));
- return jni;
+
+ JSObjectRef java(CYGetCachedObject(context, CYJSString("Java")));
+ JSValueRef arguments[1];
+ arguments[0] = CYCastJSValue(context, CYJSString("setup"));
+ CYCallAsFunction(context, CYCastJSObject(context, CYGetProperty(context, java, CYJSString("emit"))), java, 1, arguments);
+
+ return env;
}
static JSStaticValue JavaClass_staticValues[3] = {
definition.staticFunctions = JavaClass_staticFunctions;
definition.callAsConstructor = &JavaClass_callAsConstructor;
definition.finalize = &CYFinalize;
- CYJavaClass::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaClass>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.attributes = kJSClassAttributeNoAutomaticPrototype;
definition.setProperty = &JavaInterior_setProperty;
definition.getPropertyNames = &JavaInterior_getPropertyNames;
definition.finalize = &CYFinalize;
- CYJavaInterior::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaInterior>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "JavaMethod";
definition.staticFunctions = JavaMethod_staticFunctions;
definition.callAsFunction = &JavaMethod_callAsFunction;
definition.finalize = &CYFinalize;
- CYJavaMethod::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaMethod>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "JavaStaticMethod";
definition.staticFunctions = JavaStaticMethod_staticFunctions;
definition.callAsFunction = &JavaStaticMethod_callAsFunction;
definition.finalize = &CYFinalize;
- CYJavaStaticMethod::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaStaticMethod>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.attributes = kJSClassAttributeNoAutomaticPrototype;
definition.className = "JavaObject";
definition.staticValues = JavaObject_staticValues;
definition.finalize = &CYFinalize;
- CYJavaObject::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaObject>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "JavaArray";
definition.getProperty = &JavaArray_getProperty;
definition.setProperty = &JavaArray_setProperty;
definition.finalize = &CYFinalize;
- CYJavaArray::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaArray>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "JavaPackage";
definition.hasProperty = &CYJavaPackage_hasProperty;
definition.getProperty = &CYJavaPackage_getProperty;
definition.finalize = &CYFinalize;
- CYJavaPackage::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaPackage>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.attributes = kJSClassAttributeNoAutomaticPrototype;
definition.setProperty = &JavaStaticInterior_setProperty;
definition.getPropertyNames = &JavaStaticInterior_getPropertyNames;
definition.finalize = &CYFinalize;
- CYJavaStaticInterior::Class_ = JSClassCreate(&definition);
+ CYPrivate<CYJavaStaticInterior>::Class_ = JSClassCreate(&definition);
}
void CYJava_SetupContext(JSContextRef context) {
JSObjectRef global(CYGetGlobalObject(context));
- //JSObjectRef cy(CYCastJSObject(context, CYGetProperty(context, global, cy_s)));
+ JSObjectRef cy(CYCastJSObject(context, CYGetProperty(context, global, cy_s)));
JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript"))));
JSObjectRef all(CYCastJSObject(context, CYGetProperty(context, cycript, CYJSString("all"))));
//JSObjectRef alls(CYCastJSObject(context, CYGetProperty(context, cycript, CYJSString("alls"))));
JSObjectRef Java(JSObjectMake(context, NULL, NULL));
CYSetProperty(context, cycript, CYJSString("Java"), Java);
+ CYSetProperty(context, cy, CYJSString("Java"), Java);
- JSObjectRef Packages(CYJavaPackage::Make(context, CYJavaPackage::Path()));
- CYSetProperty(context, all, CYJSString("Packages"), Packages);
+ JSObjectRef Packages(CYPrivate<CYJavaPackage>::Make(context, nullptr, CYJavaPackage::Path()));
+ CYSetProperty(context, all, CYJSString("Packages"), Packages, kJSPropertyAttributeDontEnum);
for (auto name : (const char *[]) {"java", "javax", "android", "com", "net", "org"}) {
CYJSString js(name);
- CYSetProperty(context, all, js, CYGetProperty(context, Packages, js));
+ CYSetProperty(context, all, js, CYPrivate<CYJavaPackage>::Make(context, nullptr, CYJavaPackage::Path(1, name)), kJSPropertyAttributeDontEnum);
}
}