::critcl::cinit text extsinject text C code as is, to be executed at extension-init timeCritcl defines the init function as
Your_package_name_Init(Tcl_Interp* ip)(Where 'your_package_name' is the simple name of your package, plus any prefix you defined.) So if you need to inject code that uses the interpreter, the variable name is 'ip'. (This is true of both critcl.kit and critcl2.kit, for all the kits Duoas examined.)inject exts C code as is, in a different place (sets code($file,init) $text and code($file,ext) $exts)::critcl::ccode textinject text C code as is (#includes, #defines, common defs, etc) at the top of the generated code::critcl::cdata name anydataCreates a proc, name, which when called will return anydata (as byte array)::critcl::cproc name adefs rtype bodyDefine a C procedure which can be called from Tcl cproc lets you define a C proc ,name, with C code as body. Args (adefs) and return values (rtype) must be typed.There are no default args or ways to pass more sophisticated data items than int/long/float/double/char* for now.The return type can be string, meaning it's a Tcl_Alloc'ed char* which will at some point be [Tcl_Free]'d.You can also use Tcl_Obj* args (no refcount change), or return it (in which case it will be decref'ed).If the first parameter to a cproc has type Tcl_Interp*, that'll be passed in.Lastly, if the return type is ok, then an int return code of type TCL_OK/TCL_ERROR is expected and will be processed as usual (errors must set the result, so it is most likely that you'll also want to specify the Tcl_Interp* arg).Summary for adef:
- Tcl_Interp*
- int
- long
- float
- double
- char*
- Tcl_Obj*
- void*
- void -
- ok -
- int -
- long -
- float -
- double -
- char* - TCL_STATIC char*
- string - TCL_DYNAMIC char*
- dstring - TCL_DYNAMIC char*
- vstring - TCL_VOLATILE char*
- default - Tcl_Obj*
critcl::cproc sum {int a int b} int { return a+b; }::critcl::ccommand name anames ?-clientdata data? ?-delproc proc? argsConnects code to Tcl_CreateObjCommand without further wrapping
- -clientdata data
- client data to be passed
- -delproc proc
- client delete process
- anames
- {clientdata interp objc objv} are the default argument names. objv stand for "Tcl_Obj *const objv[ ]" in the compiled C code. interp is of course "Tcl_Interp *interp"
::critcl::failedcheck if the C compile failed::critcl::donestub - does nothing::critcl::tkconfigures tk 1::critcl::cachereturns the [CriTcl Cache] directory for the current platform::critcl::tsourcesdoes nothing::critcl::platformreturn a platform descriptor ($OS-$machine) of the platform CriTcl is being run on::critcl::compilingcheck that we can indeed run a compiler::critcl::sharedlibextreturns the shared library extension for the target platform.::critcl::scriptinginverse of [::critcl::compiling] - we can't run a compiler
::critcl::config option value
- general format of command to set an option to a value
- returns the current value of an option
- the compiled library will be saved for permanent use if the outdir option is set (in which case rebuilds will no longer be automatic). Default value "" causes library to be saved to the user's cache.
- the generated source will be kept (default value 0 causes source to be deleted)
- no meaning (default value "")
- force recompilation. (default value 0 causes cached files to be used if available)
- if non-empty, add -Isome_value to command line
- default value is ""
- no meaning (default value "")
- compile for Tk (default value 0 compiles without Tk)
- if non-empty, add '-x some_value' to the gcc options, causing it to interpret source files as written in the programming language specified by "some_value"
- default value "" causes '-x none' to be added to the gcc options, so files are interpreted according to their file name suffix, as if -x is not used at all
- use the #line preprocessor directive in the generated C source
- default value 1 switches this feature on; value 0 switches it off
::critcl::config combine some_valueAdjust compiler/linker options to produce different types of binary output file.some_value = ""
- (the default value of combine)
- gcc -shared -DUSE_TCL_STUBS -fPIC
- with additional optimisation options "-O2 -DNDEBUG -Wl,-s" if '-g' is not specified (?) among the headers
- use shared library filename suffix (*.so, *.dll);
- gcc -r -nostdlib -DUSE_TCL_STUBS -fPIC
- use *_pic.o filename suffix
- gcc -r -nostdlib
- use *.o filename suffix
- gcc -r -nostdlib -DUSE_TCL_STUBS
- use *_stub.o filename suffix
- gcc -r -nostdlib -DUSE_TCL_STUBS (same as for "static")
- use no filename suffix
- Distinct filename suffices are used so that switching between values of "combine" causes a rebuild
- On Windows, OSF1 and Darwin, gcc options differ from those stated above
- Only the default value "" works for me, with gcc 4.0.2 and binutils 2.15.94 on Linux/x86. It is likely that gcc's interpretation of command options has changed since Critcl was written.
RLH 09-June-2006: What does one need to make Critcl work?KJN 10-June-2006: Critcl is supplied as a Starkit. Try it first with the appropriate Tclkit for your architecture - the two files (plus a working installation of gcc) should be all you need. If you then wish to use Critcl with a non-Tclkit installation, see Critcl FAQ for instructions on unpacking the Starkit and installing its files.