Artifact ID: | 62b64a88abc9d641f10e16865b892e4261f60e64 |
---|---|
Page Name: | Documentation |
Date: | 2014-06-22 22:37:57 |
Original User: | rkeene |
Mimetype: | text/x-markdown |
Parent: | 43a8e8ed427536952f1d59b69c3cc09200ff3c0a (diff) |
Next | 8415446a14e0f327b6f7c457e1e3d0ec42ce1d9c |
High-Level API Manual Page
package require tcc4tcl
tcc4tcl::new
Creates a new TCC interpreter instance.
Synposis:
tcc4tcl::new ?<outputFile> ?<packageNameAndVersionAsAList>??
Returns an opaque handle which is also a Tcl command to operate on.
If neither <outputFile>
nor <packageNameAndVersionAsAList>
are specified, compilation (which happens when [$handle go] is called) is performed to memory.
If only <outputFile>
is specified then an executable is written to the file named.
If <packageNameAndVersionAsAList>
is also specified then a Tcl extension is written as a shared library (shared object, dynamic library, dynamic linking library) to the file named. The format is a 2 element list, the first is the name of the package and the second is the version number.
Examples:
- Create a handle that will compile to memory:
set handle [tcc4tcl::new]
- Create a handle that will compile to an executable named "myProgram":
set handle [tcc4tcl::new myProgram]
- Create a handle that will compile to a shared library named "myPackage" with the package name "myPackage" and version "1.0":
set handle [tcc4tcl::new myPackage "myPackage 1.0"]
$handle cproc
Creates a Tcl procedure that calls C code.
Synoposis:
$handle cproc <procName> <argList> <returnType> <code>
<procName>
is the name of the Tcl procedure to create<argList>
is a list of arguments and their types for the C function;- The list is in the format of: type1 name1 type2 name2 ... typeN nameN
- The supported types are:
- Tcl_Interp*: Must be first argument, will be the interpreter and the user will not need to pass this parameter
- int
- long
- float
- double
- char*
- Tcl_Obj*: Passes the Tcl object in unchanged
- void*
<returnType>
is the return type for the C function- The supported types are:
- void: No return value
- ok: Return TCL_OK or TCL_ERROR
- int
- long
- float
- double
- char*: TCL_STATIC string (immutable from C -- use this for constants)
- string, dstring: return a (char*) that is a TCL_DYNAMIC string (allocated from Tcl_Alloc, will be managed by Tcl)
- vstring: return a (char*) that is a TCL_VOLATILE string (mutable from C, will be copied be Tcl -- use this for local variables)
- default: Tcl_Obj*, a Tcl Object
- The supported types are:
<code>
is the C code that comprises the function
$handle ccode
Compile arbitrary C code.
Synopsis:
$handle ccode <code>
$handle tk
Request that Tk be used for this handle.
Synposis:
$handle tk
$handle linktclcommand
Create a Tcl command that calls an existing C command as a Tcl command.
Synopsis:
$handle linktclcommand <CSymbol> <TclCommandName>
$handle code
Return text of what code will be compiled when the go subcommand is called.
Synposis:
$handle code
$handle go
Execute all requested operations and output to memory, an executable, or DLL.
Once this command completes the handle is released.
Synopsis:
$handle go
See also Low-Level API