]> git.saurik.com Git - cycript.git/commitdiff
Added more UIKit bridging, better factored property access on structs (fixing a crash...
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 9 Oct 2009 19:48:01 +0000 (19:48 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 9 Oct 2009 19:48:01 +0000 (19:48 +0000)
Bridge.def
Library.mm
control
makefile

index e93ecf3b9290168a47b86f22f1b40b6238daf502..4c624f603903092e4a6151f4c77063233de6cc33 100644 (file)
@@ -99,6 +99,62 @@ F sel_registerName :*
 
 f UIKit
 
+C UIBarStyleDefault 0
+C UIBarStyleBlack 1
+C UIBarStyleBlackOpaque 2
+C UIBarStyleBlackTranslucent 3
+
+C UIDataDetectorTypePhoneNumber (1<<0)
+C UIDataDetectorTypeLink (1<<1)
+C UIDataDetectorTypeNone 0
+# XXX: NSUIntegerMax
+C UIDataDetectorTypeAll -1
+
+# UINavigationBar
+
+# UINavigationController
+
+V UINavigationControllerHideShowBarDuration f
+
+# UINavigationControllerDelegate
+
+: navigationController:willShowViewController:animated: v20@0:4@8@12B16
+: navigationController:didShowViewController:animated: v20@0:4@8@12B16
+
+# UIScrollView
+
+C UIScrollViewIndicatorStyleDefault 0
+C UIScrollViewIndicatorStyleBlack 1
+C UIScrollViewIndicatorStyleWhite 2
+
+V UIScrollViewDecelerationRateNormal f
+V UIScrollViewDecelerationRateFast f
+
+# UIScrollViewDelegate
+
+: scrollViewDidScroll: v12@0:4@8
+: scrollViewWillBeginDragging: v12@0:4@8
+: scrollViewDidEndDragging:willDecelerate: v16@0:4@8B12
+: scrollViewShouldScrollToTop: B12@0:4@8
+: scrollViewDidScrollToTop: v12@0:4@8
+: scrollViewWillBeginDecelerating: v12@0:4@8
+: scrollViewDidEndDecelerating: v12@0:4@8
+
+: viewForZoomingInScrollView: @12@0:4@8
+: scrollViewDidEndZooming:withView:atScale: v20@0:4@8@12f16
+
+: scrollViewDidEndScrollingAnimation: v12@0:4@8
+
+# UITabBar
+
+# UITabBarDelegate
+
+: tabBar:willBeginCustomizingItems: v16@0:4@8@12
+: tabBar:didBeginCustomizingItems: v16@0:4@8@12
+: tabBar:willBeginCustomizingItems:changed: v20@0:4@8@12B16
+: tabBar:didBeginCustomizingItems:changed: v20@0:4@8@12B16
+: tabBar:didSelectItem: v16@0:4@8@12
+
 # UITableView
 
 C UITableViewStylePlain 0
@@ -145,6 +201,8 @@ C UITableViewCellAccessoryCheckmark 3
 C UITableViewCellSeparatorStyleNone 0
 C UITableViewCellSeparatorStyleSingleLine 1
 
+# UITableViewController
+
 # UITableViewDataSource
 
 : tableView:numberOfRowsInSection: i16@0:4@8i12
@@ -161,6 +219,8 @@ C UITableViewCellSeparatorStyleSingleLine 1
 : tableView:canMoveRowAtIndexPath: B16@0:4@8@12
 : tableView:moveRowAtIndexPath:toIndexPath: v20@0:4@8@12@16
 
+# UIToolbar
+
 # UIView
 
 C UIViewAnimationCurveEaseInOut 0
@@ -196,6 +256,12 @@ C UIViewAnimationTransitionFlipFromRight 2
 C UIViewAnimationTransitionCurlUp 3
 C UIViewAnimationTransitionCurlDown 4
 
+# UIViewController
+
+C UIModalTransitionStyleCoverVertical 0
+C UIModalTransitionStyleFlipHorizontal 1
+C UIModalTransitionStyleCrossDissolve 2
+
 # UIWebView
 
 C UIWebViewNavigationTypeLinkClicked 0
@@ -212,21 +278,57 @@ C UIWebViewNavigationTypeOther 5
 : webViewDidFinishLoad: v12@0:4@8
 : webView:didFailLoadWithError: v16@0:4@8@12
 
-# Miscellaneous
-
-F UIApplicationUseLegacyEvents vB
+# Functions
 
-F UIAccessibilityPostNotification vI@
 F UIApplicationMain ii^^c@@
-F UIGraphicsEndImageContext v
-F UIGraphicsGetCurrentContext @
-F UIGraphicsGetImageFromCurrentImageContext @
-F UIGraphicsPopContext v
-F UIGraphicsPushContext v@
+
 F UIImageJPEGRepresentation @@
 F UIImagePNGRepresentation @@
 F UIImageWriteToSavedPhotosAlbum v@@:^v
 
+F UISaveVideoAtPathToSavedPhotosAlbum v@@:^v
+F UIVideoAtPathIsCompatibleWithSavedPhotosAlbum B@
+
+F UIGraphicsGetCurrentContext @
+F UIGraphicsPushContext v@
+F UIGraphicsPopContext v
+F UIGraphicsBeginImageContext v{CGSize=ff}
+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 UIEdgeInsetsFromString {UIEdgeInsets=ffff}@
+F NSStringFromCGPoint @{CGPoint=ff}
+F NSStringFromCGRect @{CGRect={CGPoint=ff}{CGSize=ff}}
+F NSStringFromCGSize @{CGSize=ff}
+F NSStringFromCGAffineTransform @{CGAffineTransform=ffffff}
+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}
+
+# XXX: UIInterfaceOrientationIsPortrait
+# XXX: UIInterfaceOrientationIsLandscape
+
+# XXX: UIDeviceOrientationIsValidInterfaceOrientation
+# XXX: UIDeviceOrientationIsPortrait
+# XXX: UIDeviceOrientationIsLandscape
+
+F UIAccessibilityPostNotification vI@
+
+# Miscellaneous
+
+F UIApplicationUseLegacyEvents vB
+
 F UIKeyboardDisableAutomaticAppearance v
 F UIKeyboardEnableAutomaticAppearance v
 F UIKeyboardInputModeUsesKBStar B@
@@ -596,6 +698,32 @@ f CoreFoundation
 F CFShow v@
 F CFShowStr v@
 
+f CoreGraphics
+
+# CGAffineTransform
+
+F CGAffineTransformMake {CGAffineTransform=ffffff}ffffff
+F CGAffineTransformMakeRotation {CGAffineTransform=ffffff}f
+F CGAffineTransformMakeScale {CGAffineTransform=ffffff}ff
+F CGAffineTransformMakeTranslation {CGAffineTransform=ffffff}ff
+
+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}
+
+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}
+
+F CGAffineTransformIsIdentity B{CGAffineTransform=ffffff}
+F CGAffineTransformEqualToTransform B{CGAffineTransform=ffffff}{CGAffineTransform=ffffff}
+
+S CGAffineTransform "a"f"b"f"c"f"d"f"tx"f"ty"f
+
+V CGAffineTransformIdentity {CGAffineTransform=ffffff}
+
 f CoreLocation
 
 V kCLLocationAccuracyBest d
index ef85e4c53b937084f3bf4141cfd54589fa8468b2..fc4bd5b76ed6c486487e37bb20be6cc1f8725d5c 100644 (file)
@@ -1351,21 +1351,26 @@ JSValueRef CYFromFFI(JSContextRef context, sig::Type *type, ffi_type *ffi, void
     return value;
 }
 
-void Index_(Struct_privateData *internal, double number, ssize_t &index, uint8_t *&base) {
+bool Index_(apr_pool_t *pool, Struct_privateData *internal, JSStringRef property, ssize_t &index, uint8_t *&base) {
     Type_privateData *typical(internal->type_);
 
+    size_t length;
+    const char *name(CYPoolCString(pool, property, &length));
+    double number(CYCastDouble(name, length));
+
+    if (std::isnan(number))
+        // XXX: implement!
+        return false;
+
     index = static_cast<ssize_t>(number);
-    if (index != number)
-        @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"struct index non-integral" userInfo:nil];
-    if (index < 0)
-        @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"struct index negative" userInfo:nil];
+    if (index != number || index < 0 || static_cast<size_t>(index) >= typical->type_.data.signature.count)
+        return false;
 
     base = reinterpret_cast<uint8_t *>(internal->value_);
     for (ssize_t local(0); local != index; ++local)
