From 9561f209ba7d08b95e2bd3b86b6338bd2537ea55 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sun, 15 Nov 2009 20:26:16 +0000 Subject: [PATCH] Fixed the #.prop case, made invalid bridging throw instead of assert, and added a ton of time/calendar/abc bridging. --- Bridge.def | 79 +++++++++++++++++++++++++++++++++++++++++++++++++---- Library.cpp | 2 +- Output.cpp | 8 ++++-- Parser.hpp | 1 + todo.txt | 1 + 5 files changed, 83 insertions(+), 8 deletions(-) diff --git a/Bridge.def b/Bridge.def index 1332e44..a5852b9 100644 --- a/Bridge.def +++ b/Bridge.def @@ -11,6 +11,7 @@ T short s T int i T long l +T byte C T uint I T ulong L T ushort S @@ -21,7 +22,13 @@ T float f T double d T Boolean B + +T SInt8 {char} +T UInt8 {byte} +T SInt16 {short} +T UInt16 {ushort} T SInt32 {int} +T UInt32 {uint} S CGPoint "x"f"y"f S CGRect "origin"{CGPoint}"size"{CGSize} @@ -441,6 +448,17 @@ V UIWebViewScalesToFitScale f f AddressBook +# Private + +F CPPhoneNumberCopyNetworkCountryCode @ +F ABCGetSharedAddressBook @ +F ABCFindPersonMatchingPhoneNumberWithCountry @@@@^i^i +F ABCRecordCopyCompositeName @@ +F ABCFindPersonMatchingPhoneNumber @@@^i^i +F ABCCopyLocalizedPropertyOrLabel @i + +# Public + F ABAddressBookAddRecord B@@^@ F ABAddressBookCopyArrayOfAllGroups @@ F ABAddressBookCopyArrayOfAllPeople @@ @@ -603,6 +621,15 @@ V kABWorkLabel @ V kABHomeLabel @ V kABOtherLabel @ +f Calendar + +F CalDatabaseCopyEventOccurrencesInDateRange {CFArrayRef}^{CalDatabase}^{CalFilter}{CFGregorianDate}{CFGregorianDate}{CFTimeZoneRef} +F CalFilterCreateWithDatabase ^{CalFilter}^{CalDatabase} + +F CalEventOccurrenceGetEvent @@ +F CalEventCopySummary @@ +F CalEventOccurrenceGetDate I@ + 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} @@ -783,7 +810,15 @@ F CFRangeMake {CFRange}{CFIndex}{CFIndex} # Time Utilities +F CFAbsoluteTimeAddGregorianUnits {CFAbsoluteTime}{CFAbsoluteTime}{CFTimeZoneRef}{CFGregorianUnits} F CFAbsoluteTimeGetCurrent {CFAbsoluteTime} +F CFAbsoluteTimeGetDayOfWeek {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} +F CFAbsoluteTimeGetDayOfYear {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} +F CFAbsoluteTimeGetDifferenceAsGregorianUnits {CFGregorianUnits}{CFAbsoluteTime}{CFAbsoluteTime}{CFTimeZoneRef}{CFOptionFlags} +F CFAbsoluteTimeGetGregorianDate {CFGregorianDate}{CFAbsoluteTime}{CFTimeZoneRef} +F CFAbsoluteTimeGetWeekOfYear {SInt32}{CFAbsoluteTime}{CFTimeZoneRef} +F CFGregorianDateGetAbsoluteTime {CFAbsoluteTime}{CFGregorianDate}{CFTimeZoneRef} +F CFGregorianDateIsValid {Boolean}{CFGregorianDate}{CFOptionFlags} T CFAbsoluteTime {CFTimeInterval} S CFGregorianDate "year"{SInt32}"month"{SInt8}"day"{SInt8}"hour"{SInt8}"minute"{SInt8}"second"{double} @@ -1132,6 +1167,43 @@ T CFRunLoopTimerRef @ T CFStringRef @ +# CFTimeZone + +F CFTimeZoneCreateWithName {CFTimeZoneRef}{CFAllocatorRef}{CFStringRef}{Boolean} +F CFTimeZoneCreateWithTimeIntervalFromGMT {CFTimeZoneRef}{CFAllocatorRef}{CFTimeInterval} +F CFTimeZoneCreate {CFTimeZoneRef}{CFAllocatorRef}{CFStringRef}{CFDataRef} + +F CFTimeZoneCopyAbbreviationDictionary {CFDictionaryRef} +F CFTimeZoneCopyAbbreviation {CFStringRef}{CFTimeZoneRef}{CFAbsoluteTime} +F CFTimeZoneCopyDefault {CFTimeZoneRef} +F CFTimeZoneCopySystem {CFTimeZoneRef} +F CFTimeZoneSetDefault v{CFTimeZoneRef} +F CFTimeZoneCopyKnownNames {CFArrayRef} +F CFTimeZoneResetSystem v +F CFTimeZoneSetAbbreviationDictionary v{CFDictionaryRef} + +F CFTimeZoneGetName {CFStringRef}{CFTimeZoneRef} +F CFTimeZoneCopyLocalizedName {CFStringRef}{CFTimeZoneRef}{CFTimeZoneNameStyle}{CFLocaleRef} +F CFTimeZoneGetSecondsFromGMT {CFTimeInterval}{CFTimeZoneRef}{CFAbsoluteTime} +F CFTimeZoneGetData {CFDataRef}{CFTimeZoneRef} + +F CFTimeZoneIsDaylightSavingTime {Boolean}{CFTimeZoneRef}{CFAbsoluteTime} +F CFTimeZoneGetDaylightSavingTimeOffset {CFTimeInterval}{CFTimeZoneRef}{CFAbsoluteTime} +F CFTimeZoneGetNextDaylightSavingTimeTransition {CFAbsoluteTime}{CFTimeZoneRef}{CFAbsoluteTime} + +F CFTimeZoneGetTypeID {CFTypeID} + +T CFTimeZoneNameStyle {CFIndex} +T CFTimeZoneRef @ +# CFTimeZoneRef ^r{__CFTimeZoneRef} + +V kCFTimeZoneSystemTimeZoneDidChangeNotification {CFStringRef} + +C kCFTimeZoneNameStyleStandard 0 +C kCFTimeZoneNameStyleShortStandard 1 +C kCFTimeZoneNameStyleDaylightSaving 2 +C kCFTimeZoneNameStyleShortDaylightSaving 3 + # CFType F CFGetAllocator {CFAllocatorRef}{CFTypeRef} @@ -1280,9 +1352,6 @@ f CoreTelephony # most of this is garbage -F _CTCallCopyAllMissedCallsAfterRowID {CFArrayRef}{CFAllocatorRef}l -F _CTCallCopyAllMissedCallsSince {CFArrayRef}{CFAllocatorRef}{CFDateRef} - T CTCallRef @ # CTCallAddressBlocked @@ -1294,8 +1363,8 @@ T CTCallRef @ F CTCallCopyAddress {CFStringRef}{CFAllocatorRef}{CTCallRef} # CTCallCopyAllCallsSince # CTCallCopyAllIncomingCallsSince -# CTCallCopyAllMissedCallsAfterRowID -# CTCallCopyAllMissedCallsSince +F CTCallCopyAllMissedCallsAfterRowID {CFArrayRef}{CFAllocatorRef}l +F CTCallCopyAllMissedCallsSince {CFArrayRef}{CFAllocatorRef}{CFDateRef} # CTCallCopyAllOutgoingCallsSince # CTCallCopyName # CTCallCopyUUID diff --git a/Library.cpp b/Library.cpp index f95cf9e..48062d4 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1194,7 +1194,7 @@ static JSValueRef All_getProperty(JSContextRef context, JSObjectRef object, JSSt switch (mode) { default: - _assert(false); + CYThrow("invalid mode from bridge table: %d", mode); case -1: return NULL; diff --git a/Output.cpp b/Output.cpp index 6a60504..9ffc4f6 100644 --- a/Output.cpp +++ b/Output.cpp @@ -59,7 +59,7 @@ _finline CYFlags &operator |=(CYFlags &lhs, CYFlags rhs) { } _finline CYFlags CYLeft(CYFlags flags) { - return flags & ~CYNoDangle; + return flags & ~(CYNoDangle | CYNoInteger); } _finline CYFlags CYRight(CYFlags flags) { @@ -513,7 +513,11 @@ void CYNull::Output(CYOutput &out, CYFlags flags) const { void CYNumber::Output(CYOutput &out, CYFlags flags) const { std::ostringstream str; CYNumerify(str, Value()); - out << str.str().c_str(); + std::string value(str.str()); + out << value.c_str(); + // XXX: this should probably also handle hex conversions and exponents + if ((flags & CYNoInteger) != 0 && value.find('.') == std::string::npos) + out << '.'; } void CYNumber::PropertyName(CYOutput &out) const { diff --git a/Parser.hpp b/Parser.hpp index bac656d..a76faaa 100644 --- a/Parser.hpp +++ b/Parser.hpp @@ -141,6 +141,7 @@ enum CYFlags { CYNoCall = (1 << 3), CYNoRightHand = (1 << 4), CYNoDangle = (1 << 5), + CYNoInteger = (1 << 6), CYNoBF = (CYNoBrace | CYNoFunction), }; diff --git a/todo.txt b/todo.txt index 298b517..14c0fb7 100644 --- a/todo.txt +++ b/todo.txt @@ -23,3 +23,4 @@ figure out what to do about global context refs: I really really want to retain the concept of NULL pooling is entirely incorrect and sad... bad... evil... need to work on this... really NSArray's .toString() and .toLocaleString() fail hard, as Array.prototype.to*String are Array-specific (4).toString() is legal, but I'm stripping the ()'s somehow in the serializer +applyOnMainThread, when done at console, loops the cyonifier -- 2.45.2