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

Thank you and an issue. #1

Open
g40 opened this issue Nov 6, 2023 · 4 comments
Open

Thank you and an issue. #1

g40 opened this issue Nov 6, 2023 · 4 comments

Comments

@g40
Copy link

g40 commented Nov 6, 2023

Many thanks - Great idea and could be very useful.

Built and run on Ventura using:

build_release % clang -v
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Seeing lots and lots of errors in the following form. Is this known and is anyone working to fix it? Or should I just get stuck in a make the relevant modifications?

[error] Couldn't resolve return type '{?=[16q]}' of function 'mpsndarrayorsecondarygradient_stridesForSourceIndex'.
[error] Skipping function 'stridesForSourceIndex:' of class 'MPSNDArrayORSecondaryGradient' because of unknown argument type.
[warning] could not resolve type name '(?=I{?=b8b8b16})'.
[error] Couldn't resolve 2. argument type name '(?=I{?=b8b8b16})' of function 'mpsndarrayorsecondarygradient_setFileVersion'.
[error] Skipping function 'setFileVersion:' of class 'MPSNDArrayORSecondaryGradient' because of unknown argument type.
[warning] could not resolve type name '(?=I{?=b8b8b16})'.
[error] Couldn't resolve return type '(?=I{?=b8b8b16})' of function 'mpsndarrayorsecondarygradient_fileVersion'.
@FelixK15
Copy link
Owner

FelixK15 commented Nov 6, 2023

Hi and thanks for your issue.

the code generator doesn't have support for all types that are supported by objc, like bitfields in your example.

For reference:

boolean8_t base_type_resolve( c_ocoa_objc_type_resolve_result* pOutResult, const char* pObjectiveCTypeName )

Do you require support for this?

(I think it makes sense to at least add an option to have quiet run where it doesn't complain about unknown types.)

@g40
Copy link
Author

g40 commented Nov 7, 2023

@FelixK15 Hello and thanks for the quick response. I get it. Should have spent more time reading the blog :). I think a quiet mode would be good. Also a small example. Do you have something like this?

//
// The simplest possible application 
//
// clang -fobjc-arc -framework Cocoa app.m -o app
// ./app
//
#import <Cocoa/Cocoa.h>

int main()
{
	id app = [NSApplication sharedApplication];
	[app setActivationPolicy:NSApplicationActivationPolicyRegular];

	NSRect frame = NSMakeRect(0, 0, 300, 300);
	int mask = NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable;
	NSWindow* window = 
	[[NSWindow alloc] initWithContentRect:frame
								 styleMask:mask
								   backing:NSBackingStoreBuffered
									 defer:NO];
	[window cascadeTopLeftFromPoint:NSMakePoint(10, 10)];
	[window setTitle:@"Application"];
	[window makeKeyAndOrderFront:nil];
  
	id nc = [NSNotificationCenter defaultCenter];
	[nc addObserver:app
			selector:@selector(terminate:)
			name:NSWindowWillCloseNotification
			object:window];

	[app activateIgnoringOtherApps:YES];
	[app run];
	return 0;
}

@g40
Copy link
Author

g40 commented Nov 7, 2023

@FelixK15 I am not spending enough time looking at the code either. Have just discovered your example for OSX. Let me try that and report back. Great work.

@g40
Copy link
Author

g40 commented Nov 7, 2023

@FelixK15, 3rd time lucky perhaps. Having built the generator for OSX, I can get it to run but there appear to be further issues.

  1. Overwhelming number of error and warning messages, the vast majority of which seem to be repeated.
  2. The system is dumping classes which are prepended with _ underscore characters - I had the impression these were private to Apple? i.e. not part of the documented API.
  3. The -o option only works if given a fully qualified path - if not the path gets pre-pended to the output filenames.
  4. I cannot get the -t option to work at all. When set the generator simply dumps a truncated c_ocoa_types.h and then exits. The types file seems to be generated to an extent when -t is not set.
  5. The types file contains many, many repetitions of the forward typedefs - not an error per se but adds hugely to the final file size and is confusing.
  6. Biggest problem is that attempting to compile the osx test using the shell script fails. A snippet below
In file included from /Users/moi/src/osx/c_ocoa/osx/test/test.c:8:
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/nsapplication.c:2424:98: error: variable has incomplete type '_NSRange' (aka 'struct __NSRange_')
nsobject_t nsapplication_accessibilityAttributedStringForRange( nsapplication_t object, _NSRange arg0 )
                                                                                                 ^
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/c_ocoa_types.h:662:8: note: forward declaration of 'struct __NSRange_'
struct __NSRange_;
       ^
In file included from /Users/moi/src/osx/c_ocoa/osx/test/test.c:8:
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/nsapplication.c:2512:10: error: incomplete result type '_NSRange' (aka 'struct __NSRange_') in function definition
_NSRange nsapplication_accessibilityColumnIndexRange( nsapplication_t object )
         ^
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/c_ocoa_types.h:662:8: note: forward declaration of 'struct __NSRange_'
struct __NSRange_;
       ^
In file included from /Users/moi/src/osx/c_ocoa/osx/test/test.c:8:
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/nsapplication.c:2516:9: error: calling function with incomplete return type '_NSRange' (aka 'struct __NSRange_')
        return nsapplication_accessibilityColumnIndexRange_call( (id)object, methodSelector );
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/moi/src/osx/c_ocoa/osx/test/../generated_files/nsapplication.c:2515:76: note: expanded from macro 'nsapplication_accessibilityColumnIndexRange_call'
        #define nsapplication_accessibilityColumnIndexRange_call( obj, selector ) ((_NSRange (*)( id, SEL ))objc_msgSend) ( obj, selector )

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