5 extern int gcd(int x, int y);
6 extern int gcdmain(int argc, char *argv[]);
7 extern int count(char *bytes, int len, char c);
8 extern void capitalize (char *str, int len);
9 extern void circle (double cx, double cy);
10 extern int squareCubed (int n, int *OUTPUT);
15 extern int gcd(int x, int y);
17 %typemap(arginit) (int argc, char *argv[]) "$2 = 0;";
19 %typemap(in) (int argc, char *argv[]) {
20 Tcl_Obj **listobjv = 0;
22 if (Tcl_ListObjGetElements(interp,$input, &$1, &listobjv) == TCL_ERROR) {
23 SWIG_exception(SWIG_ValueError,"Expected a list");
26 $2 = (char **) malloc(($1+1)*sizeof(char *));
27 for (i = 0; i < $1; i++) {
28 $2[i] = Tcl_GetStringFromObj(listobjv[i],0);
33 %typemap(freearg) char *argv[] {
39 extern int gcdmain(int argc, char *argv[]);
41 %typemap(in) (char *bytes, int len) {
42 $1 = Tcl_GetStringFromObj($input,&$2);
45 extern int count(char *bytes, int len, char c);
48 /* This example shows how to wrap a function that mutates a string */
50 %typemap(in) (char *str, int len) {
52 temp = Tcl_GetStringFromObj($input,&$2);
53 $1 = (char *) malloc($2+1);
57 /* Return the mutated string as a new object. */
59 %typemap(argout) (char *str, int len) {
61 o = Tcl_NewStringObj($1,$2);
62 Tcl_ListObjAppendElement(interp,$result,o);
66 extern void capitalize(char *str, int len);
69 /* A multi-valued constraint. Force two arguments to lie
70 inside the unit circle */
72 %typemap(check) (double cx, double cy) {
73 double a = $1*$1 + $2*$2;
75 SWIG_exception(SWIG_ValueError,"$1_name and $2_name must be in unit circle");
80 extern void circle(double cx, double cy);