From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA01702; Fri, 29 Nov 2002 18:41:24 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA00900 for caml-list@pauillac.inria.fr; Fri, 29 Nov 2002 18:41:23 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA22815 for ; Fri, 29 Nov 2002 13:21:40 +0100 (MET) Received: from mel-rto3.wanadoo.fr (smtp-out-3.wanadoo.fr [193.252.19.233]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id gATCLdX13815 for ; Fri, 29 Nov 2002 13:21:39 +0100 (MET) Received: from mel-rta8.wanadoo.fr (193.252.19.79) by mel-rto3.wanadoo.fr (6.5.007) id 3DDA12BC006E8534 for caml-list@inria.fr; Fri, 29 Nov 2002 13:21:39 +0100 Received: from ADijon-106-1-9-17.abo.wanadoo.fr (81.48.193.17) by mel-rta8.wanadoo.fr (6.5.007) id 3DD0D42700A26E35 for caml-list@inria.fr; Fri, 29 Nov 2002 13:21:39 +0100 Received: from 192.168.2.36 (ident=mail) by poulain.metalscan.fr with esmtp (MasqMail 0.1.16) id 18HkQ3-5LR-00 for caml-list@inria.fr; Fri, 29 Nov 2002 13:38:55 +0100 Received: from rhinoceros.mts ([192.168.1.4]) by drakar.mts with esmtp (Exim 3.35 #1 (Debian)) id 18Hk3w-0002V2-00 for ; Fri, 29 Nov 2002 13:16:04 +0100 Received: from matt by rhinoceros.mts with local (Exim 3.35 #1 (Debian)) id 18Hk7H-00079V-00 for ; Fri, 29 Nov 2002 13:19:31 +0100 Date: Fri, 29 Nov 2002 13:19:31 +0100 From: Metalscan To: caml-list@inria.fr Subject: Re: [Caml-list] java: short [] [] -> JNI -> int array array Message-ID: <20021129121931.GA27490@rhinoceros.mts> References: <20021128190209.GA19294@rhinoceros.mts> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021128190209.GA19294@rhinoceros.mts> User-Agent: Mutt/1.4i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Lastly I have a working solution. I'm still not sure of it's correctness... If some guru have the time to points me any amelioration, I would appreciate (both for pure C part, and manipulation of values). I apologize if this is of topic. Thanks in advance, Matthieu Dubuget value short_p_to_val(char const * i) { value v; short k = * i ; v= Val_int((short) *((short *) i) ); return v ; } value f(char const * l) { CAMLparam0() ; CAMLlocal1(v); v=alloc_array(&short_p_to_val,(char const * * ) l) ; CAMLreturn(v); } value java_short_array_array_to_ocaml_int_array_array (JNIEnv * env, jobject obj , jobjectArray jcscanA) { CAMLparam0 (); CAMLlocal1(v); //One element (line) of the jcscanA array jobjectArray ligne ; //bodies for each lines of the jcscanA pointer jshort * * ligne_body = NULL ; int i, j; // The C array in wich I'll put the values of jcscanA // Must do that because we need a null ended array for alloc_array short * * * cscan ; jsize lignes,colonnes; // Allocation de cscan et ligne_body lignes = (*env) -> GetArrayLength(env,jcscanA) ; cscan = malloc((lignes+1) * sizeof(short * *)); ligne_body = malloc (lignes * sizeof(jshort *)); // Again : cscan is NULL ended cscan[lignes]=NULL; // Remplissage avec les valeurs de jcscanA for (i=0;iGetObjectArrayElement(env,jcscanA,i); colonnes = (*env) -> GetArrayLength(env,ligne); ligne_body[i] = (*env)->GetShortArrayElements(env,ligne,0); cscan[i] = malloc( (colonnes+1) * sizeof(short *) ); cscan[i][colonnes] = NULL ; for(j=0;jReleaseShortArrayElements(env,ligne,ligne_body[i],0); free(cscan[i]); } free(ligne_body); free(cscan); CAMLreturn (v) ; }; ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners