~ubuntu-branches/ubuntu/maverick/swig1.3/maverick

« back to all changes in this revision

Viewing changes to Doc/Manual/Ocaml.html

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-12-20 14:43:24 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20061220144324-bps3kb06xp5oy9w1
Tags: 1.3.31-1ubuntu1
* Merge from debian unstable, remaining changes:
  - drop support for pike
  - use php5 instead of php4
  - clean Runtime/ as well
  - force a few environment variables

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
support of Ocaml.  Ocaml     is a relatively recent addition to the ML family,
64
64
and is a recent   addition     to SWIG.  It's the second compiled, typed
65
65
language to be added.    Ocaml   has  widely acknowledged benefits for engineers,
66
 
mostly derived  from  a sophistocated    type system, compile-time checking
 
66
mostly derived  from  a sophisticated    type system, compile-time checking
67
67
which eliminates  several  classes of  common  programming errors, and good
68
68
native performance.   While  all of this  is wonderful,  there are well-written
69
69
C and C++ libraries  that  Ocaml users  will want to  take advantage of as
70
70
part of their arsenal  (such  as SSL and  gdbm), as well  as their own mature
71
71
C and C++ code.  SWIG  allows   this code  to be used in  a natural, type-safe
72
 
way with Ocaml, by  providing   the necessary,   but repetetive  glue code
 
72
way with Ocaml, by  providing   the necessary,   but repetitive  glue code
73
73
which creates and uses Ocaml values  to communicate   with C and C++ code.
74
74
 In addition, SWIG also produces the needed Ocaml source   that binds
75
75
variants, functions,  classes, etc.
264
264
 
265
265
<p>
266
266
In order to provide access to overloaded functions, and
267
 
provide sensible outputs from them, all C entites are represented as
 
267
provide sensible outputs from them, all C entities are represented as
268
268
members of the c_obj type:
269
269
</p>
270
270
 
338
338
    ]). &nbsp;This is in order to make return values easier to handle
339
339
    when functions have only one return value, such as constructors,
340
340
    and operators. &nbsp;In addition, string, pointer, and object
341
 
    values are interchangable with respect to caml_ptr_val, so you can
 
341
    values are interchangeable with respect to caml_ptr_val, so you can
342
342
    allocate memory as caml strings and still use the resulting
343
343
    pointers for C purposes, even using them to construct simple objects
344
344
    on.  Note, though, that foreign C++ code does not respect the garbage
518
518
 
519
519
<p>
520
520
Consider writing an object when the ending condition of your array is complex,
521
 
such as using a required centinel, etc.
 
521
such as using a required sentinel, etc.
522
522
</p>
523
523
 
524
524
<H4><a name="Ocaml_nn16"></a>25.2.3.4 Example typemap for a function taking float * and int</H4>
809
809
handle the method calls in terms of the public methods of the object, and
810
810
any other relevant information.  The function <tt>new_derived_object</tt>
811
811
uses a stub class to call your methods in place of the ones provided by the
812
 
underlying implemenation.  The object you receive is the underlying object,
 
812
underlying implementation.  The object you receive is the underlying object,
813
813
so you are free to call any methods you want from within your derived method.
814
814
Note that calls to the underlying object do not invoke Ocaml code.  You need
815
815
to handle that yourself.
970
970
Sometimes, this is the main purpose of the argument given.  <tt>directorargout</tt>
971
971
typemaps allow your caml code to emulate this by specifying additional return
972
972
values to be put into the output parameters.  The SWIG ocaml module is a bit
973
 
loose in order to make code eaiser to write.  In this case, your return to
 
973
loose in order to make code easier to write.  In this case, your return to
974
974
the caller must be a list containing the normal function return first, followed
975
975
by any argout values in order.  These argout values will be taken from the
976
976
list and assigned to the values to be returned to C++ through directorargout typemaps.