Joy Online Manual
NAME |
objc:declare - Declare C variables and functions |
SYNOPSIS |
objc:declare type variableSymbol
objc:declare returnType functionSymbol argumentTypesList
DESCRIPTION |
The objc:declare command gives you direct access to plain C functions and extern variables.
Declaring a C extern variableSymbol with a given type (in Joy syntax) sets up a Tcl variable with the same name which always holds a string representation of the C variable's value. Declaring a C functionSymbol with a given returnType and a list of its argument types is like using proc to define a Tcl command that calls the C function and does all the necessary value conversions for argument and return values. Variable argument lists are supported if the variable arguments are all of the same type as the last fixed argument (or {char *} if there aren't any); you don't have to declare the additional arguments, it suffices to append them to the call. The variableSymbol or functionSymbol parameter can also be a two-element list where the first element is the name of the Tcl variable or function and the second element is either the C name (if different from the Tcl name) or a pointer value giving the variable or function address. C names containing a colon are split into a module name (before the colon) and the real symbol name. This is only useful with Microsoft Window's dynamic loading mechanisms; the module name part is ignored on all other platforms. |
EXAMPLES |
tcl> set NSWhite
Error: can't read "NSWhite": no such variable
tcl> objc:declare float NSWhite
tcl> set NSWhite
1.0
tcl> cos 0
Error: invalid command name "cos"
tcl> objc:declare double cos double
tcl> cos 0
1.0
tcl> objc:declare int {alert NSRunAlertPanel} {id id id id id}
tcl> alert [@ Hello] [@ "Hello World!"] [@ "OK"] nil nil
1
SEE ALSO |
objc:call
objc:funcPtr
objc:typedef
objc:varPtr
proc |
KEYWORDS |
function, pointer, variable |
Index |