JNI: Transforming primitive types

Discussion in 'Java' started by Marcelo, Jan 19, 2006.

  1. Marcelo

    Marcelo Guest

    Hi everybody,

    I would like to know if there is simple way in JNI to pass a float** in c++ to a
    jobjectArray.

    should I first search the jclass element, then creating the NewObjectArray and
    at the end, coping all the c++ float-elements to the jobjectArray?

    is there a simplest and low ressource-consuming way?

    thanks a lot,

    Marcelo
    Marcelo, Jan 19, 2006
    #1
    1. Advertising

  2. On Thu, 19 Jan 2006 23:47:10 +0100, Marcelo wrote:

    > I would like to know if there is simple way in JNI to pass a float**
    > in c++ to a jobjectArray.
    >
    > should I first search the jclass element, then creating the
    > NewObjectArray and at the end, coping all the c++ float-elements to
    > the jobjectArray?
    >
    > is there a simplest and low ressource-consuming way?


    Except for the fact that a float array is a more suitable structure
    for holding floats than an Object array is, you've described an
    appropriate method. What problems are you having?

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Jan 20, 2006
    #2
    1. Advertising

  3. Marcelo

    Marcelo Guest

    hi,
    my problem is that i don't understad if this senteces is OK:

    float *vectA; //Some values inside vectA
    ....
    jfloatArray jarr; //After initialize jarr with float class
    ....

    (*env)->SetIntArrayRegion(env, jarr, 0, 100, vectA);

    does it work?

    Is there any problem passing floats in c to the jfloats in Java?

    Should I do any conversion as we do in Strings?

    thanks a lot,

    Marcelo
    Marcelo, Jan 21, 2006
    #3
  4. On Sat, 21 Jan 2006 11:37:45 +0100, Marcelo wrote:
    > my problem is that i don't understad if this senteces is OK:


    Are you having specific problems, or are you just wondering?


    > float *vectA; //Some values inside vectA
    > ...
    > jfloatArray jarr; //After initialize jarr with float class
    > ...
    >
    > (*env)->SetIntArrayRegion(env, jarr, 0, 100, vectA);
    >
    > does it work?
    >
    > Is there any problem passing floats in c to the jfloats in Java?
    >
    > Should I do any conversion as we do in Strings?


    If you want to store floats in a float (not Float) array, pass vectA
    to SetFloatArrayRegion (*not* SetIntArrayRegion). Note that float is
    not, as you imply, a class.

    /gordon

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Jan 23, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo
    Replies:
    0
    Views:
    334
    Marcelo
    Jan 19, 2006
  2. Replies:
    7
    Views:
    599
    Victor Bazarov
    May 9, 2005
  3. Bill Medland
    Replies:
    1
    Views:
    1,491
    Jean-Francois Briere
    Oct 26, 2006
  4. bernd
    Replies:
    1
    Views:
    780
    bernd
    Jun 13, 2008
  5. Daniel Pitts
    Replies:
    7
    Views:
    470
Loading...

Share This Page