Artifact [3abed24b97]

Artifact 3abed24b97a1099bbf57c0bd52a64bf997120cb1:

Wiki page [Documentation] by rkeene on 2014-06-17 16:47:19.
D 2014-06-17T16:47:19.316
L Documentation
N text/x-markdown
P 4587d632ddad00761c6f9fe54913b7cee5ce8836
U rkeene
W 1989
Manual Page
===========

`package require tcc4tcl`

tcc4tcl::cproc
--------------
Creates a Tcl procedure that calls C code.

Synopsis:

  1.  `tcc4tcl::cproc <procName> <argList> <returnType> <code>`
    1. `<procName>` is the name of the Tcl procedure to create
    1. `<argList>` is a list of arguments and their types for the C function;
      1. The list is in the format of: type1 name1 type2 name2 ... typeN nameN
      1. The supported types are:
         1. Tcl_Interp*: Must be first argument, will be the interpreter and the user will not need to pass this parameter
         1. int
         1. long
         1. float
         1. double
         1. char*
         1. Tcl_Obj*: Passes the Tcl object in unchanged
         1. void*
    1. `<returnType>` is the return type for the C function
      1. The supported types are:
         1. void: No return value
         1. ok: Return TCL\_OK or TCL_ERROR
         1. int
         1. long
         1. float
         1. double
         1. char*: TCL\_STATIC string (immutable from C -- use this for constants)
         1. string, dstring: TCL\_DYNAMIC string (allocated from Tcl\_Alloc, will be managed by Tcl)
         1. vstring: TCL\_VOLATILE string (mutable from C, will be copied be Tcl -- use this for local variables)
         1. default: Tcl\_Obj*, a Tcl Object
    1. `<code>` is the C code that comprises the function

Examples:

  1.  Create a Tcl procedure called "add" which accepts 2 integers (a, b) and returns a long:
    1.  `tcc4tcl::cproc add {int a int b} long { return(a+b); }`
  2.  Create a Tcl procedure called "mkdir" which accepts a Tcl_Obj* and returns a return code:
    1.  `tcc4tcl::cproc mkdir {Tcl_Interp* interp char* dir} ok { int mkdir_ret; mkdir_ret = mkdir(dir); if (mkdir_ret != 0) { Tcl_SetObjResult(interp, Tcl_NewStringObj("failed", -1)); return(TCL_ERROR); }; return(TCL_OK); }`


tcc4tcl::ccode
--------------

tcc4tcl::cdata
--------------
Z bacd5f1afecbe178ea706c1012b1e0bf