10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
|
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
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*
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
-
+
+
+
|
1. double
1. char*: TCL_STATIC string (immutable from C)
1. string, dstring: TCL_DYNAMIC string (mutable from C)
1. vstring: TCL_VOLATILE string (mutable from C)
1. default: Tcl_Obj*, a Tcl Object
1. `<code>` is the C code that comprises the function
Example:
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
--------------
|