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

TODO: Support NSDecimal "primitive" type. #41

Open
trevorlinton opened this issue Aug 5, 2014 · 4 comments
Open

TODO: Support NSDecimal "primitive" type. #41

trevorlinton opened this issue Aug 5, 2014 · 4 comments

Comments

@trevorlinton
Copy link
Collaborator

This may be an issue in ref-struct, NSDecimal fails to parse into a struct (well it does, but size=0). It's signature looks like this (from method_getReturnTypes) {?=b8b4b1b1b18[8S]}

The definition in apples docs say:

typedef struct {
      signed int _exponent:8;
      unsigned int _length:4;
      unsigned int _isNegative:1;
      unsigned int _isCompact:1;
      unsigned int _reserved:18;
      unsigned short _mantissa[NSDecimalMaxSize];
} NSDecimal;

This is listed as a primitive in the apple docs.. :/

@TooTallNate
Copy link
Owner

Wait... I don't even get what's going on with the numbers on the right... Is that like manually setting the padding or something?

@trevorlinton
Copy link
Collaborator Author

@TooTallNate They're bit fields, it treats the signed/unsigned ints only with as many bits as specified after the colon. The structure is meant to fit in a register so it can be passed by value, but is an awkward version of a Float/Decimal that can be used for money that doesn't have specific types of overruns. Effectively we can just treat it as a structure...

@TooTallNate
Copy link
Owner

I need to implement this in ref-struct :)

@TooTallNate
Copy link
Owner

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

No branches or pull requests

2 participants