}
struct Context :
- CYPrivate<Context>
+ CYRoot
{
JSGlobalContextRef context_;
};
struct CArray :
- CYPrivate<CArray>
+ CYRoot
{
void *value_;
CYProtect owner_;
};
struct CString :
- CYPrivate<CString>
+ CYRoot
{
char *value_;
CYProtect owner_;
};
struct Pointer :
- CYPrivate<Pointer>
+ CYRoot
{
void *value_;
CYProtect owner_;
};
struct Struct_privateData :
- CYPrivate<Struct_privateData>
+ CYRoot
{
void *value_;
CYProtect owner_;
} CYCatch(NULL) }
JSObjectRef CYMakePointer(JSContextRef context, void *pointer, const sig::Type &type, ffi_type *ffi, JSObjectRef owner) {
- return Pointer::Make(context, pointer, type, context, owner);
+ return CYPrivate<Pointer>::Make(context, pointer, type, context, owner);
}
static JSValueRef CYMakeFunctor(JSContextRef context, void (*function)(), bool variadic, const sig::Signature &signature) {
return NULL;
case kJSTypeObject: {
JSObjectRef object((JSObjectRef) value);
- if (JSValueIsObjectOfClass(context, value, Pointer::Class_)) {
+ if (JSValueIsObjectOfClass(context, value, CYPrivate<Pointer>::Class_)) {
Pointer *internal(reinterpret_cast<Pointer *>(JSObjectGetPrivate(object)));
return internal->value_;
}
JSValueRef String::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
if (char *value = *reinterpret_cast<char **>(data))
- return CString::Make(context, value, context, owner);
+ return CYPrivate<CString>::Make(context, value, context, owner);
return CYJSNull(context);
}
}
JSValueRef Array::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
- return CArray::Make(context, data, size, type, ffi->elements[0], context, owner);
+ return CYPrivate<CArray>::Make(context, data, size, type, ffi->elements[0], context, owner);
}
JSValueRef Enum::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
JSValueRef Aggregate::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
_assert(!overlap);
_assert(signature.count != _not(size_t));
- return Struct_privateData::Make(context, data, *this, ffi, context, owner);
+ return CYPrivate<Struct_privateData>::Make(context, data, *this, ffi, context, owner);
}
JSValueRef Function::FromFFI(JSContextRef context, ffi_type *ffi, void *data, bool initialize, JSObjectRef owner) const {
return &PointerToVoid_;
JSObjectRef object(CYCastJSObject(context, value));
JSObjectRef type(CYCastJSObject(context, CYGetProperty(context, object, cyt_s)));
- _assert(JSValueIsObjectOfClass(context, type, Type_privateData::Class_));
+ _assert(JSValueIsObjectOfClass(context, type, CYPrivate<Type_privateData>::Class_));
Type_privateData *internal(reinterpret_cast<Type_privateData *>(JSObjectGetPrivate(type)));
return internal->type_;
}
} CYCatch(NULL) }
JSObjectRef CYMakeType(JSContextRef context, const sig::Type &type) {
- return Type_privateData::Make(context, type);
+ return CYPrivate<Type_privateData>::Make(context, type);
}
extern "C" bool CYBridgeHash(CYPool &pool, CYUTF8String name, const char *&code, unsigned &flags) {
element.name = CYPoolCString(pool, context, name);
JSObjectRef object(CYCastJSObject(context, CYArrayGet(context, types, i)));
- _assert(JSValueIsObjectOfClass(context, object, Type_privateData::Class_));
+ _assert(JSValueIsObjectOfClass(context, object, CYPrivate<Type_privateData>::Class_));
Type_privateData *internal(reinterpret_cast<Type_privateData *>(JSObjectGetPrivate(object)));
element.type = internal->type_;
_assert(element.type != NULL);
element.offset = _not(size_t);
JSObjectRef object(CYCastJSObject(context, arguments[i]));
- _assert(JSValueIsObjectOfClass(context, object, Type_privateData::Class_));
+ _assert(JSValueIsObjectOfClass(context, object, CYPrivate<Type_privateData>::Class_));
Type_privateData *internal(reinterpret_cast<Type_privateData *>(JSObjectGetPrivate(object)));
element.type = internal->type_;
definition = kJSClassDefinitionEmpty;
definition.className = "Context";
definition.finalize = &CYFinalize;
- Context::Class_ = JSClassCreate(&definition);
+ CYPrivate<Context>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "CArray";
definition.getProperty = &CArray_getProperty;
definition.setProperty = &CArray_setProperty;
definition.finalize = &CYFinalize;
- CArray::Class_ = JSClassCreate(&definition);
+ CYPrivate<CArray>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "CString";
definition.getProperty = &CString_getProperty;
definition.setProperty = &CString_setProperty;
definition.finalize = &CYFinalize;
- CString::Class_ = JSClassCreate(&definition);
+ CYPrivate<CString>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Functor";
definition.getProperty = &Pointer_getProperty;
definition.setProperty = &Pointer_setProperty;
definition.finalize = &CYFinalize;
- Pointer::Class_ = JSClassCreate(&definition);
+ CYPrivate<Pointer>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Struct";
definition.setProperty = &Struct_setProperty;
definition.getPropertyNames = &Struct_getPropertyNames;
definition.finalize = &CYFinalize;
- Struct_privateData::Class_ = JSClassCreate(&definition);
+ CYPrivate<Struct_privateData>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Type";
definition.callAsFunction = &Type_callAsFunction;
definition.callAsConstructor = &Type_callAsConstructor;
definition.finalize = &CYFinalize;
- Type_privateData::Class_ = JSClassCreate(&definition);
+ CYPrivate<Type_privateData>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Global";
JSObjectRef global(CYGetGlobalObject(context));
- JSObjectRef cy(Context::Make(context, context));
+ JSObjectRef cy(CYPrivate<Context>::Make(context, context));
CYSetProperty(context, global, cy_s, cy, kJSPropertyAttributeDontEnum);
/* Cache Globals {{{ */
CYSetProperty(context, cycript, CYJSString("compile"), &Cycript_compile_callAsFunction);
CYSetProperty(context, cycript, CYJSString("gc"), &Cycript_gc_callAsFunction);
- JSObjectRef CArray(JSObjectMakeConstructor(context, CArray::Class_, &CArray_new));
+ JSObjectRef CArray(JSObjectMakeConstructor(context, CYPrivate<::CArray>::Class_, &CArray_new));
CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, CArray, prototype_s)), Array_prototype);
CYSetProperty(context, cycript, CYJSString("CArray"), CArray);
- JSObjectRef CString(JSObjectMakeConstructor(context, CString::Class_, &CString_new));
+ JSObjectRef CString(JSObjectMakeConstructor(context, CYPrivate<::CString>::Class_, &CString_new));
CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, CString, prototype_s)), String_prototype);
CYSetProperty(context, cycript, CYJSString("CString"), CString);
CYSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Functor, prototype_s)), Function_prototype);
CYSetProperty(context, cycript, CYJSString("Functor"), Functor);
- CYSetProperty(context, cycript, CYJSString("Pointer"), JSObjectMakeConstructor(context, Pointer::Class_, &Pointer_new));
- CYSetProperty(context, cycript, CYJSString("Type"), JSObjectMakeConstructor(context, Type_privateData::Class_, &Type_new));
+ CYSetProperty(context, cycript, CYJSString("Pointer"), JSObjectMakeConstructor(context, CYPrivate<Pointer>::Class_, &Pointer_new));
+ CYSetProperty(context, cycript, CYJSString("Type"), JSObjectMakeConstructor(context, CYPrivate<Type_privateData>::Class_, &Type_new));
JSObjectRef modules(JSObjectMake(context, NULL, NULL));
CYSetProperty(context, cy, CYJSString("modules"), modules);
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_;
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_);
} 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_);
} CYCatch(NULL) }
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;
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;
jni->ExceptionClear();
package.push_back(next);
- return CYJavaPackage::Make(context, jni, package);
+ return CYPrivate<CYJavaPackage>::Make(context, jni, package);
} CYCatch(NULL) }
static void Cycript_delete(JNIEnv *env, jclass api, jlong jprotect) { CYJavaTry {
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) {
CYSetProperty(context, cycript, CYJSString("Java"), Java);
CYSetProperty(context, cy, CYJSString("Java"), Java);
- JSObjectRef Packages(CYJavaPackage::Make(context, nullptr, CYJavaPackage::Path()));
+ 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, CYJavaPackage::Make(context, nullptr, CYJavaPackage::Path(1, name)), kJSPropertyAttributeDontEnum);
+ CYSetProperty(context, all, js, CYPrivate<CYJavaPackage>::Make(context, nullptr, CYJavaPackage::Path(1, name)), kJSPropertyAttributeDontEnum);
}
}
JSValueRef Messages::GetPrototype(JSContextRef context) const {
if (Class super = class_getSuperclass(value_))
- return Messages::Make(context, super);
+ return CYPrivate<Messages>::Make(context, super);
return NULL;
}
static JSValueRef CYCastJSValue(JSContextRef context, SEL sel) {
if (sel == NULL)
return CYJSNull(context);
- return Selector_privateData::Make(context, sel);
+ return CYPrivate<Selector_privateData>::Make(context, sel);
}
static SEL CYCastSEL(JSContextRef context, JSValueRef value) {
- if (JSValueIsObjectOfClass(context, value, Selector_privateData::Class_)) {
+ if (JSValueIsObjectOfClass(context, value, CYPrivate<Selector_privateData>::Class_)) {
Selector_privateData *internal(reinterpret_cast<Selector_privateData *>(JSObjectGetPrivate((JSObjectRef) value)));
return reinterpret_cast<SEL>(internal->value_);
} else {
id self(internal->value_);
if (JSStringIsEqualToUTF8CString(property, "$cyi"))
- return Interior::Make(context, self, context, object);
+ return CYPrivate<Interior>::Make(context, self, context, object);
CYPool pool;
NSString *name(CYCastNSString(&pool, context, property));
SEL _cmd;
Class _class;
- if (JSValueIsObjectOfClass(context, arguments[0], cy::Super::Class_)) {
+ if (JSValueIsObjectOfClass(context, arguments[0], CYPrivate<cy::Super>::Class_)) {
cy::Super *internal(reinterpret_cast<cy::Super *>(JSObjectGetPrivate((JSObjectRef) arguments[0])));
self = internal->value_;
_class = internal->class_;;
CYPool pool;
id self(CYCastNSObject(&pool, context, arguments[0]));
Class _class(CYCastClass(pool, context, arguments[1]));
- return cy::Super::Make(context, self, _class);
+ return CYPrivate<cy::Super>::Make(context, self, _class);
} CYCatch(NULL) }
static JSObjectRef Selector_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
throw CYJSError(context, "incorrect number of arguments to Selector constructor");
CYPool pool;
const char *name(CYPoolCString(pool, context, arguments[0]));
- return Selector_privateData::Make(context, sel_registerName(name));
+ return CYPrivate<Selector_privateData>::Make(context, sel_registerName(name));
} CYCatch(NULL) }
static JSObjectRef Instance_new(JSContextRef context, JSObjectRef object, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
id self(internal->value_);
if (!CYIsClass(self))
return CYJSUndefined(context);
- return Messages::Make(context, (Class) self);
+ return CYPrivate<Messages>::Make(context, (Class) self);
} CYCatch(NULL) }
static JSValueRef Instance_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry {
definition.setProperty = &Interior_setProperty;
definition.getPropertyNames = &Interior_getPropertyNames;
definition.finalize = &CYFinalize;
- Interior::Class_ = JSClassCreate(&definition);
+ CYPrivate<Interior>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Message";
definition.setProperty = &Messages_setProperty;
definition.getPropertyNames = &Messages_getPropertyNames;
definition.finalize = &CYFinalize;
- Messages::Class_ = JSClassCreate(&definition);
+ CYPrivate<Messages>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Selector";
definition.staticFunctions = Selector_staticFunctions;
definition.callAsFunction = &Selector_callAsFunction;
definition.finalize = &CYFinalize;
- Selector_privateData::Class_ = JSClassCreate(&definition);
+ CYPrivate<Selector_privateData>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "Super";
definition.finalize = &CYFinalize;
- cy::Super::Class_ = JSClassCreate(&definition);
+ CYPrivate<cy::Super>::Class_ = JSClassCreate(&definition);
definition = kJSClassDefinitionEmpty;
definition.className = "ObjectiveC::Classes";
#endif
JSObjectRef Message(JSObjectMakeConstructor(context, Message_privateData::Class_, NULL));
- JSObjectRef Selector(JSObjectMakeConstructor(context, Selector_privateData::Class_, &Selector_new));
- JSObjectRef Super(JSObjectMakeConstructor(context, cy::Super::Class_, &Super_new));
+ JSObjectRef Selector(JSObjectMakeConstructor(context, CYPrivate<Selector_privateData>::Class_, &Selector_new));
+ JSObjectRef Super(JSObjectMakeConstructor(context, CYPrivate<cy::Super>::Class_, &Super_new));
JSObjectRef Instance(JSObjectMakeConstructor(context, Instance::Class_, &Instance_new));
JSObjectRef Instance_prototype(CYCastJSObject(context, CYGetProperty(context, Instance, prototype_s)));