- 论坛徽章:
- 84
|
0. Bare-Fisted Coding
- $ cc -c example.c -o example.o
- ld -shared -expect_unresolved \
- -o mycommand.so example.o
- $ cat example.c
- #include <tcl.h>
- int MyCommand(ClientData clientData,
- Tcl_Interp *interp,
- int argc, char *argv[])
- {
- char *datum, temp;
- datum = "";
- if (argc >= 2) {
- datum = argv[1];
- if (strlen(datum) > 3) {
- temp = datum[0];
- datum[0] = datum[1];
- datum[1] = temp;
- }
- }
- Tcl_SetResult(interp, datum, NULL);
- return TCL_OK;
- }
- int Mycommand_Init(Tcl_Interp *interp)
- {
- if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
- return TCL_ERROR;
- }
- Tcl_CreateCommand(interp, "mycommand", MyCommand,
- (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
- return TCL_OK;
- }
复制代码 1. SWIG tcl
http://www.swig.org/translations/chinese/index.html
2.
http://wiki.tcl.tk/ffidl
3.
https://www.tcl.tk/community/tcl ... r-critcl/critcl.pdf- package require critcl
- namespace import critcl::*
- cproc cube {int x} int {
- return x * x * x;
- }
- proc report number {
- puts "The cube of $number is [cube $number]."
- }
复制代码 ref:
http://collaboration.cmc.ec.gc.c ... 212/laird/laird.htm
https://www.tcl.tk/community/tcl ... r-critcl/critcl.pdf |
|