From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA11770 for caml-redistribution@pauillac.inria.fr; Fri, 28 Jan 2000 17:37:50 +0100 (MET) Resent-Message-Id: <200001281637.RAA11770@pauillac.inria.fr> Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA29144 for ; Fri, 28 Jan 2000 11:48:14 +0100 (MET) Received: from muguet.saclay.cea.fr (muguet.saclay.cea.fr [132.166.192.6]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id LAA27408 for ; Fri, 28 Jan 2000 11:48:13 +0100 (MET) Received: from orion.serma.cea.fr (orion.serma.cea.fr [132.166.151.161]) by muguet.saclay.cea.fr (8.9.1a/8.9.1/CEAnet-relay-5.1.D20+Y2K) with ESMTP id LAA03185 for ; Fri, 28 Jan 2000 11:47:34 +0100 (MET) Received: from cea.fr (localhost [127.0.0.1]) by orion.serma.cea.fr (8.9.3/8.8.7) with ESMTP id LAA02758 for ; Fri, 28 Jan 2000 11:48:11 +0100 Sender: pgoldb@soleil.serma.cea.fr Message-ID: <389173EB.8CE7B6D7@cea.fr> Date: Fri, 28 Jan 2000 10:48:11 +0000 From: Patrick Goldbronn - SYSCO Organization: CEA X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.9-27mdksmp i686) X-Accept-Language: fr-FR, en MIME-Version: 1.0 To: caml Inria Subject: modification de camlidl Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit Resent-From: weis@pauillac.inria.fr Resent-Date: Fri, 28 Jan 2000 17:37:50 +0100 Resent-To: caml-redistribution@pauillac.inria.fr Hello, I modified 2 features in camlidl. This is a very bad work but it's enough for me use :) Perhaps some could make better. In attachment : the modified files in camlidl ! 1 Adding a custom parameter in function translation : =================================================== For instance there are 2 label for quote mark : 'call' and 'dealloc'. I have added the label 'init' to add custom initialization sequence if there are variable like error code we don't want to see in caml function (perhaps there are another mean to do that in standard ?) Example : I have the C function : void NP_initialize(int argc, char **argv, int *err) ; and I want the caml function initialize in module Np : external initialize : string array -> unit so I write the idl file : void initialize( [in] int argc, [in,size_is(argc),string*] char **argv ) quote(init," int err=0; ") quote(call," NP_initialize( argc, argv, &err ); if(err != 0) failwith(\"Np.initialize : error \"); "); I think this part is right :) 2 Modifing the in,out tag : ========================= When I pass an array to a function that modify the value in the array, I don't want a new array. This modification work only with array and if you want another type in,out you must add it :). I'm not sure it works with all array type and what it do exactly with any array : I use it with double and int array. Example : idl file : void get_vector_D( vector vec, int ideb, int size, int n, [in,out,size_is(n)] double tab[], int root ) quote(init," int err=0; ") quote(call," NP_get_vector_D (vec,ideb,size,tab,root,&err) ; if(err != 0) failwith(\"Np.get_vector_D : error \") ; ") ; generated C file : value camlidl_np_get_vector_D( value _v_vec, value _v_ideb, value _v_size, value _v_tab, value _v_root) { vector vec; /*in*/ int ideb; /*in*/ int size; /*in*/ int n; /*in*/ double *tab; /*in,out*/ int root; /*in*/ mlsize_t _c1; mlsize_t _c2; mlsize_t _c3; struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL }; camlidl_ctx _ctx = &_ctxs; /* begin user-supplied initialization sequence */ int err=0; /* end user-supplied initialization sequence */ camlidl_ml2c_np_vector(_v_vec, &vec, _ctx); ideb = Int_val(_v_ideb); size = Int_val(_v_size); _c1 = Wosize_val(_v_tab) / Double_wosize; tab = camlidl_malloc(_c1 * sizeof(double ), _ctx); for (_c2 = 0; _c2 < _c1; _c2++) { tab[_c2] = Double_field(_v_tab, _c2); } n = _c1; root = Int_val(_v_root); /* begin user-supplied calling sequence */ NP_get_vector_D (vec,ideb,size,tab,root,&err) ; if(err != 0) failwith("Np.get_vector_D : error ") ; /* end user-supplied calling sequence */ /* begin of InOut values */ for (_c3 = 0; _c3 < n; _c3++) { Store_double_field(_v_tab, _c3, tab[_c3]); } /* end of InOut values */ camlidl_free(_ctx); return Val_unit; } genereted ocaml file : external get_vector_D : vector -> int -> int -> float array -> int -> unit = "camlidl_np_get_vector_D" -- ##################################### # Patrick GOLDBRONN # # CEA - DRN/DMT/SYSCO # # CE-Saclay, Bâtiment 460 # # 91191 GIF/YVETTE CEDEX (FRANCE) # # # # Tél : 01 69 08 73 55 # # Fax : 01 69 08 96 96 # #####################################