The OBJECT
C data type that Ctalk uses internally stores
objects’ values as C char *
’s.
See OBJECT typedef.
To store numeric values, you must format them as character strings,
using, for example, sprintf
. In many cases, however, Ctalk
performs this translation automatically.
Integer
objects can also translate values with atoi(3)
or __ctalkDecimalIntegerToASCII. Other scalar data types have
corresponding functions that translate numbers to character strings.
If for some reason you need to translate an object to its C type or back again, the Ctalk library provides the following functions.
__ctalkToCArrayElement (OBJECT *o)
Translate the value of an Integer,
Character,
String,
or LongInteger
array element to a void *
that points to its corresponding C data type.
__ctalkToCCharPtr (OBJECT *o, int keep)
Translate the value of a String
object into a C char *.
If keep is FALSE
, delete o.
__ctalkToCIntArrayElement (OBJECT *o)
Translate the value of an Integer
array element to an
int.
__ctalkToCInteger (OBJECT *
o, int
keep_object)
Translate the value of an Integer
to an int.
If
keep_object is FALSE,
then delete the object.
__ctalkToCInteger (OBJECT *
o, int
keep_object)
Translate the value of an Integer
to a long int.
If
keep_object is FALSE,
then delete the object.
__ctalk_to_c_char_ptr (OBJECT *o)
Translate the value of a String
object into a C char *.
Note: This function is being phased out. Use __ctalkToCCharPtr (),
above, instead.
__ctalk_to_c_double (OBJECT *o)
Translate the value of a Float
object into a C double.
__ctalk_to_c_int (OBJECT *o)
Translate the value of an Integer
object into a C int.
__ctalk_to_c_longlong (OBJECT *obj, int keep)
Translate the value of a LongInteger
object into a C long
long int.
If keep is non-zero, does not delete obj, or,
in compound expressions that need to interface with C variables, (like
complex if-statement conditionals), whether to delete the library’s
internal C variable registrations.
Formats the arguments of the second-most calling method and
prints them on the receiver. This function is meant to be used
within a method that is called by another method. One method that
uses this function is String : vPrintOn
. Refer to
String : vPrintOn
for an example of this function’s use.
See vPrintOn--class String
__ctalkCBoolToObj (bool b)
Create a Boolean
object with the boolean (either true or false)
value of the argument.
__ctalkCCharPtrToObj (char *s)
Create a String
object with the value s.
__ctalkClassLibraryPath (void)
Return a char *
containing the directories that Ctalk
searches for class libraries. When compiling programs Ctalk
searches first for directories given as arguments to the
‘-I’ option, then directories given by the
CLASSLIBDIRS
environment variable, then the standard
class library directory which is defined when Ctalk is
built. In addition, for each directory, if a subdirectory named
ctalk
exists, then Ctalk searches that subdirectory also.
The standard library directory defaults to
/usr/local/include/ctalk
, although if you define a
different ‘--prefix’ when building and installing
Ctalk, the class libraries will be located in
prefix/include/ctalk
.
If it is necessary to look up class libraries at run time,
Ctalk first searches the directories listed by the
CLASSLIBDIRS
environment variable, then the default
class library directory mentioned above.
__ctalkClassSearchPath (void)
A synonym for __ctalkClassLibraryPath(), above.
__ctalkCDoubleToObj (double f)
Create a Float
object with the value f.
__ctalkCIntToObj (int i)
Create an Integer
object with the value i.
__ctalkCLongLongToObj (long long int l)
Create a LongInteger
object with the value l.
__ctalkCSymbolToObj (unsigned int
label)
Create a Symbol
object with the value that is the address of
label. This is used for expressions where a function name
appears by itself, for example. In that case, the result is a
Symbol
object with the address of the function.
The functions that create objects give the objects the scope of the function call, either global or local.
Note: In future versions of Ctalk, the names of these functions are likely to change.