: applicationDidFinishLaunching: v12@0:4@8
+
S CGPoint "x"f"y"f
S CGRect "origin"{CGPoint}"size"{CGSize}
S CGSize "width"f"height"f
C UIBarStyleBlack 1
C UIBarStyleBlackOpaque 2
C UIBarStyleBlackTranslucent 3
+T UIBarStyle i
C UIDataDetectorTypePhoneNumber (1<<0)
C UIDataDetectorTypeLink (1<<1)
C UIDataDetectorTypeNone 0
-# XXX: NSUIntegerMax
C UIDataDetectorTypeAll -1
+T UIDataDetectorTypes {NSUInteger}
+
+S UIEdgeInsets "top"{CGFloat}"left"{CGFloat}"bottom"{CGFloat}"right"{CGFloat}
# UINavigationBar
F UIGraphicsGetCurrentContext @
F UIGraphicsPushContext v@
F UIGraphicsPopContext v
-F UIGraphicsBeginImageContext v{CGSize=ff}
+F UIGraphicsBeginImageContext v{CGSize}
F UIGraphicsGetImageFromCurrentImageContext @
F UIGraphicsEndImageContext v
-F UIRectClip v{CGRect={CGPoint=ff}{CGSize=ff}}
-F UIRectFill v{CGRect={CGPoint=ff}{CGSize=ff}}
-F UIRectFillUsingBlendMode v{CGRect={CGPoint=ff}{CGSize=ff}}i
-F UIRectFrame v{CGRect={CGPoint=ff}{CGSize=ff}}
-F UIRectFrameUsingBlendMode v{CGRect={CGPoint=ff}{CGSize=ff}}i
-
-F CGPointFromString {CGPoint=ff}@
-F CGRectFromString {CGRect={CGPoint=ff}{CGSize=ff}}@
-F CGSizeFromString {CGSize=ff}@
-F CGAffineTransformFromString {CGAffineTransform=ffffff}@
+F UIRectClip v{CGRect}
+F UIRectFill v{CGRect}
+F UIRectFillUsingBlendMode v{CGRect}{CGBlendMode}
+F UIRectFrame v{CGRect}
+F UIRectFrameUsingBlendMode v{CGRect}{CGBlendMode}
+
+F CGPointFromString {CGPoint}@
+F CGRectFromString {CGRect}@
+F CGSizeFromString {CGSize}@
+F CGAffineTransformFromString {CGAffineTransform}@
F UIEdgeInsetsFromString {UIEdgeInsets=ffff}@
-F NSStringFromCGPoint @{CGPoint=ff}
-F NSStringFromCGRect @{CGRect={CGPoint=ff}{CGSize=ff}}
-F NSStringFromCGSize @{CGSize=ff}
-F NSStringFromCGAffineTransform @{CGAffineTransform=ffffff}
+F NSStringFromCGPoint @{CGPoint}
+F NSStringFromCGRect @{CGRect}
+F NSStringFromCGSize @{CGSize}
+F NSStringFromCGAffineTransform @{CGAffineTransform}
F NSStringFromUIEdgeInsets @{UIEdgeInsets=ffff}
F UIEdgeInsetsMake {UIEdgeInsets=ffff}ffff
F UIEdgeInsetsEqualToEdgeInsets B{UIEdgeInsets=ffff}{UIEdgeInsets=ffff}
-F UIEdgeInsetsInsetRect {CGRect={CGPoint=ff}{CGSize=ff}}{CGRect={CGPoint=ff}{CGSize=ff}}{UIEdgeInsets=ffff}
+F UIEdgeInsetsInsetRect {CGRect}{CGRect}{UIEdgeInsets=ffff}
# XXX: UIInterfaceOrientationIsPortrait
# XXX: UIInterfaceOrientationIsLandscape
V kABHomeLabel @
V kABOtherLabel @
+f CoreAnimation
+
+S CATransform3D "m11"{CGFloat}"m12"{CGFloat}"m13"{CGFloat}"m14"{CGFloat}"m21"{CGFloat}"m22"{CGFloat}"m23"{CGFloat}"m24"{CGFloat}"m31"{CGFloat}"m32"{CGFloat}"m33"{CGFloat}"m34"{CGFloat}"m41"{CGFloat}"m42"{CGFloat}"m43"{CGFloat}"m44"{CGFloat}
+
+F CACurrentMediaTime {CFTimeInterval}
+
+F CATransform3DIsIdentity B{CATransform3D}
+F CATransform3DEqualToTransform B{CATransform3D}{CATransform3D}
+F CATransform3DMakeTranslation {CATransform3D}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DMakeScale {CATransform3D}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DMakeRotation {CATransform3D}{CGFloat}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DTranslate {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DScale {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DRotate {CATransform3D}{CATransform3D}{CGFloat}{CGFloat}{CGFloat}{CGFloat}
+F CATransform3DConcat {CATransform3D}{CATransform3D}{CATransform3D}
+F CATransform3DInvert {CATransform3D}{CATransform3D}
+F CATransform3DMakeAffineTransform {CATransform3D}{CGAffineTransform}
+F CATransform3DIsAffine B{CATransform3D}
+F CATransform3DGetAffineTransform {CGAffineTransform}{CATransform3D}
+
f CoreData
C NSUndefinedAttributeType 0
f CoreGraphics
-# CGAffineTransform
+T CGFloat f
-F CGAffineTransformMake {CGAffineTransform=ffffff}ffffff
-F CGAffineTransformMakeRotation {CGAffineTransform=ffffff}f
-F CGAffineTransformMakeScale {CGAffineTransform=ffffff}ff
-F CGAffineTransformMakeTranslation {CGAffineTransform=ffffff}ff
+# CFByteOrderUtils
-F CGAffineTransformTranslate {CGAffineTransform=ffffff}{CGAffineTransform=ffffff}ff
-F CGAffineTransformScale {CGAffineTransform=ffffff}{CGAffineTransform=ffffff}ff
-F CGAffineTransformRotate {CGAffineTransform=ffffff}{CGAffineTransform=ffffff}f
-F CGAffineTransformInvert {CGAffineTransform=ffffff}{CGAffineTransform=ffffff}
-F CGAffineTransformConcat {CGAffineTransform=ffffff}{CGAffineTransform=ffffff}{CGAffineTransform=ffffff}
+E __CFByteOrder
+C CFByteOrderUnknown 0
+C CFByteOrderLittleEndian 1
+C CFByteOrderBigEndian 2
+T CFByteOrder __CFByteOrder
-F CGPointApplyAffineTransform {CGPoint=ff}{CGPoint=ff}{CGAffineTransform=ffffff}
-F CGSizeApplyAffineTransform {CGSize=ff}{CGSize=ff}{CGAffineTransform=ffffff}
-F CGRectApplyAffineTransform {CGRect={CGPoint=ff}{CGSize=ff}}{CGRect={CGPoint=ff}{CGSize=ff}}{CGAffineTransform=ffffff}
+# CGAffineTransform
+
+F CGAffineTransformMake {CGAffineTransform}{CGFloat}{CGFloat}{CGFloat}{CGFloat}{CGFloat}{CGFloat}
+F CGAffineTransformMakeRotation {CGAffineTransform}{CGFloat}
+F CGAffineTransformMakeScale {CGAffineTransform}{CGFloat}{CGFloat}
+F CGAffineTransformMakeTranslation {CGAffineTransform}{CGFloat}{CGFloat}
+
+F CGAffineTransformTranslate {CGAffineTransform}{CGAffineTransform}{CGFloat}{CGFloat}
+F CGAffineTransformScale {CGAffineTransform}{CGAffineTransform}{CGFloat}{CGFloat}
+F CGAffineTransformRotate {CGAffineTransform}{CGAffineTransform}{CGFloat}
+F CGAffineTransformInvert {CGAffineTransform}{CGAffineTransform}
+F CGAffineTransformConcat {CGAffineTransform}{CGAffineTransform}{CGAffineTransform}
+
+F CGPointApplyAffineTransform {CGPoint}{CGPoint}{CGAffineTransform}
+F CGSizeApplyAffineTransform {CGSize}{CGSize}{CGAffineTransform}
+F CGRectApplyAffineTransform {CGRect}{CGRect}{CGAffineTransform}
+
+F CGAffineTransformIsIdentity B{CGAffineTransform}
+F CGAffineTransformEqualToTransform B{CGAffineTransform}{CGAffineTransform}
+
+S CGAffineTransform "a"{CGFloat}"b"{CGFloat}"c"{CGFloat}"d"{CGFloat}"tx"{CGFloat}"ty"{CGFloat}
+
+V CGAffineTransformIdentity {CGAffineTransform}
+
+# CGContext
+
+T CGContextRef ^{CGContext}
+
+E CGBlendMode
+C kCGBlendModeNormal 0
+C kCGBlendModeMultiply 1
+C kCGBlendModeScreen 2
+C kCGBlendModeOverlay 3
+C kCGBlendModeDarken 4
+C kCGBlendModeLighten 5
+C kCGBlendModeColorDodge 6
+C kCGBlendModeColorBurn 7
+C kCGBlendModeSoftLight 8
+C kCGBlendModeHardLight 9
+C kCGBlendModeDifference 10
+C kCGBlendModeExclusion 11
+C kCGBlendModeHue 12
+C kCGBlendModeSaturation 13
+C kCGBlendModeColor 14
+C kCGBlendModeLuminosity 15
+C kCGBlendModeClear 16
+C kCGBlendModeCopy 17
+C kCGBlendModeSourceIn 18
+C kCGBlendModeSourceOut 19
+C kCGBlendModeSourceAtop 20
+C kCGBlendModeDestinationOver 21
+C kCGBlendModeDestinationIn 22
+C kCGBlendModeDestinationOut 23
+C kCGBlendModeDestinationAtop 24
+C kCGBlendModeXOR 25
+C kCGBlendModePlusDarker 26
+C kCGBlendModePlusLighter 27
+
+E CGInterpolationQuality
+C kCGInterpolationDefault 0
+C kCGInterpolationNone 1
+C kCGInterpolationLow 2
+C kCGInterpolationHigh 3
+
+E CGLineCap
+C kCGLineCapButt 0
+C kCGLineCapRound 1
+C kCGLineCapSquare 2
+
+E CGLineJoin
+C kCGLineJoinMiter 0
+C kCGLineJoinRound 1
+C kCGLineJoinBevel 2
+
+E CGTextDrawingMode
+C kCGTextFill 0
+C kCGTextStroke 1
+C kCGTextFillStroke 2
+C kCGTextInvisible 3
+C kCGTextFillClip 4
+C kCGTextStrokeClip 5
+C kCGTextFillStrokeClip 6
+C kCGTextClip 7
+
+E CGTextEncoding
+C kCGEncodingFontSpecific 0
+C kCGEncodingMacRoman 1
-F CGAffineTransformIsIdentity B{CGAffineTransform=ffffff}
-F CGAffineTransformEqualToTransform B{CGAffineTransform=ffffff}{CGAffineTransform=ffffff}
+f CoreLocation
-S CGAffineTransform "a"f"b"f"c"f"d"f"tx"f"ty"f
+T CLLocationDegrees d
-V CGAffineTransformIdentity {CGAffineTransform=ffffff}
+S CLLocationCoordinate2D "latitude"{CLLocationDegrees}"longitude"{CLLocationDegrees}
-f CoreLocation
+T CLLocationAccuracy d
V kCLLocationAccuracyBest d
V kCLLocationAccuracyNearestTenMeters d
V kCLLocationAccuracyKilometer d
V kCLLocationAccuracyThreeKilometers d
+T CLLocationSpeed d
+T CLLocationDirection d
+
V kCLDistanceFilterNone d
V kCLHeadingFilterNone d
f Foundation
-S _NSRange "location"I"length"I
+T NSAppleEventManagerSuspensionID ^r{__NSAppleEventManagerSuspension}
+
+E _NSByteOrder
+C NS_UnknownByteOrder CFByteOrderUnknown
+C NS_LittleEndian CFByteOrderLittleEndian
+C NS_BigEndian CFByteOrderBigEndian
+
+# NSComparator
+
+C NSOrderedAscending -1
+C NSOrderedSame 0
+C NSOrderedDescending 1
+T NSComparisonResult {NSInteger}
+
+# NSDecimal
+
+T NSEnumerationOptions {NSUInteger}
+# NSHashEnumerator
+T NSHashTable {_NSHashTable}
+# NSHashTableCallBacks
+
+T NSHashTableOptions {NSUInteger}
+T NSInteger l
+
+# NSMapEnumerator
+
+T NSMapTable {_NSMapTable}
+# NSMapTableKeyCallBacks
+
+T NSMapTableOptions {NSUInteger}
+# NSMapTableValueCallBacks
+
+T NSPoint {_NSPoint}
+T NSPointArray ^{NSPoint}
+T NSPointPointer ^{NSPoint}
+
+S _NSRange "location"{NSUInteger}"length"{NSUInteger}
+T NSRange {_NSRange}
+T NSRangePointer ^{NSRange}
+
+S _NSRect "origin"{NSPoint}"size"{NSSize}
+T NSRectArray ^{NSRect}
C NSMinXEdge 0
C NSMinYEdge 1
C NSMaxXEdge 2
C NSMaxYEdge 3
+T NSRectPointer ^{NSRect}
+
C NSApplicationDirectory 1
C NSDemoApplicationDirectory 2
C NSDeveloperApplicationDirectory 3
C NSItemReplacementDirectory 99
C NSAllApplicationsDirectory 100
C NSAllLibrariesDirectory 101
+T NSSearchPathDirectory {NSUInteger}
C NSUserDomainMask 1
C NSLocalDomainMask 2
C NSNetworkDomainMask 4
C NSSystemDomainMask 8
C NSAllDomainsMask 0x0ffff
+T NSSearchPathDomainMask {NSUInteger}
+
+S _NSSize "width"{CGFloat}"height"{CGFloat}
+T NSSize {_NSSize}
+
+T NSSizePointer ^{NSSize}
+T NSSocketNativeHandle i
+T NSStringEncoding {NSUInteger}
+S NSSwappedDouble "v"Q
+S NSSwappedFloat "v"L
+T NSTimeInterval d
+# NSUncaughtExceptionHandler
+T NSUInteger L
+T NSZone {_NSZone}
f MapKit
C MKPinAnnotationColorPurple 2
# MKCoordinateRegionMake
-# MKCoordinateRegionMakeWithDistance
+F MKCoordinateRegionMakeWithDistance {MKCoordinateRegion}{CLLocationCoordinate2D}{CLLocationDistance}{CLLocationDistance}
# MKCoordinateSpanMake
C RTLD_LAZY 0x1
C RTLD_DEFAULT -2
C RTLD_SELF -3
-# XXX: dladdr
+S dl_info "dli_fname"*"dli_fbase"v^"dli_sname"*"dli_saddr"^v
+T Dl_info {dl_info}
+
+F dladdr i^rv^{dl_info}
F dlclose i^v
F dlerror *
F dlopen ^v*i
struct CYData {
apr_pool_t *pool_;
- void *value_;
-
- CYData() {
- }
-
- CYData(void *value) :
- value_(value)
- {
- }
virtual ~CYData() {
}
- void *operator new(size_t size) {
+ static void *operator new(size_t size) {
apr_pool_t *pool;
apr_pool_create(&pool, NULL);
void *data(apr_palloc(pool, size));
reinterpret_cast<CYData *>(data)->pool_ = pool;
- return data;;
+ return data;
+ }
+
+ static void operator delete(void *data) {
+ apr_pool_destroy(reinterpret_cast<CYData *>(data)->pool_);
}
static void Finalize(JSObjectRef object) {
- CYData *data(reinterpret_cast<CYData *>(JSObjectGetPrivate(object)));
- data->~CYData();
- apr_pool_destroy(data->pool_);
+ delete reinterpret_cast<CYData *>(JSObjectGetPrivate(object));
}
};
-struct Selector_privateData :
+struct CYValue :
CYData
+{
+ void *value_;
+
+ CYValue() {
+ }
+
+ CYValue(void *value) :
+ value_(value)
+ {
+ }
+};
+
+struct Selector_privateData :
+ CYValue
{
Selector_privateData(SEL value) :
- CYData(value)
+ CYValue(value)
{
}
};
struct Instance :
- CYData
+ CYValue
{
enum Flags {
None = 0,
Flags flags_;
Instance(id value, Flags flags) :
- CYData(value),
+ CYValue(value),
flags_(flags)
{
}
virtual ~Instance() {
if ((flags_ & Transient) == 0)
- [GetValue() release];
+ // XXX: does this handle background threads correctly?
+ [GetValue() performSelector:@selector(release) withObject:nil afterDelay:0];
}
static JSObjectRef Make(JSContextRef context, id object, Flags flags) {
};
struct Pointer :
- CYData
+ CYValue
{
JSObjectRef owner_;
Type_privateData *type_;
Pointer(void *value, sig::Type *type, JSObjectRef owner) :
- CYData(value),
+ CYValue(value),
owner_(owner),
type_(new(pool_) Type_privateData(pool_, type))
{
};
struct Struct_privateData :
- CYData
+ CYValue
{
JSObjectRef owner_;
Type_privateData *type_;
return;
CYPoolTry {
- if (NSMutableArray *entry = [[Bridge_ objectAtIndex:2] objectForKey:[NSString stringWithUTF8String:name]]) {
+ if (NSMutableArray *entry = [[Bridge_ objectAtIndex:2] objectForKey:[NSString stringWithUTF8String:name]])
switch ([[entry objectAtIndex:0] intValue]) {
- case 0:
- static CYPool Pool_;
- sig::Parse(Pool_, &type->data.signature, [[entry objectAtIndex:1] UTF8String], &Structor_);
- break;
+ case 0: {
+ sig::Parse(pool, &type->data.signature, [[entry objectAtIndex:1] UTF8String], &Structor_);
+ } break;
+
+ case 1: {
+ sig::Signature signature;
+ sig::Parse(pool, &signature, [[entry objectAtIndex:1] UTF8String], &Structor_);
+ type = signature.elements[0].type;
+ } break;
}
- }
} CYPoolCatch()
}
struct Functor_privateData :
- CYData
+ CYValue
{
sig::Signature signature_;
ffi_cif cif_;
Functor_privateData(const char *type, void (*value)()) :
- CYData(reinterpret_cast<void *>(value))
+ CYValue(reinterpret_cast<void *>(value))
{
sig::Parse(pool_, &signature_, type, &Structor_);
sig::sig_ffi_cif(pool_, &sig::ObjectiveC, &signature_, &cif_);
@interface NSObject (Cycript)
+- (JSValueRef) cy$JSValueInContext:(JSContextRef)context;
- (JSType) cy$JSType;
- (NSObject *) cy$toJSON:(NSString *)key;
- (void *) cy$symbol;
@end
-@interface NSNumber (Cycript)
-- (void *) cy$symbol;
-@end
-
struct PropertyAttributes {
CYPool pool_;
@implementation NSObject (Cycript)
+- (JSValueRef) cy$JSValueInContext:(JSContextRef)context {
+ return CYMakeInstance(context, self, false);
+}
+
- (JSType) cy$JSType {
return kJSTypeObject;
}
return [self cy$JSType] != kJSTypeBoolean ? CYCastJSValue(context, [self doubleValue]) : CYCastJSValue(context, [self boolValue]);
}
-- (void *) cy$symbol {
- return [self pointerValue];
-}
-
@end
@implementation NSString (Cycript)
} else return NULL;
}
+struct CYInternal :
+ CYData
+{
+ JSObjectRef object_;
+
+ CYInternal() :
+ object_(NULL)
+ {
+ }
+
+ ~CYInternal() {
+ // XXX: delete object_? ;(
+ }
+
+ static CYInternal *Get(id self) {
+ CYInternal *internal(NULL);
+ if (object_getInstanceVariable(self, "cy$internal_", reinterpret_cast<void **>(&internal)) == NULL) {
+ // XXX: do something epic? ;P
+ }
+
+ return internal;
+ }
+
+ static CYInternal *Set(id self) {
+ CYInternal *internal(NULL);
+ if (Ivar ivar = object_getInstanceVariable(self, "cy$internal_", reinterpret_cast<void **>(&internal))) {
+ if (internal == NULL) {
+ internal = new CYInternal();
+ object_setIvar(self, ivar, reinterpret_cast<id>(internal));
+ }
+ } else {
+ // XXX: do something epic? ;P
+ }
+
+ return internal;
+ }
+
+ JSValueRef GetProperty(JSContextRef context, JSStringRef name) {
+ if (object_ == NULL)
+ return NULL;
+ return CYGetProperty(context, object_, name);
+ }
+
+ void SetProperty(JSContextRef context, JSStringRef name, JSValueRef value) {
+ if (object_ == NULL)
+ object_ = JSObjectMake(context, NULL, NULL);
+ CYSetProperty(context, object_, name, value);
+ }
+};
+
static JSValueRef Instance_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
CYPool pool;
NSString *self(CYCastNSObject(pool, context, object));
NSString *name(CYCastNSString(pool, property));
+ if (CYInternal *internal = CYInternal::Get(self))
+ if (JSValueRef value = internal->GetProperty(context, property))
+ return value;
+
CYPoolTry {
if (NSObject *data = [self cy$getProperty:name])
return CYCastJSValue(context, data);
}
}
+ if (CYInternal *internal = CYInternal::Set(self)) {
+ internal->SetProperty(context, property, value);
+ return true;
+ }
+
return false;
} CYCatch
}
return CYSendMessage(pool, context, self, _cmd, count - 2, arguments + 2, uninitialized, exception);
}
-static JSValueRef CYJSValueInContext(id self, SEL _cmd, JSContextRef context) {
- // XXX: the offset of this Ivar could be recomputed and stored in some form of closure during $objc_registerClassPair
-
- JSObjectRef value;
- object_getInstanceVariable(self, "cy$value_", reinterpret_cast<void **>(&value));
+void dealloc_(id self, SEL sel) {
+ CYInternal *internal;
+ object_getInstanceVariable(self, "cy$internal_", reinterpret_cast<void **>(&internal));
+ if (internal != NULL)
+ delete internal;
+ if (Method dealloc = class_getInstanceMethod(object_getClass(self), @selector(cy$dealloc)))
+ reinterpret_cast<void (*)(id, SEL)>(method_getImplementation(dealloc))(self, sel);
+}
- if (value == NULL) {
- value = CYMakeInstance(context, self, false);
- object_setInstanceVariable(self, "cy$value_", value);
+MSHook(void, objc_registerClassPair, Class _class) {
+ Class super(class_getSuperclass(_class));
+ if (super == NULL || class_getInstanceVariable(super, "cy$internal_") == NULL) {
+ class_addIvar(_class, "cy$internal_", sizeof(CYInternal *), log2(sizeof(CYInternal *)), "^{CYInternal}");
+ if (!class_addMethod(_class, @selector(dealloc), reinterpret_cast<IMP>(&dealloc_), "v8@0:4")) {
+ Method dealloc(class_getInstanceMethod(_class, @selector(dealloc)));
+ class_addMethod(_class, @selector(cy$dealloc), method_getImplementation(dealloc), method_getTypeEncoding(dealloc));
+ method_setImplementation(dealloc, reinterpret_cast<IMP>(&dealloc_));
+ }
}
- return value;
+ _objc_registerClassPair(_class);
}
-static JSValueRef $objc_registerClassPair(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef objc_registerClassPair_(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYTry {
CYPool pool;
-
Class _class(CYCastNSObject(pool, context, object));
- if (class_getInstanceMethod(_class, @selector(cy$JSValueInContext:)) == NULL) {
- class_addIvar(_class, "cy$value_", sizeof(JSObjectRef), log2(sizeof(JSObjectRef)), "^v");
- class_addMethod(_class, @selector(cy$JSValueInContext:), reinterpret_cast<IMP>(&CYJSValueInContext), "^v12@0:4^v8");
- }
-
- objc_registerClassPair(_class);
+ $objc_registerClassPair(_class);
return CYJSUndefined(context);
} CYCatch
}
} CYCatch
}
-JSValueRef CYData_getProperty_value(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
- CYData *data(reinterpret_cast<CYData *>(JSObjectGetPrivate(object)));
- return CYCastJSValue(context, reinterpret_cast<uintptr_t>(data->value_));
+JSValueRef CYValue_getProperty_value(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
+ CYValue *internal(reinterpret_cast<CYValue *>(JSObjectGetPrivate(object)));
+ return CYCastJSValue(context, reinterpret_cast<uintptr_t>(internal->value_));
}
JSValueRef Selector_getProperty_prototype(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
return Function_;
}
-static JSValueRef CYData_callAsFunction_valueOf(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef CYValue_callAsFunction_valueOf(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYTry {
- CYData *data(reinterpret_cast<CYData *>(JSObjectGetPrivate(_this)));
- return CYCastJSValue(context, reinterpret_cast<uintptr_t>(data->value_));
+ CYValue *internal(reinterpret_cast<CYValue *>(JSObjectGetPrivate(_this)));
+ return CYCastJSValue(context, reinterpret_cast<uintptr_t>(internal->value_));
} CYCatch
}
-static JSValueRef CYData_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
- return CYData_callAsFunction_valueOf(context, object, _this, count, arguments, exception);
+static JSValueRef CYValue_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+ return CYValue_callAsFunction_valueOf(context, object, _this, count, arguments, exception);
}
-static JSValueRef CYData_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
+static JSValueRef CYValue_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYTry {
- CYData *data(reinterpret_cast<CYData *>(JSObjectGetPrivate(_this)));
+ CYValue *internal(reinterpret_cast<CYValue *>(JSObjectGetPrivate(_this)));
char string[32];
- sprintf(string, "%p", data->value_);
+ sprintf(string, "%p", internal->value_);
return CYCastJSValue(context, string);
} CYCatch
}
static JSValueRef Instance_callAsFunction_toCYON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYTry {
- Instance *data(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
+ Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
CYPoolTry {
- return CYCastJSValue(context, CYJSString([data->GetValue() cy$toCYON]));
+ return CYCastJSValue(context, CYJSString([internal->GetValue() cy$toCYON]));
} CYPoolCatch(NULL)
} CYCatch
}
static JSValueRef Instance_callAsFunction_toJSON(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) {
CYTry {
- Instance *data(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
+ Instance *internal(reinterpret_cast<Instance *>(JSObjectGetPrivate(_this)));
CYPoolTry {
NSString *key(count == 0 ? nil : CYCastNSString(NULL, CYJSString(context, arguments[0])));
- return CYCastJSValue(context, CYJSString([data->GetValue() cy$toJSON:key]));
+ return CYCastJSValue(context, CYJSString([internal->GetValue() cy$toJSON:key]));
} CYPoolCatch(NULL)
} CYCatch
}
} CYCatch
}
-static JSStaticValue CYData_staticValues[2] = {
- {"value", &CYData_getProperty_value, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
+static JSStaticValue CYValue_staticValues[2] = {
+ {"value", &CYValue_getProperty_value, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete},
{NULL, NULL, NULL, 0}
};
static JSStaticFunction Pointer_staticFunctions[4] = {
- {"toCYON", &CYData_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
- {"toJSON", &CYData_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
- {"valueOf", &CYData_callAsFunction_valueOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"toCYON", &CYValue_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"toJSON", &CYValue_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"valueOf", &CYValue_callAsFunction_valueOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
{NULL, NULL, 0}
};
static JSStaticFunction Functor_staticFunctions[4] = {
- {"toCYON", &CYData_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
- {"toJSON", &CYData_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
- {"valueOf", &CYData_callAsFunction_valueOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"toCYON", &CYValue_callAsFunction_toCYON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"toJSON", &CYValue_callAsFunction_toJSON, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
+ {"valueOf", &CYValue_callAsFunction_valueOf, kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
{NULL, NULL, 0}
};
definition = kJSClassDefinitionEmpty;
definition.className = "Selector";
- definition.staticValues = CYData_staticValues;
+ definition.staticValues = CYValue_staticValues;
//definition.staticValues = Selector_staticValues;
definition.staticFunctions = Selector_staticFunctions;
definition.callAsFunction = &Selector_callAsFunction;
definition = kJSClassDefinitionEmpty;
definition.className = "Instance";
- definition.staticValues = CYData_staticValues;
+ definition.staticValues = CYValue_staticValues;
definition.staticFunctions = Instance_staticFunctions;
definition.getProperty = &Instance_getProperty;
definition.setProperty = &Instance_setProperty;
CYSetProperty(context, global, CYJSString("Pointer"), JSObjectMakeConstructor(context, Pointer_, &Pointer_new));
CYSetProperty(context, global, CYJSString("Selector"), JSObjectMakeConstructor(context, Selector_, &Selector_new));
- CYSetProperty(context, global, CYJSString("objc_registerClassPair"), JSObjectMakeFunctionWithCallback(context, CYJSString("objc_registerClassPair"), &$objc_registerClassPair));
+ MSHookFunction(&objc_registerClassPair, MSHake(objc_registerClassPair));
+
+ CYSetProperty(context, global, CYJSString("objc_registerClassPair"), JSObjectMakeFunctionWithCallback(context, CYJSString("objc_registerClassPair"), &objc_registerClassPair_));
CYSetProperty(context, global, CYJSString("objc_msgSend"), JSObjectMakeFunctionWithCallback(context, CYJSString("objc_msgSend"), &$objc_msgSend));
System_ = JSObjectMake(context, NULL, NULL);