From 0d4a07e5e5d8ff1f4e7e2d2ab666c53dfa66dd81 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Thu, 23 Sep 2004 22:16:13 +0000 Subject: [PATCH] * profile.swg: Only include tclsh.i if building for Tcl. (Tcl_SetResult, my_tcl_setresult): Compile hack only if building for Tcl. (%typemap SWIGTYPE *OUTPUT): Initialization is not specific to the scripting language. Add Python code. (%typemap errcode_t, errcode_t*): Add placeholders for Python support. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16782 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/profile/ChangeLog | 10 ++++++++++ src/util/profile/profile.swg | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/util/profile/ChangeLog b/src/util/profile/ChangeLog index d5376ccdb..a08a6107d 100644 --- a/src/util/profile/ChangeLog +++ b/src/util/profile/ChangeLog @@ -1,3 +1,13 @@ +2004-09-23 Ken Raeburn + + * profile.swg: Only include tclsh.i if building for Tcl. + (Tcl_SetResult, my_tcl_setresult): Compile hack only if building + for Tcl. + (%typemap SWIGTYPE *OUTPUT): Initialization is not specific to the + scripting language. Add Python code. + (%typemap errcode_t, errcode_t*): Add placeholders for Python + support. + 2004-08-28 Ken Raeburn * prof_file.c (profile_open_file): If an error occurs while diff --git a/src/util/profile/profile.swg b/src/util/profile/profile.swg index 5de7093ba..960734302 100644 --- a/src/util/profile/profile.swg +++ b/src/util/profile/profile.swg @@ -29,6 +29,7 @@ #include "com_err.h" #include "profile.h" +#ifdef SWIGTCL /* Reduce warnings about cast discarding const to just this one, from every SWIG-generated call to Tcl_SetResult. */ static void my_tcl_setresult(Tcl_Interp *i, const char *str, Tcl_FreeProc *f) @@ -37,15 +38,19 @@ static void my_tcl_setresult(Tcl_Interp *i, const char *str, Tcl_FreeProc *f) } #undef Tcl_SetResult #define Tcl_SetResult my_tcl_setresult +#endif %} %include "typemaps.i" -%typemap(tcl8,in,numinputs=0) SWIGTYPE *OUTPUT ($1_basetype tmp) { - $1 = &tmp; +/* These should perhaps be part of the general SWIG package, maybe? */ +%typemap(in,numinputs=0) SWIGTYPE *OUTPUT ($1_basetype tmp) { + /*generic swigtype hack*/ $1 = &tmp; } %typemap(tcl8,argout) SWIGTYPE *OUTPUT - "/*foo*/Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) *$1, $*1_descriptor,0));"; + "/*generic swigtype hack*/ Tcl_SetObjResult(interp,SWIG_NewInstanceObj((void *) *$1, $*1_descriptor,0));"; +%typemap(python,argout) SWIGTYPE *OUTPUT + "/*generic swigtype hack*/ resultobj = SWIG_NewPointerObj((void *) *$1, $*1_descriptor,0);"; %module profile @@ -82,6 +87,12 @@ typedef void **iter_t; /* ick */ SWIG_fail; } } +%typemap(python,argout) errcode_t* { + /* do something with *($1) */ abort(); +} +%typemap(python,out) errcode_t { + /* do something with $1 */ abort(); +} /* "char **OUTPUT" : Supply a place for the function to stuff one string pointer. */ @@ -239,4 +250,6 @@ errcode_t profile_rename_section(profile_t p, const char **nullterm, errcode_t profile_add_relation(profile_t p, const char **nullterm, const char *new_val = NULL); +#ifdef SWIGTCL %include "tclsh.i" +#endif -- 2.26.2