Comments (6)
Mapping files are now documented, and can be used to define Objective-C method names as desired. We'll still pursue adding support for method name annotations.
from j2objc.
From nbransby on the old issue tracker:
Was the ObjectiveCName annotation added for methods or only classes? I think being able to give friendlier names to exposed methods that are designed to be called from objective c code is really important despite the risk of selector clash.
Just as important I feel is the translation of arguments to their native types when the annotation is used. In other words not exposing any of the 'javaness' to the client of the translated code. I believe if you can wrap up your cross platform library in a familiar coating for iOS developers it will decrease the suspicion around using such a libary.
Just class names right now, but now that I verified that method name mapping works correctly, adding support for methods should be much easier than starting from scratch.
I'm not sure what you mean by "native types," but the types are copied verbatim from a method mapping (including typos!).
from j2objc.
By native types I mean converting any emulated classes to their native counterparts, e.g IosObjectArray to NSArray (in fact this maybe the only instance of this)
from j2objc.
We first tried mapping Java arrays to NSArray, but found that they differ in several critical ways. Java arrays are mutable but fixed size, while NSArray is immutable and NSMutableArray's size changes. NSArray also cannot have nil elements, while Java arrays do (and Java developers expect).
It's easy to convert between NSArray and IOSObjectArray, though. To convert from an NSArray to IOSObjectArray:
NSArray *nsArray = [NSArray arrayWithObjects: @"one", @"two", @"three", nil];
IOSObjectArray *javaArray =
[IOSObjectArray *arrayWithNSArray:nsArray type:[IOSClass stringClass]];
To convert from an IOSObjectArray to NSArray (if javaArray doesn't have any nil elements):
NSArray *newArray = [NSArray arrayWithObjects:javaArray->buffer_
count:[javaArray size]];
If you want a visible API that only uses NSArrays, you'll need to write a wrapper with the above converters.
from j2objc.
Methods and constructors are now supported for the @ObjectiveCName annotation. This allows developers to rename a method to whatever selector looks best (as long as it is unique in the class). The translator will warn if an attempt is made to rename an overridden method if that super-method doesn't have the same annotation value, and will then ignore that annotation so as to not break polymorphism.
from j2objc.
Since issues are filed for specific problems with method mapping (64, 359, 378, and 389), I'm closing this general issue in favor of j2objc-discuss discussions.
from j2objc.
Related Issues (20)
- When can you update the new version? HOT 3
- JAVA code is configured with JVM, how do I configure JVM into J2OBJC? HOT 1
- My
- Myself
- Files with same name HOT 3
- Size of JRE.xcframework exceeds 75MB limit of appstoreconnect HOT 2
- bitwise error ( sudo make dist command ). JDK 15 osx Sonoma 14.1.2
- The contents of JRE.xcframework (static vs dynamic lib)
- Bazel 6 example workspace
- Inquiry about Support for Apple's Privacy Manifest Files HOT 1
- Difficulty resolving missing Android SDK APIs in iOS SDK during J2objc translation HOT 1
- "JavaMathBigDecimal_initWithLong_(self, val)" declaration not available in "BigDecimal.h" causing compilation error HOT 6
- Building j2objc fails on latest master HOT 2
- make dist fails on latest master (error while building cycle_finder jar) HOT 4
- Error in upgrading J2ObjC from version 2.8 to 3.0: create_JavaLangDeprecated() too few arguments HOT 2
- Multiple commands produce JSONArray.h
- Transpiler generated header like JavaUtilMap cannot be bridged to swift HOT 3
- 0 HOT 2
- J2objc 3.0.0 and JDK 17 HOT 2
- Error when ugrading from j2objc 1.3.1 to 3.0.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from j2objc.