~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Source/Modules/tcl8.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2008-11-10 16:29:56 UTC
  • mfrom: (1.2.8 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20081110162956-xue6itkuqhbza87s
Tags: 1.3.36-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop pike and libchicken-dev from the build-depends 
    (both are universe)
  - Use python2.5 instead of python2.4.
  - use php5
  - Clean Runtime/ as well.
  - debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.
  - drop "--without-mzscheme", we don't have it in our build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 * Tcl8 language module for SWIG.
8
8
 * ----------------------------------------------------------------------------- */
9
9
 
10
 
char cvsroot_tcl8_cxx[] = "$Id: tcl8.cxx 10270 2008-02-27 15:29:55Z wsfulton $";
 
10
char cvsroot_tcl8_cxx[] = "$Id: tcl8.cxx 10453 2008-05-15 21:18:44Z wsfulton $";
11
11
 
12
12
#include "swigmod.h"
13
13
#include "cparse.h"
303
303
 
304
304
    Printv(f->def, "SWIGINTERN int\n ", wname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {", NIL);
305
305
 
306
 
    /* Print out variables for storing arguments. */
307
 
    emit_args(type, parms, f);
 
306
    // Emit all of the local variables for holding arguments.
 
307
    emit_parameter_variables(parms, f);
308
308
 
309
309
    /* Attach standard typemaps */
310
310
    emit_attach_parmmaps(parms, f);
443
443
    }
444
444
 
445
445
    /* Now write code to make the function call */
446
 
    emit_action(n, f);
 
446
    String *actioncode = emit_action(n);
447
447
 
448
448
    /* Need to redo all of this code (eventually) */
449
449
 
450
450
    /* Return value if necessary  */
451
 
    if ((tm = Swig_typemap_lookup_new("out", n, "result", 0))) {
 
451
    if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
452
452
      Replaceall(tm, "$source", "result");
453
453
#ifdef SWIG_USE_RESULTOBJ
454
454
      Replaceall(tm, "$target", "resultobj");
466
466
    } else {
467
467
      Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), name);
468
468
    }
 
469
    emit_return_variable(n, type, f);
469
470
 
470
471
    /* Dump output argument code */
471
472
    Printv(f->code, outarg, NIL);
475
476
 
476
477
    /* Look for any remaining cleanup */
477
478
    if (GetFlag(n, "feature:new")) {
478
 
      if ((tm = Swig_typemap_lookup_new("newfree", n, "result", 0))) {
 
479
      if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
479
480
        Replaceall(tm, "$source", "result");
480
481
        Printf(f->code, "%s\n", tm);
481
482
      }
482
483
    }
483
484
 
484
 
    if ((tm = Swig_typemap_lookup_new("ret", n, "result", 0))) {
 
485
    if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
485
486
      Replaceall(tm, "$source", "result");
486
487
      Printf(f->code, "%s\n", tm);
487
488
    }
565
566
    Setattr(n, "wrap:name", getfname);
566
567
    Printv(getf->def, "SWIGINTERN const char *", getfname, "(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, char *name1, char *name2, int flags) {", NIL);
567
568
    Wrapper_add_local(getf, "value", "Tcl_Obj *value = 0");
568
 
    if ((tm = Swig_typemap_lookup_new("varout", n, name, 0))) {
 
569
    if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
569
570
      Replaceall(tm, "$source", name);
570
571
      Replaceall(tm, "$target", "value");
571
572
      Replaceall(tm, "$result", "value");
572
573
      /* Printf(getf->code, "%s\n",tm); */
573
 
      addfail = emit_action_code(n, getf, tm);
 
574
      addfail = emit_action_code(n, getf->code, tm);
574
575
      Printf(getf->code, "if (value) {\n");
575
576
      Printf(getf->code, "Tcl_SetVar2(interp,name1,name2,Tcl_GetStringFromObj(value,NULL), flags);\n");
576
577
      Printf(getf->code, "Tcl_DecrRefCount(value);\n");
601
602
        Wrapper_add_local(setf, "value", "Tcl_Obj *value = 0");
602
603
        Wrapper_add_local(setf, "name1o", "Tcl_Obj *name1o = 0");
603
604
 
604
 
        if ((tm = Swig_typemap_lookup_new("varin", n, name, 0))) {
 
605
        if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
605
606
          Replaceall(tm, "$source", "value");
606
607
          Replaceall(tm, "$target", name);
607
608
          Replaceall(tm, "$input", "value");
610
611
          Printf(setf->code, "Tcl_DecrRefCount(name1o);\n");
611
612
          Printf(setf->code, "if (!value) SWIG_fail;\n");
612
613
          /* Printf(setf->code,"%s\n", tm); */
613
 
          emit_action_code(n, setf, tm);
 
614
          emit_action_code(n, setf->code, tm);
614
615
          Printf(setf->code, "return NULL;\n");
615
616
          Printf(setf->code, "fail:\n");
616
617
          Printf(setf->code, "return \"%s\";\n", iname);
675
676
      value = Char(wname);
676
677
    }
677
678
 
678
 
    if ((tm = Swig_typemap_lookup_new("consttab", n, name, 0))) {
 
679
    if ((tm = Swig_typemap_lookup("consttab", n, name, 0))) {
679
680
      Replaceall(tm, "$source", value);
680
681
      Replaceall(tm, "$target", name);
681
682
      Replaceall(tm, "$value", value);
682
683
      Replaceall(tm, "$nsname", nsname);
683
684
      Printf(const_tab, "%s,\n", tm);
684
 
    } else if ((tm = Swig_typemap_lookup_new("constcode", n, name, 0))) {
 
685
    } else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
685
686
      Replaceall(tm, "$source", value);
686
687
      Replaceall(tm, "$target", name);
687
688
      Replaceall(tm, "$value", value);
782
783
      Printv(f_wrappers, "SWIGINTERN void swig_delete_", class_name, "(void *obj) {\n", NIL);
783
784
      if (destructor_action) {
784
785
        Printv(f_wrappers, SwigType_str(rt, "arg1"), " = (", SwigType_str(rt, 0), ") obj;\n", NIL);
785
 
        Printv(f_wrappers, destructor_action, NIL);
 
786
        Printv(f_wrappers, destructor_action, "\n", NIL);
786
787
      } else {
787
788
        if (CPlusPlus) {
788
789
          Printv(f_wrappers, "    delete (", SwigType_str(rt, 0), ") obj;\n", NIL);