C YES true
C NO false
C nil null
+C NULL null
: applicationDidFinishLaunching: v12@0:4@8
F UIGetScreenImage @
+V UIAbbreviatedMonthDayFormat @
+V UIAbbreviatedWeekdayDateFormat @
+V UIAbbreviatedWeekdayFormat @
+V UIAbbreviatedWeekdayMonthDayFormat @
+V UIAbbreviatedWeekdayMonthDayMinutelessFormat @
+V UIAbbreviatedWeekdayMonthDayTimeFormat @
+V UIDatePickerDayFormat @
+V UIDatePickerMonthFormat @
+V UIDatePickerYearFormat @
+V UIHourFormat @
+V UIMinutelessTimeFormat @
+V UIMonthYearFormat @
+V UINoAMPMTimeFormat @
+V UIShortMonthDayFormat @
+V UIWeekdayAbbreviatedDateFormat @
+V UIWeekdayAbbreviatedNoYearDateFormat @
+V UIWeekdayFormat @
+V UIWeekdayNoYearDateFormat @
+
+F UIDateFormatStringForFormatType @@
+
F UIApplicationUseLegacyEvents vB
F UIKeyboardDisableAutomaticAppearance v
# Time Utilities
+F CFAbsoluteTimeGetCurrent {CFAbsoluteTime}
+
T CFAbsoluteTime {CFTimeInterval}
S CFGregorianDate "year"{SInt32}"month"{SInt8}"day"{SInt8}"hour"{SInt8}"minute"{SInt8}"second"{double}
S CFGregorianUnits "years"{SInt32}"months"{SInt32}"days"{SInt32}"hours"{SInt32}"minutes"{SInt32}"second"{double}
S CFAllocatorContext "version"{CFIndex}"info"^v"retain"{CFAllocatorRetainCallBack}"release"{CFAllocatorReleaseCallBack}"copyDescription"{CFAllocatorCopyDescriptionCallBack}"allocate"{CFAllocatorAllocateCallBack}"reallocate"{CFAllocatorReallocateCallBack}"deallocate"{CFAllocatorDeallocateCallBack}"preferredSize"{CFAllocatorPreferredSizeCallBack}
# CFAllocatorContext CFAllocatorContext
-T CFAllocatorRef ^r{__CFAllocator}
+T CFAllocatorRef @
+# CFAllocatorRef ^r{__CFAllocator}
V kCFAllocatorDefault {CFAllocatorRef}
V kCFAllocatorSystemDefault {CFAllocatorRef}
T CFArrayRef @
+# CFData
+
+F CFDataCreate {CFDataRef}{CFAllocatorRef}^r{UInt8}{CFIndex}
+F CFDataCreateCopy {CFDataRef}{CFAllocatorRef}{CFDataRef}
+F CFDataCreateWithBytesNoCopy {CFDataRef}{CFAllocatorRef}^r{UInt8}{CFIndex}{CFAllocatorRef}
+
+F CFDataGetBytePtr ^r{UInt8}{CFDataRef}
+F CFDataGetBytes v{CFDataRef}{CFRange}^{UInt8}
+F CFDataGetLength {CFIndex}{CFDataRef}
+
+F CFDataGetTypeID {CFTypeID}
+
+T CFDataRef @
+# CFDataRef ^r{__CFData}
+
+# CFDate
+
+F CFDateCompare {CFComparisonResult}{CFDateRef}{CFDateRef}^v
+F CFDateCreate {CFDateRef}{CFAllocatorRef}{CFAbsoluteTime}
+F CFDateGetAbsoluteTime {CFAbsoluteTime}{CFDateRef}
+F CFDateGetTimeIntervalSinceDate {CFTimeInterval}{CFDateRef}{CFDateRef}
+F CFDateGetTypeID {CFTypeID}
+
+T CFDateRef @
+# CFDateRef ^r{__CFDate}
+
+# CFDateFormatter
+
+F CFDateFormatterCreate {CFDateFormatterRef}{CFAllocatorRef}{CFLocaleRef}{CFDateFormatterStyle}{CFDateFormatterStyle}
+
+F CFDateFormatterSetFormat v{CFDateFormatterRef}{CFStringRef}
+F CFDateFormatterSetProperty v{CFDateFormatterRef}{CFStringRef}{CFTypeRef}
+
+F CFDateFormatterCreateDateFromString {CFDateRef}{CFAllocatorRef}{CFDateFormatterRef}{CFStringRef}^{CFRange}
+F CFDateFormatterGetAbsoluteTimeFromString {Boolean}{CFDateFormatterRef}{CFStringRef}^{CFRange}^{CFAbsoluteTime}
+
+F CFDateFormatterCreateStringWithAbsoluteTime {CFStringRef}{CFAllocatorRef}{CFDateFormatterRef}{CFAbsoluteTime}
+F CFDateFormatterCreateStringWithDate {CFStringRef}{CFAllocatorRef}{CFDateFormatterRef}{CFDateRef}
+F CFDateFormatterCreateDateFormatFromTemplate {CFStringRef}{CFAllocatorRef}{CFStringRef}{CFOptionFlags}{CFLocaleRef}
+
+F CFDateFormatterCopyProperty {CFTypeRef}{CFDateFormatterRef}{CFStringRef}
+F CFDateFormatterGetDateStyle {CFDateFormatterStyle}{CFDateFormatterRef}
+F CFDateFormatterGetFormat {CFStringRef}{CFDateFormatterRef}
+F CFDateFormatterGetLocale {CFLocaleRef}{CFDateFormatterRef}
+F CFDateFormatterGetTimeStyle {CFDateFormatterStyle}{CFDateFormatterRef}
+
+F CFDateFormatterGetTypeID {CFTypeID}
+
+T CFDateFormatterRef @
+# CFDateFormatterRef ^r{__CFDateFormatter}
+
+T CFDateFormatterStyle {CFIndex}
+
+C kCFDateFormatterNoStyle 0
+C kCFDateFormatterShortStyle 1
+C kCFDateFormatterMediumStyle 2
+C kCFDateFormatterLongStyle 3
+C kCFDateFormatterFullStyle 4
+
+V kCFDateFormatterIsLenient @
+V kCFDateFormatterTimeZone @
+V kCFDateFormatterCalendarName @
+V kCFDateFormatterDefaultFormat @
+
+V kCFDateFormatterTwoDigitStartDate @
+V kCFDateFormatterDefaultDate @
+V kCFDateFormatterCalendar @
+V kCFDateFormatterEraSymbols @
+V kCFDateFormatterMonthSymbols @
+V kCFDateFormatterShortMonthSymbols @
+V kCFDateFormatterWeekdaySymbols @
+V kCFDateFormatterShortWeekdaySymbols @
+V kCFDateFormatterAMSymbol @
+V kCFDateFormatterPMSymbol @
+
+V kCFDateFormatterLongEraSymbols @
+V kCFDateFormatterVeryShortMonthSymbols @
+V kCFDateFormatterStandaloneMonthSymbols @
+V kCFDateFormatterShortStandaloneMonthSymbols @
+V kCFDateFormatterVeryShortStandaloneMonthSymbols @
+V kCFDateFormatterVeryShortWeekdaySymbols @
+V kCFDateFormatterStandaloneWeekdaySymbols @
+V kCFDateFormatterShortStandaloneWeekdaySymbols @
+V kCFDateFormatterVeryShortStandaloneWeekdaySymbols @
+V kCFDateFormatterQuarterSymbols @
+V kCFDateFormatterShortQuarterSymbols @
+V kCFDateFormatterStandaloneQuarterSymbols @
+V kCFDateFormatterShortStandaloneQuarterSymbols @
+V kCFDateFormatterGregorianStartDate @
+
+V CFGregorianCalendar @
+
+# CFLocale
+
+F CFLocaleCopyCurrent {CFLocaleRef}
+F CFLocaleCreate {CFLocaleRef}{CFAllocatorRef}{CFStringRef}
+F CFLocaleCreateCopy {CFLocaleRef}{CFAllocatorRef}{CFLocaleRef}
+F CFLocaleGetSystem {CFLocaleRef}
+
+F CFLocaleCopyAvailableLocaleIdentifiers {CFArrayRef}
+
+F CFLocaleCopyISOCountryCodes {CFArrayRef}
+F CFLocaleCopyISOLanguageCodes {CFArrayRef}
+F CFLocaleCopyISOCurrencyCodes {CFArrayRef}
+F CFLocaleCopyCommonISOCurrencyCodes {CFArrayRef}
+
+F CFLocaleCopyPreferredLanguages {CFArrayRef}
+
+F CFLocaleCopyDisplayNameForPropertyValue {CFStringRef}{CFLocaleRef}{CFStringRef}{CFStringRef}
+F CFLocaleGetValue {CFTypeRef}{CFLocaleRef}{CFStringRef}
+F CFLocaleGetIdentifier {CFStringRef}{CFLocaleRef}
+
+F CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes {CFStringRef}{CFAllocatorRef}{LangCode}{RegionCode}
+F CFLocaleCreateCanonicalLanguageIdentifierFromString {CFStringRef}{CFAllocatorRef}{CFStringRef}
+F CFLocaleCreateCanonicalLocaleIdentifierFromString {CFStringRef}{CFAllocatorRef}{CFStringRef}
+F CFLocaleCreateComponentsFromLocaleIdentifier {CFDictionaryRef}{CFAllocatorRef}{CFStringRef}
+F CFLocaleCreateLocaleIdentifierFromComponents {CFStringRef}{CFAllocatorRef}{CFDictionaryRef}
+
+F CFLocaleGetTypeID {CFTypeID}
+
+F CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode {CFStringRef}{CFAllocatorRef}{uint32_t}
+F CFLocaleGetLanguageCharacterDirection {CFLocaleLanguageDirection}{CFStringRef}
+F CFLocaleGetLanguageLineDirection {CFLocaleLanguageDirection}{CFStringRef}
+F CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier {uint32_t}{CFStringRef}
+
+T CFLocaleRef @
+# CFLocaleRef ^r{__CFLocale}
+
+C kCFLocaleLanguageDirectionUnknown 0
+C kCFLocaleLanguageDirectionLeftToRight 1
+C kCFLocaleLanguageDirectionRightToLeft 2
+C kCFLocaleLanguageDirectionTopToBottom 3
+C kCFLocaleLanguageDirectionBottomToTop 4
+
+T CFLocaleLanguageDirection {CFIndex}
+
+V kCFLocaleMeasurementSystem @
+V kCFLocaleDecimalSeparator @
+V kCFLocaleGroupingSeparator @
+V kCFLocaleCurrencySymbol @
+V kCFLocaleCurrencyCode @
+
+V kCFLocaleIdentifier @
+V kCFLocaleLanguageCode @
+V kCFLocaleCountryCode @
+V kCFLocaleScriptCode @
+V kCFLocaleVariantCode @
+V kCFLocaleExemplarCharacterSet @
+V kCFLocaleCalendarIdentifier @
+V kCFLocaleCalendar @
+V kCFLocaleCollationIdentifier @
+V kCFLocaleUsesMetricSystem @
+
+V kCFGregorianCalendar @
+V kCFBuddhistCalendar @
+V kCFChineseCalendar @
+V kCFHebrewCalendar @
+V kCFIslamicCalendar @
+V kCFIslamicCivilCalendar @
+V kCFJapaneseCalendar @
+V kCFRepublicOfChinaCalendar @
+V kCFPersianCalendar @
+V kCFIndianCalendar @
+V kCFISO8601Calendar @
+
+V kCFLocaleCurrentLocaleDidChangeNotificatio @
+
# CFRunLoop
F CFRunLoopGetCurrent {CFRunLoopRef}
T CFHashCode L
T CFTypeID L
-# technically ^v
+
T CFTypeRef @
+# CFTypeRef ^rv
# Private
if (debug)
std::cout << code << std::endl;
+ code = "with(Cycript.all){" + code + "}";
Run(client, code, fout, expand);
}
CYThrow(context, exception);
}
-void CYSetProperty(JSContextRef context, JSObjectRef object, JSStringRef name, JSValueRef (*callback)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *), JSPropertyAttributes attributes = kJSPropertyAttributeNone) {
+void CYSetProperty(JSContextRef context, JSObjectRef object, JSStringRef name, JSValueRef (*callback)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *), JSPropertyAttributes attributes) {
CYSetProperty(context, object, name, JSObjectMakeFunctionWithCallback(context, name, callback), attributes);
}
/* }}} */
}
/* }}} */
+static JSClassRef All_;
static JSClassRef Context_;
static JSClassRef Functor_;
static JSClassRef Global_;
static JSClassRef Pointer_;
-static JSClassRef Runtime_;
static JSClassRef Struct_;
JSStringRef Array_s;
return dlsym(RTLD_DEFAULT, name);
}
-static JSValueRef Runtime_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
+static JSValueRef All_getProperty(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { CYTry {
+ JSObjectRef global(CYGetGlobalObject(context));
+ JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript"))));
+ if (JSValueRef value = CYGetProperty(context, cycript, property))
+ if (!JSValueIsUndefined(context, value))
+ return value;
+
CYPool pool;
CYUTF8String name(CYPoolUTF8String(pool, context, property));
JSClassDefinition definition;
+ definition = kJSClassDefinitionEmpty;
+ definition.className = "All";
+ definition.getProperty = &All_getProperty;
+ All_ = JSClassCreate(&definition);
+
definition = kJSClassDefinitionEmpty;
definition.className = "Context";
definition.finalize = &CYFinalize;
definition.finalize = &CYFinalize;
Type_privateData::Class_ = JSClassCreate(&definition);
- definition = kJSClassDefinitionEmpty;
- definition.className = "Runtime";
- definition.getProperty = &Runtime_getProperty;
- Runtime_ = JSClassCreate(&definition);
-
definition = kJSClassDefinitionEmpty;
//definition.getProperty = &Global_getProperty;
Global_ = JSClassCreate(&definition);
return reinterpret_cast<Context *>(JSObjectGetPrivate(CYCastJSObject(context, CYGetProperty(context, CYGetGlobalObject(context), cy_s))))->context_;
}
-void CYSetupContext(JSGlobalContextRef context) {
+extern "C" void CYSetupContext(JSGlobalContextRef context) {
+ CYInitialize();
+
JSObjectRef global(CYGetGlobalObject(context));
JSObjectRef cy(JSObjectMake(context, Context_, new Context(context)));
CYSetProperty(context, global, cy_s, cy, kJSPropertyAttributeDontEnum);
+/* Cache Globals {{{ */
JSObjectRef Array(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Array"))));
CYSetProperty(context, cy, CYJSString("Array"), Array);
JSObjectRef String(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("String"))));
CYSetProperty(context, cy, CYJSString("String"), String);
-
- JSObjectSetPrototype(context, global, JSObjectMake(context, Runtime_, NULL));
+/* }}} */
CYSetProperty(context, Array_prototype, toCYON_s, &Array_callAsFunction_toCYON, kJSPropertyAttributeDontEnum);
+ JSObjectRef cycript(JSObjectMake(context, NULL, NULL));
+ CYSetProperty(context, global, CYJSString("Cycript"), cycript);
+ CYSetProperty(context, cycript, CYJSString("gc"), &Cycript_gc_callAsFunction);
+
JSObjectRef Functor(JSObjectMakeConstructor(context, Functor_, &Functor_new));
JSObjectSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Functor, prototype_s)), Function_prototype);
- CYSetProperty(context, global, CYJSString("Functor"), Functor);
+ CYSetProperty(context, cycript, CYJSString("Functor"), Functor);
- CYSetProperty(context, global, CYJSString("Pointer"), JSObjectMakeConstructor(context, Pointer_, &Pointer_new));
- CYSetProperty(context, global, CYJSString("Type"), JSObjectMakeConstructor(context, Type_privateData::Class_, &Type_new));
+ CYSetProperty(context, cycript, CYJSString("Pointer"), JSObjectMakeConstructor(context, Pointer_, &Pointer_new));
+ CYSetProperty(context, cycript, CYJSString("Type"), JSObjectMakeConstructor(context, Type_privateData::Class_, &Type_new));
- JSObjectRef cycript(JSObjectMake(context, NULL, NULL));
- CYSetProperty(context, global, CYJSString("Cycript"), cycript);
- CYSetProperty(context, cycript, CYJSString("gc"), &Cycript_gc_callAsFunction);
+ JSObjectRef all(JSObjectMake(context, All_, NULL));
+ CYSetProperty(context, cycript, CYJSString("all"), all);
CYSetProperty(context, global, CYJSString("$cyq"), &$cyq);
if (context_ == NULL) {
context_ = JSGlobalContextCreate(Global_);
CYSetupContext(context_);
+ JSObjectSetPrototype(context_, CYGetGlobalObject(context_), JSObjectMake(context_, All_, NULL));
}
return context_;
void CYObjectiveC_SetupContext(JSContextRef context) { CYPoolTry {
JSObjectRef global(CYGetGlobalObject(context));
JSObjectRef cy(CYCastJSObject(context, CYGetProperty(context, global, cy_s)));
+ JSObjectRef cycript(CYCastJSObject(context, CYGetProperty(context, global, CYJSString("Cycript"))));
+ JSObjectRef all(CYCastJSObject(context, CYGetProperty(context, cycript, CYJSString("all"))));
JSObjectRef ObjectiveC(JSObjectMake(context, NULL, NULL));
- CYSetProperty(context, global, CYJSString("ObjectiveC"), ObjectiveC);
+ CYSetProperty(context, cycript, CYJSString("ObjectiveC"), ObjectiveC);
CYSetProperty(context, ObjectiveC, CYJSString("classes"), JSObjectMake(context, ObjectiveC_Classes_, NULL));
CYSetProperty(context, ObjectiveC, CYJSString("protocols"), JSObjectMake(context, ObjectiveC_Protocols_, NULL));
JSObjectRef Instance_prototype(CYCastJSObject(context, CYGetProperty(context, Instance, prototype_s)));
CYSetProperty(context, cy, CYJSString("Instance_prototype"), Instance_prototype);
- CYSetProperty(context, global, CYJSString("Instance"), Instance);
- CYSetProperty(context, global, CYJSString("Selector"), Selector);
- CYSetProperty(context, global, CYJSString("Super"), Super);
+ CYSetProperty(context, cycript, CYJSString("Instance"), Instance);
+ CYSetProperty(context, cycript, CYJSString("Selector"), Selector);
+ CYSetProperty(context, cycript, CYJSString("Super"), Super);
#if defined(__APPLE__) && defined(__arm__)
- CYSetProperty(context, global, CYJSString("objc_registerClassPair"), JSObjectMakeFunctionWithCallback(context, CYJSString("objc_registerClassPair"), &objc_registerClassPair_));
+ CYSetProperty(context, all, CYJSString("objc_registerClassPair"), &objc_registerClassPair_);
#endif
- CYSetProperty(context, global, CYJSString("objc_msgSend"), JSObjectMakeFunctionWithCallback(context, CYJSString("objc_msgSend"), &$objc_msgSend));
+ CYSetProperty(context, all, CYJSString("objc_msgSend"), &$objc_msgSend);
JSObjectRef Function_prototype(CYGetCachedObject(context, CYJSString("Function_prototype")));
JSObjectSetPrototype(context, CYCastJSObject(context, CYGetProperty(context, Message, prototype_s)), Function_prototype);
CYExpression *CYSendDirect::Replace(CYContext &context) {
std::ostringstream name;
CYArgument **argument(&arguments_);
+ CYSelectorPart *selector(NULL), *current(NULL);
while (*argument != NULL) {
if ((*argument)->name_ != NULL) {
- name << *(*argument)->name_;
+ CYSelectorPart *part($ CYSelectorPart((*argument)->name_, (*argument)->value_ != NULL));
+ if (selector == NULL)
+ selector = part;
+ if (current != NULL)
+ current->SetNext(part);
+ current = part;
(*argument)->name_ = NULL;
- if ((*argument)->value_ != NULL)
- name << ':';
}
if ((*argument)->value_ == NULL)
argument = &(*argument)->next_;
}
- SEL sel(sel_registerName(name.str().c_str()));
- double address(static_cast<double>(reinterpret_cast<uintptr_t>(sel)));
-
- return $C2($V("objc_msgSend"), self_, $D(address), arguments_);
+ return $C2($V("objc_msgSend"), self_, ($ CYSelector(selector))->Replace(context), arguments_);
}
CYExpression *CYSendSuper::Replace(CYContext &context) {
CYWord *name_;
bool value_;
- CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next) :
+ CYSelectorPart(CYWord *name, bool value, CYSelectorPart *next = NULL) :
CYNext<CYSelectorPart>(next),
name_(name),
value_(value)
apr_pool_t *CYGetGlobalPool();
JSObjectRef CYGetGlobalObject(JSContextRef context);
-void CYSetupContext(JSGlobalContextRef context);
+extern "C" void CYSetupContext(JSGlobalContextRef context);
const char *CYExecute(apr_pool_t *pool, const char *code);
void CYSetArgs(int argc, const char *argv[]);
JSValueRef CYGetProperty(JSContextRef context, JSObjectRef object, size_t index);
JSValueRef CYGetProperty(JSContextRef context, JSObjectRef object, JSStringRef name);
+
void CYSetProperty(JSContextRef context, JSObjectRef object, size_t index, JSValueRef value);
void CYSetProperty(JSContextRef context, JSObjectRef object, JSStringRef name, JSValueRef value, JSPropertyAttributes attributes = kJSPropertyAttributeNone);
+void CYSetProperty(JSContextRef context, JSObjectRef object, JSStringRef name, JSValueRef (*callback)(JSContextRef, JSObjectRef, JSObjectRef, size_t, const JSValueRef[], JSValueRef *), JSPropertyAttributes attributes = kJSPropertyAttributeNone);
JSObjectRef CYGetCachedObject(JSContextRef context, JSStringRef name);