Good point.  Upon looking into it, it doesn't appear anyone has *ever* used
this functionality.  In my cn1libs I had generally passed in JSON data when
I needed to pass complex data.  So I decided to put together a test case,
to use as a demonstration, and I found a few bugs in the current
implementation.  I have fixed these bugs, but they won't be available until
the next server update next friday.

I have posted a small unit test for this which demonstrates how it works.

The native interface:
https://github.com/codenameone/CodenameOne/blob/master/tests/TestNativeInterfaces/src/com/codename1/testnatives/MyNativeInterface.java

The iOS implementation:
https://github.com/codenameone/CodenameOne/blob/master/tests/TestNativeInterfaces/native/ios/com_codename1_testnatives_MyNativeInterfaceImpl.m

The unit test.
https://github.com/codenameone/CodenameOne/blob/master/tests/TestNativeInterfaces/test/com/codename1/testnatives/TestNativesTest.java


Steve


On Thu, Sep 12, 2019 at 11:52 AM Thomas <[email protected]> wrote:

> well it is not really convenient when you are modifying an already
> existing cn1 lib and can't override the native files you already wrote.
> Also, the generated native interface do not give you any hint on how to
> convert you native object to the expected interface binding object when
> these differ.
> For example in objective C, if I have an  NSArray or an NSMutableArray
> holding my primitives how must I convert it to NSData* before returning it
> (there is different methods using NSKeyedArchiver or 
> NSPropertyListSerialization
> and I don't which one to use since I have no information on the
> deserialisation method CN1 is using to bind it back to java arrays of
> primitives..).
> In any case you should fix the documentation on native interfaces types
> mapping and rules
> On Thursday, September 12, 2019 at 2:23:27 AM UTC+2, Steve Hannah wrote:
>>
>> The easiest way to see is just to create a native interface and then
>> generate the native implementations using the IDEs “generate native
>> interfaces” option.
>>
>> On Wed, Sep 11, 2019 at 5:01 PM Thomas <[email protected]> wrote:
>>
>>> I need to return an array of primitives ( a double[] ) as the result of
>>> a native call in a NativeInterface. However, even if I guess it is
>>> possible, I could not find any example of this in the documentation or the
>>> various cn1libs I already looked at. And I don't know what would be the
>>> correct mapping for this in the diiferent native languages (the mapping
>>> table given into
>>> https://www.codenameone.com/manual/advanced-topics.html#_native_interfaces 
>>> is
>>> a complete mess with column headers that do not match the types in the rows
>>> (since when do Java have a NSData* type or Android a BOOL one for
>>> example?) and a "byte" column that isn't a language and do not make any
>>> sense (at least without any additional explanation, it is completely
>>> incomprehensible). You really shoud fix this part of the documentation!)
>>>
>>> So, if, in my NativeInterface I define a function like this:
>>>
>>>   public double[] myfunction();
>>>
>>> what woud be its mapping in the various languages (c# for ioS,
>>> javascript...)?
>>>
>>> for example for iOS would it be
>>>
>>> (double[]) myfunction {}
>>>
>>> or
>>>
>>> (NSData*) myfunction {}
>>>
>>> or something else...?
>>>
>>>
>>> same question if I would like to return a byte[] array instead of a
>>> double[] one
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "CodenameOne Discussions" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/codenameone-discussions/dfa74779-54c4-46ff-b55a-a923111225b6%40googlegroups.com
>>> <https://groups.google.com/d/msgid/codenameone-discussions/dfa74779-54c4-46ff-b55a-a923111225b6%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> Steve Hannah
>> Software Developer
>> Codename One
>> http://www.codenameone.com
>>
> --
> You received this message because you are subscribed to the Google Groups
> "CodenameOne Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/codenameone-discussions/918c7fb9-2325-4b8b-9601-8f281f547244%40googlegroups.com
> <https://groups.google.com/d/msgid/codenameone-discussions/918c7fb9-2325-4b8b-9601-8f281f547244%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Steve Hannah
Software Developer
Codename One
http://www.codenameone.com

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/CAGOYrKV4G6F_27pMiTuryMn6LhDia45E5Gho9EPk_v2X-nmx0A%40mail.gmail.com.

Reply via email to