Index: practcl.tcl ================================================================== --- practcl.tcl +++ practcl.tcl @@ -3,11 +3,11 @@ # An object oriented templating system for stamping out Tcl API calls to C ### puts [list LOADED practcl.tcl from [info script]] package require TclOO -# Do nothing. A handy way of +# Do nothing. A handy way of proc ::noop args {} proc ::debug args { #puts $args ::practcl::cputs ::DEBUG_INFO $args @@ -137,15 +137,15 @@ dict set result $key $value } dict set result sandbox [file dirname [dict get $result srcdir]] dict set result download [file join [dict get $result sandbox] download] dict set result teapot [file join [dict get $result sandbox] teapot] - set result [::practcl::de_shell $result] + set result [::practcl::de_shell $result] } - # If data is available from autoconf, defer to that + # If data is available from autoconf, defer to that if {[dict exists $result TEACUP_OS] && [dict get $result TEACUP_OS] ni {"@TEACUP_OS@" {}}} { - return $result + return $result } # If autoconf hasn't run yet, assume we are not cross compiling # and defer to local checks dict set result TEACUP_PROFILE unknown dict set result TEACUP_OS unknown @@ -198,11 +198,11 @@ if {$arch eq "unknown"} { catch {set arch [exec uname -m]} } switch -glob $arch { i*86 { - set arch "ix86" + set arch "ix86" } amd64 { set arch "x86_64" } } @@ -602,11 +602,11 @@ # a line feed. Unlike puts, blank links in the interstitial are # suppressed proc ::practcl::cputs {varname args} { upvar 1 $varname buffer if {[llength $args]==1 && [string length [string trim [lindex $args 0]]] == 0} { - + } if {[info exist buffer]} { if {[string index $buffer end] ne "\n"} { append buffer \n } @@ -696,11 +696,11 @@ set version [lindex $line 3] break } # Look for a package provide statement foreach line [split $dat \n] { - set line [string trim $line] + set line [string trim $line] if { [string range $line 0 14] != "package provide" } continue set package [lindex $line 2] set version [lindex $line 3] break } @@ -713,11 +713,11 @@ close $fin if {![regexp "package provide" $dat]} continue set fname [file rootname [file tail $file]] # Look for a package provide statement foreach line [split $dat \n] { - set line [string trim $line] + set line [string trim $line] if { [string range $line 0 14] != "package provide" } continue set package [lindex $line 2] set version [lindex $line 3] if {[string index $package 0] in "\$ \["} continue if {[string index $version 0] in "\$ \["} continue @@ -747,11 +747,11 @@ if {[regexp "if.*package.*vsatisfies.*package.*provide.*return" $thisline]} continue if {![regexp "package.*ifneeded" $thisline]} { # This package index contains arbitrary code # source instead of trying to add it to the master # package index - return {source [file join $dir pkgIndex.tcl]} + return {source [file join $dir pkgIndex.tcl]} } append buffer $thisline \n } on error {err opts} { puts *** puts "GOOF: $pkgidxfile" @@ -795,25 +795,25 @@ set path_indexed($path) 0 } set path_indexed($base) 1 set path_indexed([file join $base boot tcl]) 1 #set path_index([file join $base boot tk]) 1 - + foreach path $paths { if {$path_indexed($path)} continue set thisdir [file_relative $base $path] #set thisdir [string range $path $i+1 end] set idxbuf [::practcl::_pkgindex_directory $path] if {[string length $idxbuf]} { incr path_indexed($path) append buffer "set dir \[set PKGDIR \[file join \[lindex \$::PATHSTACK end\] $thisdir\]\]" \n append buffer [string map {$dir $PKGDIR} [string trimright $idxbuf]] \n - } + } } } append buffer { -set dir [lindex $::PATHSTACK end] +set dir [lindex $::PATHSTACK end] set ::PATHSTACK [lrange $::PATHSTACK 0 end-1] } return $buffer } @@ -863,21 +863,21 @@ } } ::oo::class create ::practcl::metaclass { superclass ::oo::object - + method script script { eval $script } - + method source filename { source $filename } - + method initialize {} {} - + method define {submethod args} { my variable define switch $submethod { dump { return [array get define] @@ -950,11 +950,11 @@ oo::objdefine [self] forward <${stub}> $object oo::objdefine [self] export <${stub}> } return $object } - + method organ {{stub all}} { my variable organs if {![info exists organs]} { return {} } @@ -963,11 +963,11 @@ } if {[dict exists $organs $stub]} { return [dict get $organs $stub] } } - + method link {command args} { my variable links switch $command { object { foreach obj $args { @@ -1018,11 +1018,11 @@ dump { return [array get links] } } } - + method select {} { my variable define set class {} if {[info exists define(class)]} { if {[info command $define(class)] ne {}} { @@ -1133,19 +1133,19 @@ } set idx $ndx } return $defs } - + proc ::practcl::build::tclkit_main {PROJECT PKG_OBJS} { ### # Build static package list ### set statpkglist {} dict set statpkglist Tk {autoload 0} puts [list TCLKIT MAIN $PROJECT] - + foreach {ofile info} [${PROJECT} compile-products] { puts [list * PROD $ofile $info] if {![dict exists $info object]} continue set cobj [dict get $info object] foreach {pkg info} [$cobj static-packages] { @@ -1157,21 +1157,21 @@ foreach {pkg info} [$cobj static-packages] { puts [list * PKG $pkg $info] dict set statpkglist $pkg $info } } - + set result {} $PROJECT include {} $PROJECT include {"tclInt.h"} $PROJECT include {"tclFileSystem.h"} $PROJECT include {} $PROJECT include {} $PROJECT include {} $PROJECT include {} $PROJECT include {} - + $PROJECT code header { #ifndef MODULE_SCOPE # define MODULE_SCOPE extern #endif @@ -1191,11 +1191,11 @@ #undef Tcl_NewStringObj #undef Tk_Init #undef Tk_MainEx #undef Tk_SafeInit } - + # Build an area of the file for #define directives and # function declarations set define {} set mainhook [$PROJECT define get TCL_LOCAL_MAIN_HOOK Tclkit_MainHook] set mainfunc [$PROJECT define get TCL_LOCAL_APPINIT Tclkit_AppInit] @@ -1202,11 +1202,11 @@ set mainscript [$PROJECT define get main.tcl main.tcl] set vfsroot [$PROJECT define get vfsroot zipfs:/app] set vfs_main "${vfsroot}/${mainscript}" set vfs_tcl_library "${vfsroot}/boot/tcl" set vfs_tk_library "${vfsroot}/boot/tk" - + set map {} foreach var { vfsroot mainhook mainfunc vfs_main vfs_tcl_library vfs_tk_library } { dict set map %${var}% [set $var] @@ -1238,11 +1238,11 @@ } # We have to initialize the virtual filesystem before calling # Tcl_Init(). Otherwise, Tcl_Init() will not be able to find # its startup script files. $PROJECT include {"tclZipfs.h"} - + ::practcl::cputs zvfsboot " if(!Tclzipfs_Mount(NULL, archive, \"%vfsroot%\", NULL)) \x7B " ::practcl::cputs zvfsboot { Tcl_Obj *vfsinitscript; vfsinitscript=Tcl_NewStringObj("%vfs_main%",-1); Tcl_IncrRefCount(vfsinitscript); @@ -1274,29 +1274,29 @@ }])\;" ::practcl::cputs zvfsboot " \x7D" ::practcl::cputs zvfsboot " return TCL_OK;" - + if {[$PROJECT define get os] eq "windows"} { set header {int %mainhook%(int *argc, TCHAR ***argv)} } else { set header {int %mainhook%(int *argc, char ***argv)} } $PROJECT c_function [string map $map $header] [string map $map $zvfsboot] - + practcl::cputs appinit "int %mainfunc%(Tcl_Interp *interp) \x7B" - + # Build AppInit() set appinit {} - practcl::cputs appinit { + practcl::cputs appinit { if ((Tcl_Init)(interp) == TCL_ERROR) { return TCL_ERROR; } } set main_init_script {} - + foreach {statpkg info} $statpkglist { set initfunc {} if {[dict exists $info initfunc]} { set initfunc [dict get $info initfunc] } @@ -1307,11 +1307,11 @@ # package is actually loaded into the interpreter $PROJECT code header "extern Tcl_PackageInitProc $initfunc\;\n" set script [list package ifneeded $statpkg [dict get $info version] [list ::load {} $statpkg]] append main_init_script \n [list set ::kitpkg(${statpkg}) $script] if {[dict get $info autoload]} { - ::practcl::cputs appinit " if(${initfunc}(interp)) return TCL_ERROR\;" + ::practcl::cputs appinit " if(${initfunc}(interp)) return TCL_ERROR\;" ::practcl::cputs appinit " Tcl_StaticPackage(interp,\"$statpkg\",$initfunc,NULL)\;" } else { ::practcl::cputs appinit "\n Tcl_StaticPackage(NULL,\"$statpkg\",$initfunc,NULL)\;" append main_init_script \n $script } @@ -1433,12 +1433,12 @@ set map {} lappend map {${PKG_OBJECTS}} %LIBRARY_OBJECTS% lappend map {$(PKG_OBJECTS)} %LIBRARY_OBJECTS% lappend map {${PKG_STUB_OBJECTS}} %LIBRARY_STUB_OBJECTS% lappend map {$(PKG_STUB_OBJECTS)} %LIBRARY_STUB_OBJECTS% - - lappend map %LIBRARY_NAME% [dict get $data name] + + lappend map %LIBRARY_NAME% [dict get $data name] lappend map %LIBRARY_VERSION% [dict get $data version] lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} [dict get $data version]] if {[dict exists $data libprefix]} { lappend map %LIBRARY_PREFIX% [dict get $data libprefix] } else { @@ -1516,11 +1516,11 @@ append cmd " -c [dict get $info cfile] -o \$@\n\t" ::practcl::cputs result $cmd } set map {} - lappend map %LIBRARY_NAME% $proj(name) + lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %LIBRARY_PREFIX% [$PROJECT define getnull libprefix] if {[string is true [$PROJECT define get SHARED_BUILD]]} { @@ -1535,11 +1535,11 @@ " #lappend map %OUTFILE% {\[$]@} lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% "\$(${NAME}_OBJS)" - ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" + ::practcl::cputs result "$outfile: \$(${NAME}_OBJS)" ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_SHARED_LIB]]" if {[$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL] ni {: {}}} { ::practcl::cputs result "\t[string map $map [$PROJECT define get PRACTCL_VC_MANIFEST_EMBED_DLL]]" } ::practcl::cputs result {} @@ -1593,25 +1593,25 @@ if {[info exists proc(CXX)]} { set COMPILECPP "$proj(CXX) $defs $INCLUDES $proj(CFLAGS_DEBUG) -ggdb \ $proj(DEFS) $proj(CFLAGS_WARNING)" } else { set COMPILECPP $COMPILE - } + } } else { set COMPILE "$proj(CC) $proj(CFLAGS) $defs $INCLUDES " if {[info exists proc(CXX)]} { set COMPILECPP "$proj(CXX) $defs $INCLUDES $proj(CFLAGS) $proj(DEFS)" } else { set COMPILECPP $COMPILE } } - + set products [compile-sources $PROJECT $COMPILE $COMPILECPP] - + set map {} - lappend map %LIBRARY_NAME% $proj(name) + lappend map %LIBRARY_NAME% $proj(name) lappend map %LIBRARY_VERSION% $proj(version) lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $proj(version)] lappend map %OUTFILE% $outfile lappend map %LIBRARY_OBJECTS% $products lappend map {${CFLAGS}} "$proj(CFLAGS_DEFAULT) $proj(CFLAGS_WARNING)" @@ -1628,11 +1628,11 @@ exec {*}$cmd >&@ stdout } } else { set cmd [string map $map [$PROJECT define get PRACTCL_STATIC_LIB]] puts $cmd - exec {*}$cmd >&@ stdout + exec {*}$cmd >&@ stdout } } ### # Produce a static executable @@ -1687,27 +1687,27 @@ set cpath [::practcl::file_relative $path [file normalize $include]] if {$cpath ni $includedir} { lappend includedir $cpath } } - + set INCLUDES "-I[join $includedir " -I"]" if {$debug} { set COMPILE "$TCL(cc) $TCL(shlib_cflags) $TCL(cflags_debug) -ggdb \ $TCL(cflags_warning) $TCL(extra_cflags) $INCLUDES" } else { set COMPILE "$TCL(cc) $TCL(shlib_cflags) $TCL(cflags_optimize) \ -$TCL(cflags_warning) $TCL(extra_cflags) $INCLUDES" +$TCL(cflags_warning) $TCL(extra_cflags) $INCLUDES" } append COMPILE " " $defs lappend OBJECTS {*}[compile-sources $PROJECT $COMPILE $COMPILE] - + if {[${PROJECT} define get platform] eq "windows"} { set RSOBJ [file join $path build tclkit.res.o] set RCSRC [${PROJECT} define get kit_resource_file] if {$RCSRC eq {} || ![file exists $RCSRC]} { - set RCSRC [file join $TKSRCDIR win rc wish.rc] + set RCSRC [file join $TKSRCDIR win rc wish.rc] } set cmd [list windres -o $RSOBJ -DSTATIC_BUILD] set TCLSRC [file normalize $TCLSRCDIR] set TKSRC [file normalize $TKSRCDIR] @@ -1734,11 +1734,11 @@ $TCL(cflags_warning) $TCL(extra_cflags) $INCLUDES" } else { set cmd "$TCL(cc) $TCL(shlib_cflags) $TCL(cflags_optimize) \ $TCL(cflags_warning) $TCL(extra_cflags) $INCLUDES" } - append cmd " $OBJECTS" + append cmd " $OBJECTS" append cmd " $EXTERN_OBJS " # On OSX it is impossibly to generate a completely static # executable if {[$PROJECT define get TEACUP_OS] ne "macosx"} { append cmd " -static " @@ -1745,14 +1745,14 @@ } parray TCL if {$debug} { if {$os eq "windows"} { append cmd " -L${TCL(src_dir)}/win -ltcl86g" - append cmd " -L${TK(src_dir)}/win -ltk86g" + append cmd " -L${TK(src_dir)}/win -ltk86g" } else { append cmd " -L${TCL(src_dir)}/unix -ltcl86g" - append cmd " -L${TK(src_dir)}/unix -ltk86g" + append cmd " -L${TK(src_dir)}/unix -ltk86g" } } else { append cmd " $TCL(build_lib_spec) $TK(build_lib_spec)" } foreach obj $PKG_OBJS { @@ -1763,14 +1763,14 @@ append cmd " [$obj linker-external $config($obj)]" } if {$debug} { if {$os eq "windows"} { append cmd " -L${TCL(src_dir)}/win ${TCL(stub_lib_flag)}" - append cmd " -L${TK(src_dir)}/win ${TK(stub_lib_flag)}" + append cmd " -L${TK(src_dir)}/win ${TK(stub_lib_flag)}" } else { append cmd " -L${TCL(src_dir)}/unix ${TCL(stub_lib_flag)}" - append cmd " -L${TK(src_dir)}/unix ${TK(stub_lib_flag)}" + append cmd " -L${TK(src_dir)}/unix ${TK(stub_lib_flag)}" } } else { append cmd " $TCL(build_stub_lib_spec)" append cmd " $TK(build_stub_lib_spec)" } @@ -1790,16 +1790,16 @@ set data [uplevel 2 [list subst $info]] array set define $data my select my initialize } - + method do {} { my variable domake return $domake } - + method check {} { my variable needs_make domake if {$domake} { return 1 } @@ -1824,11 +1824,11 @@ set needs_make 1 } } return $needs_make } - + method triggers {} { my variable triggered domake define if {$triggered} { return $domake } @@ -1887,22 +1887,22 @@ method include_dir args { my define add include_dir {*}$args } - + method include_directory args { my define add include_dir {*}$args } method Collate_Source CWD {} - + method child {method} { return {} } - + method InitializeSourceFile filename { my define set filename $filename set class {} switch [file extension $filename] { .tcl { @@ -1934,20 +1934,20 @@ if {$class ne {}} { oo::objdefine [self] class $class my initialize } } - + method add args { my variable links set object [::practcl::object new [self] {*}$args] foreach linktype [$object linktype] { lappend links($linktype) $object } return $object } - + method go {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable links foreach {linktype objs} [array get links] { foreach obj $objs { @@ -1954,24 +1954,24 @@ $obj go } } debug [list /[self] [self method] [self class]] } - + method code {section body} { my variable code ::practcl::cputs code($section) $body } - + method Ofile filename { set lpath [my define get localpath] if {$lpath eq {}} { set lpath [my define get name] } return ${lpath}_[file rootname [file tail $filename]].o } - + method compile-products {} { set filename [my define get filename] set result {} if {$filename ne {}} { if {[my define exists ofile]} { @@ -1985,11 +1985,11 @@ foreach item [my link list subordinate] { lappend result {*}[$item compile-products] } return $result } - + method generate-include-directory {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result [my define get include_dir] foreach obj [my link list product] { foreach path [$obj generate-include-directory] { @@ -1996,11 +1996,11 @@ lappend result $path } } return $result } - + method generate-debug {{spaces {}}} { set result {} ::practcl::cputs result "$spaces[list [self] [list class [info object class [self]] filename [my define get filename]] links [my link list]]" foreach item [my link list subordinate] { practcl::cputs result [$item generate-debug "$spaces "] @@ -2053,11 +2053,11 @@ # Add the initializer wrapper for the class ::practcl::cputs result "static int ${thisclass}_OO_Init(Tcl_Interp *interp)\;" } return $result } - + method generate-public-define {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-define)]} { @@ -2067,11 +2067,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-define] } return $result } - + method generate-public-macro {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(public-macro)]} { @@ -2081,11 +2081,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-macro] } return $result } - + method generate-public-typedef {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-typedef)]} { @@ -2107,11 +2107,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-typedef] } return $result } - + method generate-private-typedef {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-typedef)]} { @@ -2133,11 +2133,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-private-typedef] } return $result } - + method generate-public-structure {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(public-structure)]} { @@ -2156,12 +2156,12 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-structure] } return $result } - - + + method generate-private-structure {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cstruct set result {} if {[info exists code(private-structure)]} { @@ -2180,11 +2180,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-private-structure] } return $result } - + method generate-public-headers {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code tcltype set result {} if {[info exists code(public-header)]} { @@ -2208,11 +2208,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-headers] } return $result } - + method generate-stub-function {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} foreach mod [my link list product] { @@ -2223,37 +2223,37 @@ if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info export]} continue dict set result $funcname [dict get $info header] } - } + } return $result } - + method generate-public-function {} { - debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] + debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code cfunct tcltype set result {} - + if {[my define get initfunc] ne {}} { ::practcl::cputs result "int [my define get initfunc](Tcl_Interp *interp);" } if {[info exists cfunct]} { foreach {funcname info} $cfunct { if {![dict get $info public]} continue ::practcl::cputs result "[dict get $info header]\;" } - } + } set result [::practcl::_tagblock $result c [my define get filename]] foreach mod [my link list product] { ::practcl::cputs result [$mod generate-public-function] } return $result } - + method generate-public-includes {} { - debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] + debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set includes {} foreach item [my define get public-include] { if {$item ni $includes} { lappend includes $item } @@ -2294,11 +2294,11 @@ set includes [my generate-public-includes] foreach inc $includes { if {[string index $inc 0] ni {< \"}} { ::practcl::cputs result "#include \"$inc\"" } else { - ::practcl::cputs result "#include $inc" + ::practcl::cputs result "#include $inc" } } foreach method { generate-public-define @@ -2308,17 +2308,17 @@ } { ::practcl::cputs result "/* BEGIN SECTION $method */" ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } - + foreach file [my generate-public-verbatim] { ::practcl::cputs result "/* BEGIN $file */" ::practcl::cputs result [::practcl::cat $file] ::practcl::cputs result "/* END $file */" } - + foreach method { generate-public-headers generate-public-function } { ::practcl::cputs result "/* BEGIN SECTION $method */" @@ -2325,11 +2325,11 @@ ::practcl::cputs result [my $method] ::practcl::cputs result "/* END SECTION $method */" } return $result } - + method IncludeAdd {headervar args} { upvar 1 $headervar headers foreach inc $args { if {[string index $inc 0] ni {< \"}} { set inc "\"$inc\"" @@ -2337,11 +2337,11 @@ if {$inc ni $headers} { lappend headers $inc } } } - + ### # This methods generates the contents of an amalgamated .c file # which implements the loader for a batch of tools ### method generate-c {} { @@ -2348,17 +2348,17 @@ debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result { /* This file was generated by practcl */ } set includes {} - + foreach mod [my link list product] { # Signal modules to formulate final implementation $mod go } set headers {} - + my IncludeAdd headers if {[my define get tk 0]} { my IncludeAdd headers } if {[my define get output_h] ne {}} { @@ -2378,11 +2378,11 @@ generate-private-typedef generate-private-structure generate-cstruct generate-constant generate-cfunct - generate-cmethod + generate-cmethod } { set dat [my $method] if {[string length [string trim $dat]]} { ::practcl::cputs result "/* BEGIN $method [my define get filename] */" ::practcl::cputs result $dat @@ -2429,11 +2429,11 @@ ::practcl::cputs result " if (Tcl_PkgProvide(interp, \"[my define get pkg_name [my define get name]]\" , \"[my define get pkg_vers [my define get version]]\" )) return TCL_ERROR\;" } ::practcl::cputs result " return TCL_OK\;\n\}\n" return $result } - + ### # This methods generates any Tcl script file # which is required to pre-initialize the C library ### method generate-tcl-pre {} { @@ -2462,11 +2462,11 @@ foreach mod [my link list product] { ::practcl::cputs result [$mod generate-tcl-post] } return $result } - + method static-packages {} { set result [my define get static_packages] set statpkg [my define get static_pkg] set initfunc [my define get initfunc] if {$initfunc ne {}} { @@ -2482,30 +2482,30 @@ dict set result $pkg $info } } return $result } - + method target {method args} { switch $method { is_unix { return [expr {$::tcl_platform(platform) eq "unix"}] } } } - + } ::oo::class create ::practcl::product { superclass ::practcl::object - + method linktype {} { return {subordinate product} } - + method include header { my define add include $header } - + method cstructure {name definition {argdat {}}} { my variable cstruct dict set cstruct $name body $definition foreach {f v} $argdat { dict set cstruct $name $f $v @@ -2512,11 +2512,11 @@ } if {![dict exists $cstruct $name public]} { dict set cstruct $name public 1 } } - + method generate-cinit {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] my variable code set result {} if {[info exists code(cinit)]} { @@ -2538,13 +2538,13 @@ # instead the contribute to the amalgamation # of the main library file ### ::oo::class create ::practcl::dynamic { superclass ::practcl::product - + # Retrieve any additional source files required - + method compile-products {} { set filename [my define get output_c] set result {} if {$filename ne {}} { if {[my define exists ofile]} { @@ -2569,11 +2569,11 @@ foreach item [my link list subordinate] { lappend result {*}[$item compile-products] } return $result } - + method implement path { my go my Collate_Source $path if {[my define get output_c] eq {}} return set filename [file join $path [my define get output_c]] @@ -2589,11 +2589,11 @@ puts $fout " return TCL_OK\;" puts $fout "\x7D" } close $fout } - + method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } @@ -2603,15 +2603,15 @@ if {[my define get localpath] eq {}} { my define set localpath [my define get localpath]_[my define get name] } ::source $filename } - + method linktype {} { return {subordinate product dynamic} } - + ### # Populate const static data structures ### method generate-cstruct {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] @@ -2625,11 +2625,11 @@ if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cstruct] } return $result } - + method generate-constant {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set result {} my variable code cstruct methods tcltype if {[info exists code(constant)]} { @@ -2666,15 +2666,15 @@ if {[info exists tcltype]} { foreach {type info} $tcltype { dict with info {} ::practcl::cputs result "const Tcl_ObjType $cname = \{\n .freeIntRepProc = &${freeproc},\n .dupIntRepProc = &${dupproc},\n .updateStringProc = &${updatestringproc},\n .setFromAnyProc = &${setfromanyproc}\n\}\;" } - } + } if {[info exists methods]} { set mtypes {} - foreach {name info} $methods { + foreach {name info} $methods { set callproc [dict get $info callproc] set methodtype [dict get $info methodtype] if {$methodtype in $mtypes} continue lappend mtypes $methodtype ### @@ -2710,11 +2710,11 @@ if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-constant] } return $result } - + ### # Generate code that provides subroutines called by # Tcl API methods ### method generate-cfunct {} { @@ -2749,11 +2749,11 @@ my variable code methods tclprocs set result {} if {[info exists code(method)]} { ::practcl::cputs result $code(method) } - + if {[info exists tclprocs]} { foreach {name info} $tclprocs { if {![dict exists $info body]} continue set callproc [dict get $info callproc] set header [dict get $info header] @@ -2761,11 +2761,11 @@ ::practcl::cputs result "/* Tcl Proc $name */" ::practcl::cputs result "${header} \{${body}\}" } } - + if {[info exists methods]} { set thisclass [my define get cclass] foreach {name info} $methods { if {![dict exists $info body]} continue set callproc [dict get $info callproc] @@ -2783,11 +2783,11 @@ */ Tcl_Obj* nameObj; /* Name of a class or method being looked up */ Tcl_Object curClassObject; /* Tcl_Object representing the current class */ Tcl_Class curClass; /* Tcl_Class representing the current class */ - /* + /* * Find the "@TCLCLASS@" class, and attach an 'init' method to it. */ nameObj = Tcl_NewStringObj("@TCLCLASS@", -1); Tcl_IncrRefCount(nameObj); @@ -2822,11 +2822,11 @@ Tcl_DecrRefCount(nameObj); }] } } } - ::practcl::cputs result " return TCL_OK\;\n\}\n" + ::practcl::cputs result " return TCL_OK\;\n\}\n" } foreach obj [my link list dynamic] { # Exclude products that will generate their own C files if {[$obj define get output_c] ne {}} continue ::practcl::cputs result [$obj generate-cmethod] @@ -2838,11 +2838,11 @@ if {[my define get initfunc] eq {}} { return "/* [my define get filename] declared not initfunc */" } return " if([my define get initfunc](interp)) return TCL_ERROR\;" } - + ### # Generate code that runs when the package/module is # initialized into the interpreter ### method generate-cinit {} { @@ -2857,11 +2857,11 @@ if(!modPtr) { modPtr = Tcl_CreateNamespace(interp, "@NSPACE@", NULL, NULL); } }] } - ::practcl::cputs result " \}" + ::practcl::cputs result " \}" } if {[info exists code(tclinit)]} { ::practcl::cputs result $code(tclinit) } if {[info exists code(cinit)]} { @@ -2882,11 +2882,11 @@ ::practcl::cputs result [string map $map { Tcl_CreateObjCommand(interp,"@NAME@",(Tcl_ObjCmdProc *)@CALLPROC@,NULL,NULL);}] } } } } - + if {[info exists code(nspace)]} { ::practcl::cputs result " \{\n Tcl_Namespace *modPtr;" foreach nspace $code(nspace) { ::practcl::cputs result [string map [list @NSPACE@ $nspace] { modPtr=Tcl_FindNamespace(interp,"@NSPACE@",NULL,TCL_NAMESPACE_ONLY); @@ -2945,30 +2945,30 @@ # Could not parse that block as a function # append it verbatim to our c_implementation ::practcl::cputs code(funct) "$header [list $body]" } - + method cmethod {name body {arginfo {}}} { my variable methods code foreach {f v} $arginfo { dict set methods $name $f $v } dict set methods $name body "Tcl_Object thisObject = Tcl_ObjectContextObject(objectContext); /* The current connection object */ $body" } - + method c_tclproc_nspace nspace { my variable code if {![info exists code(nspace)]} { set code(nspace) {} } if {$nspace ni $code(nspace)} { lappend code(nspace) $nspace } } - + method c_tclproc_raw {name body {arginfo {}}} { my variable tclprocs code foreach {f v} $arginfo { dict set tclprocs $name $f $v @@ -2981,11 +2981,11 @@ next my variable methods code cstruct tclprocs if {[info exists methods]} { debug [self] methods [my define get cclass] set thisclass [my define get cclass] - foreach {name info} $methods { + foreach {name info} $methods { # Provide a callproc if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} OOMethod_${thisclass}_${name}]] dict set methods $name callproc $callproc } else { @@ -3011,11 +3011,11 @@ if {![dict exists $info callproc]} { set callproc [string map {____ _ ___ _ __ _} [string map {{ } _ : _} TclCmd_${thisnspace}_${name}]] dict set tclprocs $name callproc $callproc } else { set callproc [dict get $info callproc] - } + } if {[dict exists $info body] && ![dict exists $info header]} { dict set tclprocs $name header "static int ${callproc}(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv\[\])" } } } @@ -3025,11 +3025,11 @@ # Once an object marks itself as some # flavor of dynamic, stop trying to morph # it into something else method select {} {} - + method tcltype {name argdat} { my variable tcltype foreach {f v} $argdat { dict set tcltype $name $f $v } @@ -3071,33 +3071,33 @@ superclass ::practcl::product } ::oo::class create ::practcl::clibrary { superclass ::practcl::product - + method linker-products {configdict} { return [my define get filename] } - + } ### # In the end, all C code must be loaded into a module # This will either be a dynamically loaded library implementing # a tcl extension, or a compiled in segment of a custom shell/app ### ::oo::class create ::practcl::module { superclass ::practcl::dynamic - + method child which { switch $which { organs { return [list project [my define get project] module [self]] } } } - + method initialize {} { set filename [my define get filename] if {$filename eq {}} { return } @@ -3108,11 +3108,11 @@ my define set localpath [my define get name]_[my define get name] } debug [self] SOURCE $filename my source $filename } - + method implement path { my go my Collate_Source $path foreach item [my link list dynamic] { if {[catch {$item implement $path} err]} { @@ -3141,11 +3141,11 @@ debug [list /[self] [self method] [self class]] } method linktype {} { return {subordinate product dynamic module} - } + } } ::oo::class create ::practcl::autoconf { ### @@ -3221,11 +3221,11 @@ } array set define $contents my select my initialize } - + method add_project {pkg info {oodefine {}}} { set os [my define get os] if {$os eq {}} { set os [::practcl::os] @@ -3250,25 +3250,25 @@ oo::objdefine $obj $oodefine $obj define set masterpath $::CWD $obj go return $obj } - + method child which { switch $which { organs { # A library can be a project, it can be a module. Any # subordinate modules will indicate their existance return [list project [self] module [self]] } } } - + method linktype {} { return project } - + # Exercise the methods of a sub-object method project {pkg args} { set obj [namespace current]::PROJECT.$pkg if {[llength $args]==0} { return $obj @@ -3277,11 +3277,11 @@ } } ::oo::class create ::practcl::library { superclass ::practcl::project - + method compile-products {} { set result {} foreach item [my link list subordinate] { lappend result {*}[$item compile-products] } @@ -3290,11 +3290,11 @@ set ofile [file rootname [file tail $filename]]_main.o lappend result $ofile [list cfile $filename extra [my define get extra] external [string is true -strict [my define get external]]] } return $result } - + method generate-tcl-loader {} { set result {} set PKGINIT [my define get pkginit] set PKG_NAME [my define get name [my define get pkg_name]] set PKG_VERSION [my define get pkg_vers [my define get version]] @@ -3314,11 +3314,11 @@ package provide @PKG_NAME@ @PKG_VERSION@ }] } return $result } - + method go {} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set name [my define getnull name] if {$name eq {}} { set name generic @@ -3385,11 +3385,11 @@ ** any changes will be overwritten the next time it is run */}] puts $cout [my generate-c] puts $cout [my generate-loader] close $cout - + set macro HAVE_[string toupper [file rootname [my define get output_h]]]_H set hout [open [file join $path [my define get output_h]] w] puts $hout [subst {/* ** This file is generated by the [info script] script ** any changes will be overwritten the next time it is run @@ -3397,11 +3397,11 @@ puts $hout "#ifndef ${macro}" puts $hout "#define ${macro}" puts $hout [my generate-h] puts $hout "#endif" close $hout - + set output_tcl [my define get output_tcl] if {$output_tcl ne {}} { set tclout [open [file join $path [my define get output_tcl]] w] puts $tclout "### # This file is generated by the [info script] script @@ -3415,25 +3415,25 @@ } method generate-decls {pkgname path} { debug [list [self] [self method] [self class] -- [my define get filename] [info object class [self]]] set outfile [file join $path/$pkgname.decls] - + ### # Build the decls file ### set fout [open $outfile w] puts $fout [subst {### # $outfile # # This file was generated by [info script] ### - + library $pkgname interface $pkgname }] - + ### # Generate list of functions ### set stubfuncts [my generate-stub-function] set thisline {} @@ -3443,16 +3443,16 @@ } puts $fout [list export "int [my define get initfunc](Tcl_Inter *interp)"] puts $fout [list export "char *[string totitle [my define get name]]_InitStubs(Tcl_Inter *interp, char *version, int exact)"] close $fout - + ### # Build [package]Decls.h ### set hout [open [file join $path ${pkgname}Decls.h] w] - + close $hout set cout [open [file join $path ${pkgname}StubInit.c] w] puts $cout [string map [list %pkgname% $pkgname %PkgName% [string totitle $pkgname]] { #ifndef USE_TCL_STUBS @@ -3508,23 +3508,23 @@ }] close $cout } # Backward compadible call - method generate-make path { + method generate-make path { ::practcl::build::Makefile $path [self] } - + method install-headers {} { set result {} return $result } method linktype {} { return library } - + # Create a "package ifneeded" # Args are a list of aliases for which this package will answer to method package-ifneeded {args} { set result {} set name [my define get pkg_name [my define get name]] @@ -3546,18 +3546,18 @@ set script "package require $name $version \; package provide $alias $version" append result \n\n [list package ifneeded $alias $version $script] } return $result } - - + + method shared_library {} { set name [string tolower [my define get name [my define get pkg_name]]] set NAME [string toupper $name] set version [my define get version [my define get pkg_vers]] set map {} - lappend map %LIBRARY_NAME% $name + lappend map %LIBRARY_NAME% $name lappend map %LIBRARY_VERSION% $version lappend map %LIBRARY_VERSION_NODOTS% [string map {. {}} $version] lappend map %LIBRARY_PREFIX% [my define getnull libprefix] set outfile [string map $map [my define get PRACTCL_NAME_LIBRARY]][my define get SHLIB_SUFFIX] return $outfile @@ -3564,11 +3564,11 @@ } } ::oo::class create ::practcl::tclkit { superclass ::practcl::library - + method Collate_Source CWD { my define set SHARED_BUILD 0 set name [my define get name] if {![my define exists TCL_LOCAL_APPINIT]} { @@ -3575,17 +3575,17 @@ my define set TCL_LOCAL_APPINIT Tclkit_AppInit } if {![my define exists TCL_LOCAL_MAIN_HOOK]} { my define set TCL_LOCAL_MAIN_HOOK Tclkit_MainHook } - + set PROJECT [self] set os [$PROJECT define get os] set TCLOBJ [$PROJECT project TCLCORE] set TKOBJ [$PROJECT project TKCORE] set ODIEOBJ [$PROJECT project odie] - + set TCLSRCDIR [$TCLOBJ define get srcroot] set TKSRCDIR [$TKOBJ define get srcroot] set PKG_OBJS {} foreach item [$PROJECT link list package] { if {[string is true [$item define get static]]} { @@ -3632,11 +3632,11 @@ set ODIESRCROOT [my project odie define get srcroot] set cdir [file join $ODIESRCROOT compat zipfs] my define add include_dir $cdir set zipfs [file join $cdir zvfs.c] } - + my add class csource filename $zipfs initfunc Tclzipfs_Init pkg_name zipfs pkg_vers 1.0 autoload 1 my define add include_dir [file join $TKSRCDIR generic] my define add include_dir [file join $TKSRCDIR $PLATFORM_SRC_DIR] my define add include_dir [file join $TKSRCDIR bitmaps] @@ -3645,11 +3645,11 @@ my define add include_dir [file join $TCLSRCDIR $PLATFORM_SRC_DIR] my define add include_dir [file join $TCLSRCDIR compat zlib] # This file will implement TCL_LOCAL_APPINIT and TCL_LOCAL_MAIN_HOOK ::practcl::build::tclkit_main $PROJECT $PKG_OBJS } - + ## Wrap an executable # method wrap {PWD exename vfspath args} { cd $PWD if {![file exists $vfspath]} { @@ -3676,11 +3676,11 @@ } #set BASEVFS [my define get BASEVFS] set EXEEXT [my define get EXEEXT] set tclkit_bare [my define get tclkit_bare] - + set buffer [::practcl::pkgindex_path $vfspath] puts $fout $buffer puts $fout { # Advertise statically linked packages foreach {pkg script} [array get ::kitpkg] { @@ -3700,13 +3700,13 @@ # Meta repository # The default is an inert source code block ### oo::class create ::practcl::subproject { superclass ::practcl::object - + method compile {} {} - + method go {} { set platform [my define get platform] my define get USEMSVC [my define get USEMSVC] set name [my define get name] if {![my define exists srcroot]} { @@ -3715,39 +3715,39 @@ set srcroot [my define get srcroot] my define set localsrcdir $srcroot my define add include_dir [file join $srcroot generic] my sources } - + # Install project into the local build system method install-local {} { my unpack } # Install project into the virtual file system - method install-vfs {} {} - + method install-vfs {} {} + method linktype {} { return {subordinate package} } - + method linker-products {configdict} {} method linker-external {configdict} { if {[dict exists $configdict PRACTCL_LIBS]} { return [dict get $configdict PRACTCL_LIBS] } } method sources {} {} - + method unpack {} { set name [my define get name] puts [list $name [self] UNPACK] my define set [::practcl::fossil_sandbox $name [my define dump]] } - + method update {} { set name [my define get name] my define set [::practcl::fossil_sandbox $name [dict merge [my define dump] {update 1}]] } } @@ -3760,11 +3760,11 @@ superclass ::practcl::subproject ::practcl::library method linktype {} { return {subordinate package source} } - + } # a copy from the teapot oo::class create ::practcl::subproject.teapot { superclass ::practcl::subproject @@ -3831,11 +3831,11 @@ lappend opts --host=[my define get TARGET] } if {[my define exists tclsrcdir]} { set TCLSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my define get tclsrcdir]]]] set TCLGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my define get tclsrcdir] .. generic]]] - lappend opts --with-tcl=$TCLSRCDIR --with-tclinclude=$TCLGENERIC + lappend opts --with-tcl=$TCLSRCDIR --with-tclinclude=$TCLGENERIC } if {[my define exists tksrcdir]} { set TKSRCDIR [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my define get tksrcdir]]]] set TKGENERIC [::practcl::file_relative [file normalize $builddir] [file normalize [file join $::CWD [my define get tksrcdir] .. generic]]] lappend opts --with-tk=$TKSRCDIR --with-tkinclude=$TKGENERIC @@ -3852,26 +3852,26 @@ } else { lappend opts --enable-shared } return $opts } - + method go {} { next my define set builddir [my BuildDir [my define get masterpath]] } - + method linker-products {configdict} { if {![my define get static 0]} { return {} } set srcdir [my define get builddir] if {[dict exists $configdict libfile]} { return " [file join $srcdir [dict get $configdict libfile]]" } } - + method static-packages {} { if {![my define get static 0]} { return {} } set result [my define get static_packages] @@ -3906,11 +3906,11 @@ method BuildDir {PWD} { set name [my define get name] return [my define get builddir [file join $PWD pkg.$name]] } - + method compile {} { set name [my define get name] set PWD $::CWD cd $PWD my go @@ -3943,11 +3943,11 @@ } } cd $PWD } - + method Configure {} { cd $::CWD my unpack my TeaConfig set builddir [file normalize [my define get builddir]] @@ -3964,11 +3964,11 @@ puts [list CONFIGURE {*}$opts] cd $builddir exec sh [file join $srcroot configure] {*}$opts >& [file join $builddir practcl.log] cd $::CWD } - + method install-vfs {} { set PWD [pwd] set PKGROOT [my define get installdir] set PREFIX [my define get prefix] @@ -4017,11 +4017,11 @@ file delete -force $BROKENROOT } } cd $PWD } - + method TeaConfig {} { set srcroot [file normalize [my define get srcroot]] set copytea 0 if {![file exists [file join $srcroot tclconfig]]} { set copytea 1 @@ -4059,11 +4059,11 @@ # On the windows platform MinGW must build # from the platform directory in the source repo method BuildDir {PWD} { return [my define get localsrcdir] } - + method Configure {} { if {[my define get USEMSVC 0]} { return } set opts [my ConfigureOpts] @@ -4089,11 +4089,11 @@ lappend opts --prefix=$PREFIX #--exec_prefix=$PREFIX lappend opts --disable-shared return $opts } - + method go {} { set name [my define get name] set platform [my define get platform] if {![my define exists srcroot]} { my define set srcroot [file join [my define get sandbox] $name] @@ -4110,12 +4110,12 @@ my define add include_dir [file join $srcroot $name unix] } } my define set builddir [my BuildDir [my define get masterpath]] } - + method linktype {} { return {subordinate core.library} } } package provide practcl 0.5