-
Notifications
You must be signed in to change notification settings - Fork 49
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
Investigate further Encoding
s
#68
Comments
Apple's objc4 defines (using GNUStep's ordering and grouping): #define _C_ID '@'
#define _C_CLASS '#'
#define _C_SEL ':'
#define _C_BOOL 'B'
#define _C_CHR 'c'
#define _C_UCHR 'C'
#define _C_SHT 's'
#define _C_USHT 'S'
#define _C_INT 'i'
#define _C_UINT 'I'
#define _C_LNG 'l'
#define _C_ULNG 'L'
#define _C_LNG_LNG 'q'
#define _C_ULNG_LNG 'Q'
#define _C_FLT 'f'
#define _C_DBL 'd'
#define _C_BFLD 'b'
#define _C_VOID 'v'
#define _C_UNDEF '?'
#define _C_PTR '^'
#define _C_CHARPTR '*'
#define _C_ATOM '%'
#define _C_ARY_B '['
#define _C_ARY_E ']'
#define _C_UNION_B '('
#define _C_UNION_E ')'
#define _C_STRUCT_B '{'
#define _C_STRUCT_E '}'
#define _C_VECTOR '!'
#define _C_CONST 'r' GNUStep's libobjc2 additionally defines: #define _C_COMPLEX 'j'
#define _C_IN 'n'
#define _C_INOUT 'N'
#define _C_OUT 'o'
#define _C_BYCOPY 'O'
#define _C_ONEWAY 'V' And GCC's libobjc furthermore define: #define _C_BYREF 'R'
#define _C_GCINVISIBLE '|' GCC's notes on
|
This comment has been minimized.
This comment has been minimized.
Just found that the following methods:
All fail in counting properly in Apple's runtime (though GNU's does this fine, and I would guess GNUStep's as well) when using For example, the following produces wrong results: #import <objc/runtime.h>
#import <Foundation/Foundation.h>
@interface TestObject : NSObject
- (_Complex float)myMethod;
@end
@implementation TestObject
- (_Complex float)myMethod {
return 0.0;
}
@end
int main (int argc, const char * argv[]) {
Method m = class_getInstanceMethod([TestObject class], @selector(myMethod));
NSLog(@"Encoding %s", method_getTypeEncoding(m));
NSLog(@"Return %s", method_copyReturnType(m));
NSLog(@"Argument count %i", method_getNumberOfArguments(m));
NSLog(@"self %s", method_copyArgumentType(m, 0));
NSLog(@"_cmd %s", method_copyArgumentType(m, 1));
NSLog(@"Arg #1 %s", method_copyArgumentType(m, 2));
return 0;
} Outputs:
Vs. the expected:
In effect, this means that Also, |
I tried adding unsafe impl<T: RefEncode + ?Sized> Encode for *const T {
const ENCODING: Encoding<'static> = Encoding::Const(&T::ENCODING_REF);
}
unsafe impl<'a, T: RefEncode + ?Sized> Encode for &'a T {
const ENCODING: Encoding<'static> = Encoding::Const(&T::ENCODING_REF);
}
unsafe impl<'a, T: RefEncode + ?Sized> Encode for Option<&'a T> {
const ENCODING: Encoding<'static> = Encoding::Const(&T::ENCODING_REF);
} But this doesn't really help with debugging:
In short, users would have to coerce their references to
|
Also: Bitfields are encoded differently on GNUStep (future compatibility hazard avoided in #138). To achieve perfect compatibility, we would need a |
#412 resolves the bitfield problems, and moves the remaining items in here (if any) into TODO's in the code (since they're mostly theoretical improvements, and not really something of much use) |
There are a few encodings we don't yet support (
Vector
?), and we don't support type specifiers / qualifiers (_Atomic
,const
, ...) either.See #20.
Also, does
objc2-encode
require knowledge of the compiler and runtime? E.g. it is often allowed to omit details likein
,inout
,oneway
and so on, but does this change significantly across compilers and/or runtimes?The text was updated successfully, but these errors were encountered: