Skip to content

Commit

Permalink
tweak: main package - use Tcl_CreateObjCommand2, and map to old fun…
Browse files Browse the repository at this point in the history
…ction for 8.6 and before.

fix: compat layer, define `Tcl_NewSizeIntObj` for 9.0 and after.
  • Loading branch information
andreas-kupries committed Jan 10, 2024
1 parent 261ae22 commit e7408b5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/critcl/critcl.tcl
Expand Up @@ -3491,7 +3491,7 @@ proc ::critcl::c++command {tclname class constructors methods} {
append comproc " return TCL_ERROR;\n"
append comproc " \}\n"

append comproc " Tcl_CreateObjCommand(ip, Tcl_GetString(objv\[1]), cmdproc_$tclname, (ClientData) $classptr, delproc_$tclname);\n"
append comproc " Tcl_CreateObjCommand2(ip, Tcl_GetString(objv\[1]), cmdproc_$tclname, (ClientData) $classptr, delproc_$tclname);\n"
append comproc " return TCL_OK;\n"
#
# Build the body of the c function called when the object is deleted
Expand Down Expand Up @@ -4098,7 +4098,7 @@ proc ::critcl::scan::critcl::userconfig {cmd args} {

proc ::critcl::EmitShimHeader {wname} {
# Function head
set ca "(ClientData cd, Tcl_Interp *interp, int oc, Tcl_Obj *CONST ov\[])"
set ca "(ClientData cd, Tcl_Interp *interp, Tcl_Size oc, Tcl_Obj *CONST ov\[])"
Emitln
Emitln "static int"
Emitln "$wname$ca"
Expand Down Expand Up @@ -4705,7 +4705,7 @@ proc ::critcl::CollectEmbeddedSources {file destination libfile ininame placestu
} else {
set dp 0
}
puts $fd " Tcl_CreateObjCommand(interp, [PadRight [expr {$max+4}] ns_$name,] [PadRight [expr {$max+5}] tcl_$name,] $cd, $dp);"
puts $fd " Tcl_CreateObjCommand2(interp, [PadRight [expr {$max+4}] ns_$name,] [PadRight [expr {$max+5}] tcl_$name,] $cd, $dp);"
}

# Complete the trailer and be done.
Expand Down
12 changes: 12 additions & 0 deletions lib/critcl/critcl_c/tclpre9compat.h
Expand Up @@ -26,6 +26,18 @@
#define TCL_SIZE_MODIFIER ""
#define Tcl_GetSizeIntFromObj Tcl_GetIntFromObj
#define Tcl_NewSizeIntObj Tcl_NewIntObj
#else
#define Tcl_NewSizeIntObj Tcl_NewWideIntObj
#endif

/*
* - - -- --- ----- -------- ------------- ---------------------
* Critcl (3.2.1+) emits the command creation API using Tcl_Size by default.
* Map this to the older int-based API when compiling against Tcl 8.x or older.
*/

#if TCL_MAJOR_VERSION <= 8
#define Tcl_CreateObjCommand2 Tcl_CreateObjCommand
#endif

/*
Expand Down
2 changes: 1 addition & 1 deletion lib/critclf/wrapfort.tcl
Expand Up @@ -208,7 +208,7 @@ proc ::Wrapfort::ExternalInterfaces {arglist} {
proc ::Wrapfort::WriteTclCreateCommand {cmdname routine} {

Output2 [string map [list CMDNAME $cmdname ROUTINE $routine] \
" Tcl_CreateObjCommand( interp, \"CMDNAME\", c__ROUTINE, NULL, NULL );"]
" Tcl_CreateObjCommand2( interp, \"CMDNAME\", c__ROUTINE, NULL, NULL );"]
}


Expand Down

0 comments on commit e7408b5

Please sign in to comment.