-        if (ffi_type *element = typical->ffi_.elements[local])
-            base += element->size;
-        else
-            @throw [NSException exceptionWithName:NSInvalidArgumentException reason:@"struct index out-of-range" userInfo:nil];
+        base += typical->ffi_.elements[local]->size;
+
+    return true;
 }
 
 static JSValueRef Struct_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) {
@@ -1374,19 +1379,11 @@ static JSValueRef Struct_getProperty(JSContextRef context, JSObjectRef object, J
         Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(object)));
         Type_privateData *typical(internal->type_);
 
-        size_t length;
-        const char *name(CYPoolCString(pool, property, &length));
-        double number(CYCastDouble(name, length));
-
-        if (std::isnan(number)) {
-            // XXX: implement!
-            return NULL;
-        }
-
         ssize_t index;
         uint8_t *base;
 
-        Index_(internal, number, index, base);
+        if (!Index_(pool, internal, property, index, base))
+            return NULL;
 
         return CYFromFFI(context, typical->type_.data.signature.elements[index].type, typical->ffi_.elements[index], base, object);
     } CYCatch
@@ -1398,19 +1395,11 @@ static bool Struct_setProperty(JSContextRef context, JSObjectRef object, JSStrin
         Struct_privateData *internal(reinterpret_cast<Struct_privateData *>(JSObjectGetPrivate(object)));
         Type_privateData *typical(internal->type_);
 
-        size_t length;
-        const char *name(CYPoolCString(pool, property, &length));
-        double number(CYCastDouble(name, length));
-
-        if (std::isnan(number)) {
-            // XXX: implement!
-            return false;
-        }
-
         ssize_t index;
         uint8_t *base;
 
-        Index_(internal, number, index, base);
+        if (!Index_(pool, internal, property, index, base))
+            return false;
 
         CYPoolFFI(NULL, context, typical->type_.data.signature.elements[index].type, typical->ffi_.elements[index], base, value);
         return true;
diff --git a/control b/control
index 95f40bd390bd306342398388122fd292d10a8da1..a072e6a15f7e65cb395978050a50bc389ff0550d 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: Development
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.65-1
+Version: 0.9.#-1
 Description: runtime execution server and disassembler
 Name: Cycript
 Depends: mobilesubstrate (>= 0.9.3005-1), readline, libffi
index a4c2478c9f7005abd8ea9f7c15221b49246bd658..69a8c158402e3b2f8c2835c6c9ca1431dea01872 100644 (file)
--- a/makefile
+++ b/makefile
@@ -9,6 +9,9 @@ package:
 flags := -mthumb -g3 -O0 -Wall -Werror -I. -fno-common
 flags += -F${PKG_ROOT}/System/Library/PrivateFrameworks
 
+svn := $(shell svnversion)
+deb := $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2 | sed -e 's/\#/$(svn)/')_iphoneos-arm.deb
+
 all: cycript libcycript.dylib libcycript.plist
 
 clean:
@@ -73,7 +76,7 @@ cycript: Application.o libcycript.dylib
 package: all
        rm -rf package
        mkdir -p package/DEBIAN
-       cp -a control package/DEBIAN
+       sed -e 's/#/$(svn)/' control >package/DEBIAN/control
        mkdir -p package/Library/MobileSubstrate/DynamicLibraries
        if [[ -e Settings.plist ]]; then \
            mkdir -p package/Library/PreferenceLoader/Preferences; \
@@ -87,10 +90,10 @@ package: all
        #ln -s /usr/lib/libcycript.dylib package/Library/MobileSubstrate/DynamicLibraries/Cycript.dylib
        cp -a cycript package/usr/bin
        cp -a libcycript.plist package/usr/lib
-       dpkg-deb -b package $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2)_iphoneos-arm.deb
+       dpkg-deb -b package $(deb)
 
 test: package
-       dpkg -i $(shell grep ^Package: control | cut -d ' ' -f 2-)_$(shell grep ^Version: control | cut -d ' ' -f 2)_iphoneos-arm.deb
+       dpkg -i $(deb)
        cycript test.cy
 
 .PHONY: all clean extra package