/usr/share/tcltk/critcl-iassoc1.0.1/iassoc.tcl is in critcl 3.1.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | ## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
# Pragmas for MetaData Scanner.
# @mdgen OWNER: iassoc.h
# CriTcl Utility Commands. Specification of a C function and structure
# associated with an interpreter made easy.
package provide critcl::iassoc 1.0.1
# # ## ### ##### ######## ############# #####################
## Requirements.
package require Tcl 8.4 ; # Min supported version.
package require critcl 3.1 ; # Need 'meta?' to get the package name.
package require critcl::util ; # Use the package's Get/Put commands.
namespace eval ::critcl::iassoc {}
# # ## ### ##### ######## ############# #####################
## API: Generate the declaration and implementation files for the iassoc.
proc ::critcl::iassoc::def {name arguments struct constructor destructor} {
critcl::at::caller
critcl::at::incrt $arguments ; set sloc [critcl::at::get*]
critcl::at::incrt $struct ; set cloc [critcl::at::get*]
critcl::at::incrt $constructor ; set dloc [critcl::at::get]
set struct $sloc$struct
set constructor $cloc$constructor
set destructor $dloc$destructor
# Arguments:
# - name of the C function which will provide access to the
# structure. This name, with a fixed prefix is also used to
# identify the association within the interpreter, and for
# the structure's type.
#
# - C code declaring the structure's contents.
# - C code executed to initialize the structure.
# - C code executed to destroy the structure.
# Note that this is, essentially, a singleton object, without
# methods.
# Pull the package we are working on out of the system.
set package [critcl::meta? name]
#puts "%%% Pkg |$package|"
#puts "%%% Name |$name|"
#puts "@@@ <<$data>>"
set stem ${package}_iassoc_${name}
set type ${name}_data
set label critcl::iassoc/p=$package/a=$name
set anames {}
if {[llength $arguments]} {
foreach {t v} $arguments {
lappend alist "$t $v"
lappend anames $v
}
set arguments ", [join $alist {, }]"
set anames ", [join $anames {, }]"
}
lappend map @package@ $package
lappend map @name@ $name
lappend map @stem@ $stem
lappend map @label@ $label
lappend map @type@ $type
lappend map @struct@ $struct
lappend map @argdecls@ $arguments
lappend map @argnames@ $anames
lappend map @constructor@ $constructor
lappend map @destructor@ $destructor
set hdr ${stem}.h
set header [file join [critcl::cache] $hdr]
set template [Template iassoc.h]
#puts T=[string length $template]
file mkdir [critcl::cache]
critcl::util::Put $header [string map $map $template]
critcl::ccode "#include <$hdr>"
return
}
proc ::critcl::iassoc::Template {path} {
variable selfdir
set path $selfdir/$path
#puts T=$path
return [critcl::util::Get $path]
}
# # ## ### ##### ######## ############# #####################
##
# Internal: Namespace holding the specification commands and related
# state. Treat like a sub-package, with a proper API.
##
# # ## ### ##### ######## ############# #####################
namespace eval ::critcl::iassoc::spec {}
# # ## ### ##### ######## ############# #####################
# # ## ### ##### ######## ############# #####################
## State
namespace eval ::critcl::iassoc {
variable selfdir [file dirname [file normalize [info script]]]
}
# # ## ### ##### ######## ############# #####################
## Export API
namespace eval ::critcl::iassoc {
namespace export def
catch { namespace ensemble create }
}
# # ## ### ##### ######## ############# #####################
## Ready
return
|