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

Map basic objects like NSRect #7

Open
mojo2012 opened this issue Jun 2, 2019 · 4 comments
Open

Map basic objects like NSRect #7

mojo2012 opened this issue Jun 2, 2019 · 4 comments

Comments

@mojo2012
Copy link
Collaborator

mojo2012 commented Jun 2, 2019

I'm trying to show a simple empty window on screen - but right now I'm totally stuck calling NSWindow.initWithContentRect:styleMask:backing:defer:. I think the problem is my NSRect implementation:

public class NSRect extends Structure implements Structure.ByValue {
    public NSPoint origin;
    public NSSize size;

    ...

    @Override
	protected List<String> getFieldOrder() {
		return Arrays.asList("origin", "size");
	}
}

I have no clue what goes wrong here, but this is the stack:

2019-06-02 22:03:22.641 java[53279:2512944] *** +[WLJavaProxy restorableStateKeyPaths]: unrecognized selector sent to class 0x1143803b8
2019-06-02 22:03:22.645 java[53279:2512944] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[WLJavaProxy restorableStateKeyPaths]: unrecognized selector sent to class 0x1143803b8'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff41da9cfd __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff6c44fa17 objc_exception_throw + 48
	2   Foundation                          0x00007fff44123639 +[NSProxy init] + 0
	3   CoreFoundation                      0x00007fff41d4bb8f ___forwarding___ + 1485
	4   CoreFoundation                      0x00007fff41d4b538 _CF_forwarding_prep_0 + 120
	5   AppKit                              0x00007fff3f3629e8 -[NSResponder(NSPersistentUISupport) _changePersistentKeyPathObservationTo:] + 48
	6   jna17962736570655425700.tmp         0x000000011443de74 ffi_call_unix64 + 76
	7   ???                                 0x00007ffee8311758 0x0 + 140732793952088
)
libc++abi.dylib: terminating with uncaught exception of type NSException

It would be nice to have basic types already mapped!

Furthermore, it would be awesome to have better logging in case something goes wrong, like what are the selector arguments that were passed (on the objc-side).

Thanks for any help.

@shannah
Copy link
Owner

shannah commented Jun 3, 2019

Struct parameters are not well supported right now. I'd like to add support for them, but currently it isn't on my radar. Handling shortcomings like this, I usually handle by writing a small library in Objective-C that wraps the things I need, in a way that is easier for the bridge to work with. Then call that wrapper via the Objective-C bridge.

@mojo2012
Copy link
Collaborator Author

mojo2012 commented Jun 3, 2019

Well for now I copied some files from rococoa and adapted them a bit. It seems to work quite well.
I prefer not to write objective-c :-D

@shannah
Copy link
Owner

shannah commented Jun 3, 2019

Do you use the rococoa stuff in conjunction with the objective-c bridge (this library), or on its own? e.g. is there any thing you can share that might help others facing the same issue?

@mojo2012
Copy link
Collaborator Author

mojo2012 commented Jun 4, 2019

This is what I'm currently working on: https://github.com/mojo2012/kakao
It's a basic macOS cocoa UI framework. It was born from the dissatisfaction of the current Java IDEs (and I've tried them all) - UI-wise. I plan it to use as the UI foundation for a new Java IDE based on Eclipse Compiler/Editor/LSP infrastructure :-D (if my children give me enough time hehe)

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