Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose compile time constants in metadata as JSCode #279

Closed
ivanbuhov opened this issue Aug 24, 2015 · 5 comments
Closed

Expose compile time constants in metadata as JSCode #279

ivanbuhov opened this issue Aug 24, 2015 · 5 comments
Assignees
Milestone

Comments

@ivanbuhov
Copy link
Contributor

All compile time constants are exposed as variables and we are trying to retrive their values at runtime. This crashes the runtime because these variables doesn't exist at runtime. Example of such variable is NSNotFound in iOS 9:

static const NSInteger NSNotFound = NSIntegerMax;

A possible solution is in metadata generation process to retrieve the value of the variable and save it as JSCodeMeta. This way we will no longer search for non-existing values at runtime.

It can be tricky to handle all variable types e.g. numerics, string, char, structs etc.

@jasssonpet
Copy link
Contributor

Here is an incomplete list of some static const variables :)

static const CFIndex kCFNotFound = -1;
static const CGFontIndex kCGFontIndexInvalid = ((1 << 16) - 1);
static const CGFontIndex kCGFontIndexMax = ((1 << 16) - 2);
static const CGFontIndex kCGGlyphMax = kCGFontIndexMax;
static const Float64 kAudioStreamAnyRate = 0.0;
static const MIDIObjectType kMIDIObjectType_ExternalMask = (MIDIObjectType)0x10;
static const NSExpressionType NSFetchRequestExpressionType = (NSExpressionType)50;
static const NSInteger NSNotFound = NSIntegerMax;
static const NSInteger NSOperationQueueDefaultMaxConcurrentOperationCount = -1;
static const NSPointerFunctionsOptions NSHashTableCopyIn = NSPointerFunctionsCopyIn;
static const NSPointerFunctionsOptions NSHashTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality;
static const NSPointerFunctionsOptions NSHashTableStrongMemory = NSPointerFunctionsStrongMemory;
static const NSPointerFunctionsOptions NSHashTableWeakMemory = NSPointerFunctionsWeakMemory;
static const NSPointerFunctionsOptions NSHashTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory;
static const NSPointerFunctionsOptions NSMapTableCopyIn = NSPointerFunctionsCopyIn;
static const NSPointerFunctionsOptions NSMapTableObjectPointerPersonality = NSPointerFunctionsObjectPointerPersonality;
static const NSPointerFunctionsOptions NSMapTableStrongMemory = NSPointerFunctionsStrongMemory;
static const NSPointerFunctionsOptions NSMapTableWeakMemory = NSPointerFunctionsWeakMemory;
static const NSPointerFunctionsOptions NSMapTableZeroingWeakMemory = NSPointerFunctionsZeroingWeakMemory;
static const NSUInteger NSUndoCloseGroupingRunLoopOrdering = 350000;
static const PHAssetResourceDataRequestID PHInvalidAssetResourceDataRequestID = 0;
static const PHImageRequestID PHInvalidImageRequestID = 0;
static const UILayoutPriority UILayoutPriorityDefaultHigh = 750;
static const UILayoutPriority UILayoutPriorityDefaultLow = 250;
static const UILayoutPriority UILayoutPriorityFittingSizeLevel = 50;
static const UILayoutPriority UILayoutPriorityRequired = 1000;

@ivanbuhov
Copy link
Contributor Author

@jasssonpet very good regex skills, your list is missing only 2 constants ;)

@jasssonpet
Copy link
Contributor

Are these in usr/include? I didn't search there.

@ivanbuhov
Copy link
Contributor Author

Yes, the constants are OS_ACTIVITY_FLAG_DEFAULT and OS_ACTIVITY_FLAG_DETACHED from usr/include/os/activity.h.

@ivanbuhov
Copy link
Contributor Author

Fixed: #329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants