From 4e8c99fb09f51a009d1091d0a1a01ca73d7d4c85 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 9 Oct 2009 10:33:00 +0000 Subject: [PATCH] Output all message declarations (not just one or the first and last), flesh out some UIKit bridging, fix Instance toString() memory allocation, and copy all structure fields (not just the last one onto the first element). --- Bridge.def | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Cycript.y | 2 +- Library.mm | 11 ++--- Output.cpp | 2 + 4 files changed, 125 insertions(+), 7 deletions(-) diff --git a/Bridge.def b/Bridge.def index a73de5f..b42dc47 100644 --- a/Bridge.def +++ b/Bridge.def @@ -2,7 +2,7 @@ C YES true C NO false C nil null -: applicationDidFinishLaunching: v@:@ +: applicationDidFinishLaunching: v12@0:4@8 S CGPoint "x"f"y"f S CGRect "origin"{CGPoint}"size"{CGSize} @@ -99,6 +99,121 @@ F sel_registerName :* f UIKit +# UITableView + +C UITableViewStylePlain 0 +C UITableViewStyleGrouped 1 + +C UITableViewScrollPositionNone 0 +C UITableViewScrollPositionTop 1 +C UITableViewScrollPositionMiddle 2 +C UITableViewScrollPositionBottom 3 + +C UITableViewRowAnimationFade 0 +C UITableViewRowAnimationRight 1 +C UITableViewRowAnimationLeft 2 +C UITableViewRowAnimationTop 3 +C UITableViewRowAnimationTop 4 +C UITableViewRowAnimationNone 5 + +V UITableViewIndexSearch @ + +# UITableViewCell + +C UITableViewCellStyleDefault 0 +C UITableViewCellStyleValue1 1 +C UITableViewCellStyleValue2 2 +C UITableViewCellStyleSubtitle 3 + +C UITableViewCellStateDefaultMask 0 +C UITableViewCellStateEditingMask (1<<0) +C UITableViewCellStateShowingDeleteConfirmationMask (1<<1) + +C UITableViewCellSelectionStyleNone 0 +C UITableViewCellSelectionStyleBlue 1 +C UITableViewCellSelectionStyleGray 2 + +C UITableViewCellEditingStyleNone 0 +C UITableViewCellEditingStyleDelete 1 +C UITableViewCellEditingStyleInsert 2 + +C UITableViewCellAccessoryNone 0 +C UITableViewCellAccessoryDisclosureIndicator 1 +C UITableViewCellAccessoryDetailDisclosureButton 2 +C UITableViewCellAccessoryCheckmark 3 + +C UITableViewCellSeparatorStyleNone 0 +C UITableViewCellSeparatorStyleSingleLine 1 + +# UITableViewDataSource + +: tableView:numberOfRowsInSection: i16@0:4@8i12 +: numberOfSectionsInTableView: i12@0:4@8 +: tableView:cellForRowAtIndexPath: @16@0:4@8@12 +: sectionIndexTitlesForTableView: @12@0:4@8 +: tableView:sectionForSectionIndexTitle:atIndex: i20@0:4@8@12i16 +: tableView:titleForHeaderInSection: @16@0:4@8i12 +: tableView:titleForFooterInSection: @16@0:4@8i12 + +: tableView:commitEditingStyle:forRowAtIndexPath: v20@0:4@8i12@16 +: tableView:canEditRowAtIndexPath: B16@0:4@8@12 + +: tableView:canMoveRowAtIndexPath: B16@0:4@8@12 +: tableView:moveRowAtIndexPath:toIndexPath: v20@0:4@8@12@16 + +# UIView + +C UIViewAnimationCurveEaseInOut 0 +C UIViewAnimationCurveEaseIn 1 +C UIViewAnimationCurveEaseOut 2 +C UIViewAnimationCurveLinear 3 + +C UIViewContentModeScaleToFill 0 +C UIViewContentModeScaleAspectFit 1 +C UIViewContentModeScaleAspectFill 2 +C UIViewContentModeRedraw 3 +C UIViewContentModeCenter 4 +C UIViewContentModeTop 5 +C UIViewContentModeBottom 6 +C UIViewContentModeLeft 7 +C UIViewContentModeRight 8 +C UIViewContentModeTopLeft 9 +C UIViewContentModeTopRight 10 +C UIViewContentModeBottomLeft 11 +C UIViewContentModeBottomRight 12 + +C UIViewAutoresizingNone 0 +C UIViewAutoresizingFlexibleLeftMargin (1<<0) +C UIViewAutoresizingFlexibleWidth (1<<1) +C UIViewAutoresizingFlexibleRightMargin (1<<2) +C UIViewAutoresizingFlexibleTopMargin (1<<3) +C UIViewAutoresizingFlexibleHeight (1<<4) +C UIViewAutoresizingFlexibleBottomMargin (1<<5) + +C UIViewAnimationTransitionNone 0 +C UIViewAnimationTransitionFlipFromLeft 1 +C UIViewAnimationTransitionFlipFromRight 2 +C UIViewAnimationTransitionCurlUp 3 +C UIViewAnimationTransitionCurlDown 4 + +# UIWebView + +C UIWebViewNavigationTypeLinkClicked 0 +C UIWebViewNavigationTypeFormSubmitted 1 +C UIWebViewNavigationTypeBackForward 2 +C UIWebViewNavigationTypeReload 3 +C UIWebViewNavigationTypeFormResubmitted 4 +C UIWebViewNavigationTypeOther 5 + +# UIWebViewDelegate + +: webView:shouldStartLoadWithRequest:navigationType: B20@0:4@8@12I16 +: webViewDidStartLoad: v12@0:4@8 +: webViewDidFinishLoad: v12@0:4@8 +: webView:didFailLoadWithError: v16@0:4@8@12 + +# Miscellaneous + F UIApplicationUseLegacyEvents vB F UIAccessibilityPostNotification vI@ diff --git a/Cycript.y b/Cycript.y index e51a0ec..cef2a42 100644 --- a/Cycript.y +++ b/Cycript.y @@ -1184,7 +1184,7 @@ ClassMessageDeclaration ; ClassMessageDeclarationListOpt - : ClassMessageDeclarationListOpt ClassMessageDeclaration { if ($1) { $1->SetNext($2); $$ = $1; } else $$ = $2; } + : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; } | { $$ = NULL; } ; diff --git a/Library.mm b/Library.mm index f12f6d7..e5a2082 100644 --- a/Library.mm +++ b/Library.mm @@ -356,7 +356,6 @@ JSObjectRef CYMakeStruct(JSContextRef context, void *data, sig::Type *type, ffi_ internal->value_ = copy; } - NSLog(@"%s", type->name); return JSObjectMake(context, Struct_, internal); } @@ -1264,8 +1263,11 @@ void CYPoolFFI(apr_pool_t *pool, JSContextRef context, sig::Type *type, ffi_type uint8_t *base(reinterpret_cast(data)); bool aggregate(JSValueIsObject(context, value)); for (size_t index(0); index != type->data.signature.count; ++index) { + ffi_type *element(ffi->elements[index]); JSValueRef rhs(aggregate ? CYGetProperty(context, (JSObjectRef) value, index) : value); - CYPoolFFI(pool, context, type->data.signature.elements[index].type, ffi->elements[index], base, rhs); + CYPoolFFI(pool, context, type->data.signature.elements[index].type, element, base, rhs); + // XXX: alignment? + base += element->size; } } break; @@ -1635,10 +1637,9 @@ static JSValueRef Pointer_callAsFunction_valueOf(JSContextRef context, JSObjectR static JSValueRef Instance_callAsFunction_toString(JSContextRef context, JSObjectRef object, JSObjectRef _this, size_t count, const JSValueRef arguments[], JSValueRef *exception) { CYTry { Instance_privateData *data(reinterpret_cast(JSObjectGetPrivate(_this))); - NSString *description; CYPoolTry { - description = [data->GetValue() description]; + CYPoolTry { + return CYCastJSValue(context, CYJSString([data->GetValue() description])); } CYPoolCatch(NULL) - return CYCastJSValue(context, CYJSString(description)); } CYCatch } diff --git a/Output.cpp b/Output.cpp index 5e0d6ef..7eee678 100644 --- a/Output.cpp +++ b/Output.cpp @@ -353,6 +353,8 @@ void CYMember::Output(std::ostream &out, CYFlags flags) const { } void CYMessage::Output(std::ostream &out) const { + if (next_ != NULL) + next_->Output(out); out << "$cyn=new Selector(\""; for (CYMessageParameter *parameter(parameter_); parameter != NULL; parameter = parameter->next_) if (parameter->tag_ != NULL) { -- 2.47.2