This chapter describes the GemBuilder for C include files, data structures, and other reference information that may be useful when writing your application.
The following include files are provided for use with GemBuilder for C functions. These files are in the $GEMSTONE/include directory.
Your C source code should include one of these include files:
Using the GemStone C Statistics Interface (GCSI), as described in Chapter C, “GemStone C Statistics Interface”, include the following:
Defines all cache statistics. (For a list of cache statistics, refer to the “Monitoring GemStone” chapter of the System Administration Guide for GemStone/S 64 Bit.) |
|
The following include files are included by gciua.hf and/or gci.hf; you do not need to explicitly include any other files in order to use the GCI functions:
The GemStone/S 64 Bit distribution includes the file gcioop.ht, which defines C macros that define the OOPs of certain commonly used GemStone objects. Your code can compare these with any value of type OopType.
Note that the actual definition of these macros is subject to change without notice in future software releases. Your C application should refer to the OOPs of predefined GemStone objects by defined macro name only.
The following are some of the names for predefined GemStone objects Refer to $GEMSTONE/include/gcioop.ht for a complete list.
OOP_NIL (nil)
OOP_FALSE (false)
OOP_TRUE (true)
OOP_MinusOne
OOP_MinusTwo
OOP_Zero
OOP_One
OOP_Two
OOP_Three
OOP_Four
MAX_SMALL_INT
MIN_SMALL_INT
OOP_ASCII_NUL represents the first ASCII character OOP. Other Characters have specific OOPs, but no macros.
OOP_CLASS_className, where className is the name of a class (which may be uppercase or camelcase) Refer to gcioop.ht for specific names.
OOP_LAST_KERNEL_OOP (which has the same value as the last class)
he following C types are used by GemBuilder functions. The file
$GEMSTONE/include/gci.ht defines each of the GemBuilder types.
Enumerated type that defines the possible kinds of an IEEE binary float. |
|
A GemStone error report; see Error Report Structure - GciErrSType. |
|
A C++ class for a GemStone object information report; see Object Information Structure - GciObjInfoSType. |
|
A C++ class for an object report header; see Object Report Header - GciObjRepHdrSType. |
|
A C++ class for an object report; see Object Report Structure - GciObjRepSType. |
|
A traversal buffer; see Traversal Buffer - GciTravBufType. |
|
A structure for describing a user action (see User Action Information Structure - GciUserActionSType. |
GemBuilder includes some functions to facilitate access to objects of type DateTime. (These functions also make use of the C representation for time, time_t.)
The structured type GciDateTimeSType, which provides a C representation of an instance of class DateTime, contains the following fields:
typedef struct {
int year;
int dayOfYear;
int milliseconds;
OopType timeZone;
} GciDateTimeSType;
The year value must be less than 1,000,000.
In addition, a C mnemonic supports representation of DateTime objects.
#define GCI_SECONDS_PER_DAY 86400/* conversion constant */
An error report is a C structured type named GciErrSType. This structure contains the following fields:
The arguments (args) are specific to the error encountered. See the gcierr.ht file for a full list of errors and their arguments.
In the case of a compiler error, this is a single argument — the OOP of an array of error identifiers. Each identifier is an Array with three elements: (1) the error number (a SmallInteger); (2) the offset into the source string at which the error occurred (also a SmallInteger); and (3) the text of the error message (a String).
In the case of a fatal error, fatal is set to nonzero (TRUE). Your connection to GemStone is lost, and the current session ID (from GciGetSessionId) is reset to GCI_INVALID_SESSION_ID.
Object information is placed in a C++ class named GciObjInfoSType. Object information access functions provide information about objects in the database. These functions offer C-style access to much information that would otherwise be available only through calls to GemStone. For more information about the GciObjInfoSType structured type, refer to GciFetchObjImpl.
Object's total size in bytes or OOPs; see GciFetchSize_. |
||
Bits indicating the implementation format and mask. See gci.hf for the bit definitions. |
The object information class GciObjInfoSType provides the following functions:
unsigned char isInvariant( );
Returns non-zero if this object is invariant. Returns zero otherwise.
unsigned char isIndexable( );
Returns non-zero if this object is indexable. Returns zero otherwise.
unsigned char isPartial( );
Returns non-zero if the value buffer does not contain the entire object; that is, the operation truncated the object’s instance variables. Returns zero otherwise.
unsigned char isOverlayed( );
Returns non-zero if overlay semantics were used on this operation. Returns zero otherwise. When the traversal is overlayed, you can use OOP_ILLEGAL to mask out instance variables that you don’t want to modify, and then store into the remaining instance variables.
unsigned char objImpl( );
Returns an unsigned char in the range 0..3 that corresponds to the object’s implementation format. The mnemonics for these values are:
GC_FORMAT_OOP
GC_FORMAT_BYTE
GC_FORMAT_NSC
GC_FORMAT_SPECIAL
Each object report has two parts: a fixed-size header (as defined in the C++ class GciObjRepHdrSType) and a variable-size value buffer (an array of the values of the object’s instance variables):
class GciObjRepSType {
public:
GciObjRepHdrSType hdr; /* object report header */
union {
ByteType bytes[1]; /* Byte objects */
OopType oops[1]; /* Pointer objects */
} u;
The object report class GciObjRepSType provides these functions:
int64 usedBytes();
When constructing an object report buffer, returns the size of the object report, including any alignment considerations.
GciObjRepHdrSType* nextReport();
Given a pointer to an object report in a traversal buffer, this function increments the pointer by usedBytes (the size of the object report).
ByteType* valueBufferBytes();
Returns a pointer to the start of the body, as bytes.
OopType* valueBufferOops();
Returns a pointer to the start of the body, as OOPs.
An object report header is a C++ class named GciObjRepHdrSType. This class holds a general description of an object, and contains the following fields:
The object report header class GciObjRepHdrSType provides the following functions:
int64 idxSize();
Returns the number of indexable or varying instance variables.
void setIdxSize(int64 size);
Sets the number of indexable or varying instance variables.
void setIdxSizeBits(int64 size, unsigned char bits);
Sets both the indexable size and the eight bits defined by the enum of the mask values. Intended for GemStone use only.
int objImpl( );
Returns an integer in the range 0..3 that corresponds to the object’s implementation format. See the description on here.
int setObjImpl(int impl);
Defines the object’s implementation format. The argument must be an integer in the range 0..3 corresponding to the implementation format. You may use the mnemonics GC_FORMAT_OOP, GC_FORMAT_BYTE, GC_FORMAT_NSC, and GC_FORMAT_SPECIAL.
int64 objSize( );
Returns the total number of instance variables in the object (both indexable and named).
void clearBits( );
Sets indexable, invariable, partial, overlayed, non-readable, and clamped to FALSE.
unsigned char isClamped( );
Returns non-zero if this object report is clamped. Returns zero otherwise.
unsigned char noReadAuthorization( );
Returns non-zero if this object report is not readable. Returns zero otherwise.
unsigned char isInvariant( );
Returns non-zero if this object report is invariant. Returns zero otherwise.
unsigned char isIndexable( );
Returns non-zero if this object report is indexable. Returns zero otherwise.
unsigned char isPartial( );
Returns non-zero if the value buffer does not contain the entire object; that is, the traversal operation truncated the object’s instance variables. Returns zero otherwise.
unsigned char isOverlayed( );
Returns non-zero if overlay semantics were used on this store traversal operation. Returns zero otherwise. When the traversal is overlayed, you can use OOP_ILLEGAL to mask out instance variables that you don’t want to modify, and then store into the remaining instance variables.
void setIsClamped(unsigned char val);
If val is non-zero, make this object report clamped.
void setNoReadAuth(unsigned char val);
If val is non-zero, make this object report non-readable.
void setInvariant(unsigned char val);
If val is non-zero, make this object report invariant.
void setIndexable(unsigned char val);
If val is non-zero, make this object report indexable.
void setOverlayed(unsigned char val);
If val is non-zero, use overlay semantics on this store traversal.
ByteType* valueBufferBytes() ;
Returns a pointer to the start of the body, as bytes.
OopType* valueBufferOops()
Returns a pointer to the start of the body, as OOPs.
int64 usedBytes() ;
Returns the size (in bytes) of this object report, including the size of the header, value buffer, and any padding bytes needed at the end of the report so that the next report in the buffer begins on an address that is a multiple of 8.
GciObjRepHdrSType * nextReport() ;
Given a pointer to an object report in a traversal buffer, this function increments the pointer by usedBytes (the size of the object report).
During a store traversal operation, if the specified idxSize is inadequate to accommodate the contents of the value buffer (the values in u.bytes or u.oops), the store operation will automatically increase idxSize (the number of the object’s indexed variables) as needed. If the specified objClass is not indexable, then the idxSize is ignored; in addition, if there are more OOPs in the value buffer than there are named instance variables, and the object is not an NSC, an error will be generated.
During a store traversal operation, the firstOffset indicates where to begin storing values into the object’s array of instance variables. In that array, the object’s named instance variables are followed by its unnamed variables. If firstOffset is not 1, all instance variables (named or indexed) up to the firstOffset will be initialized to nil or 0. The firstOffset must be in the range (1, objSize+1).
The isInvariant() value is true if the object itself is invariant. This can happen in one of three ways:
The object’s class was created with instancesInvariant: true and the object has been committed.
The gcioc.ht include file defines four mnemonics that can be of assistance when you are handling the object implementation field (objImpl): GC_FORMAT_OOP, GC_FORMAT_BYTE, GC_FORMAT_NSC, and GC_FORMAT_SPECIAL. These mnemonics, and no other values, should be used to supply values for objImpl, or to test its contents. However, the gcioc.ht file also defines other mnemonics that can be used in other contexts related to object implementations, indexability, and invariance.
An object’s implementation may restrict the number of its named instance variables (namedSize) and its indexed instance variables (idxSize), as contained in the object report header.
For more information about object implementation types, see Structural Access to Objects.
GciStoreTravDoArgsSType holds traversal arguments, and is described in $GEMSTONE/include/gcicmn.ht. It contains the following fields:
The traversal buffer. For details, see Traversal Buffer - GciTravBufType. |
||
Flag bits that determines how the objects should be handled.
GCI_STORE_TRAV_DEFAULT = 0
GCI_STORE_TRAV_NSC_REP = 0x1,
GCI_STORE_TRAV_CREATE = 0x2
GCI_STORE_TRAV_FINISH_UPDATES = 0x8
GCI_STORE_TRAV_SWIZZLE_IN_PLACE = 0x10 |
||
|
||
Flags to disable or permit asynchronous events and debugging in Smalltalk. These flags apply whatever the value of doPerform.
|
||
One of three structures containing appropriate input fields for the specified operation.
For more information on these structs and how to use them, see gcicmn.ht. |
||
An array allocating memory for OOPs of objects that will be modified as a consequence of executing the specified code. |
||
The number of OOPs in alteredTheOops. On input, the caller must set this to the maximum number of OOPs that will fit in alteredTheOops. Upon completion, this field indicates the number of OOPs actually written to alteredTheOops. |
||
Upon output, TRUE if the alteredTheOops contains the complete set of objects modified as a result of executing the specified code; false otherwise. If FALSE, call GciAlteredObjs for the rest of the modified objects. |
perform has the following fields:
executestr has the following fields:
continueArgs has the following fields:
GciClampedTravArgsSType holds the arguments for clamped traversal, and includes the following fields:
The C++ class GciTravBufType describes a traversal buffer, and defines the following fields:
The actual body size is variable, with a minimum of GCI_MIN_TRAV_BUFF_SIZE. Maximum size is 4GB, or, if compression is used, 2GB. |
To create a new instance of GciTravBufType, use the function GciAllocTravBuf.
The traversal buffer class GciTravBufType provides these functions:
GciObjRepSType* firstReport();
Returns a pointer to the first object report in the buffer.
GciObjRepSType* readLimit() ;
Used when reading object reports out of a buffer. Returns a pointer past the end of last object report in the buffer. If readLimit()==firstReport(), the buffer is empty.
GciObjRepSType* writeLimit();
Used when composing a buffer. Returns a pointer one byte past the end of the allocated buffer.
GciObjRepHdrSType* firstReportHdr();
Returns a pointer to the first object report in the buffer.
GciObjRepHdrSType* readLimitHdr();
Used when reading object reports out of a buffer. Returns a pointer past the end of last object report in the buffer.
GciObjRepHdrSType* writeLimitHdr();
Used when composing a buffer. Returns a pointer one byte past the end of the allocated buffer.