[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stratagus-CVS] stratagus/src include/ccl_helpers.h clone/ccl_h...
From: |
Russell Smith |
Subject: |
[Stratagus-CVS] stratagus/src include/ccl_helpers.h clone/ccl_h... |
Date: |
Thu, 23 Oct 2003 19:31:28 -0400 |
CVSROOT: /cvsroot/stratagus
Module name: stratagus
Branch:
Changes by: Russell Smith <address@hidden> 03/10/23 19:31:28
Modified files:
src/include : ccl_helpers.h
src/clone : ccl_helpers.c
Log message:
Cleanup
Patches:
Index: stratagus/src/clone/ccl_helpers.c
diff -u stratagus/src/clone/ccl_helpers.c:1.1
stratagus/src/clone/ccl_helpers.c:1.2
--- stratagus/src/clone/ccl_helpers.c:1.1 Thu Oct 23 15:15:09 2003
+++ stratagus/src/clone/ccl_helpers.c Thu Oct 23 19:31:28 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_helpers.c,v 1.1 2003/10/23 19:15:09 n0body Exp $
+// $Id: ccl_helpers.c,v 1.2 2003/10/23 23:31:28 mr-russ Exp $
//@{
@@ -54,63 +54,65 @@
global void IOPrintTabs()
{
- unsigned int tableft, cur;
+ unsigned int tableft;
+ unsigned int cur;
char buffer[256];
tableft = IOTabLevel;
- while ( tableft ) {
- cur = ( tableft >= sizeof ( buffer ) ? sizeof ( buffer ) - 1 : tableft
);
+ while (tableft) {
+ cur = (tableft >= sizeof(buffer) ? sizeof(buffer) - 1 : tableft);
- memset( buffer, 9, cur );
+ memset(buffer, 9, cur);
buffer[cur] = 0;
- CLprintf( IOOutFile, buffer );
+ CLprintf(IOOutFile, buffer);
tableft -= cur;
}
}
-local void saveData( CclFieldDef * defs, void *data )
+local void saveData(CclFieldDef * defs, void *data)
{
unsigned int i;
- while ( defs->name ) {
- if ( defs->convertfunc ) {
+ while (defs->name) {
+ if (defs->convertfunc) {
IOPrintTabs();
- for ( i = 0; i < IOTabLevel; i++ ) {
+ for (i = 0; i < IOTabLevel; i++) {
DebugLevel3Fn( "\t" );
}
- DebugLevel3Fn("saving %s\n" _C_ defs->name );
- // name
- CLprintf( IOOutFile, "%s", defs->name );
+ DebugLevel3Fn("saving %s\n" _C_ defs->name);
+ // name
+ CLprintf(IOOutFile, "%s", defs->name);
IOTabLevel++;
- // real output
- ( *defs->convertfunc ) ( SCM_UNSPECIFIED,
- ( ( char * ) data ) + ( int )
defs->offset, defs->para );
+ // real output
+ (*defs->convertfunc)(SCM_UNSPECIFIED,
+ ((char*)data) + (int)defs->offset, defs->para);
IOTabLevel--;
- CLprintf( IOOutFile, "\n" );
+ CLprintf(IOOutFile, "\n");
}
defs++;
}
}
-local void restoreData( CclFieldDef * defs, void *data, SCM desc )
+local void restoreData(CclFieldDef * defs, void *data, SCM desc)
{
- SCM ident, value;
+ SCM ident;
+ SCM value;
CclFieldDef *curdef;
- while ( !gh_null_p( desc ) ) {
- ident = gh_car( desc );
- desc = gh_cdr( desc );
- value = gh_car( desc );
- desc = gh_cdr( desc );
- for ( curdef = defs; curdef->name; curdef++ ) {
- if ( curdef->convertfunc && gh_eq_p( ident, gh_symbol2scm(
curdef->name ) ) ) {
- ( *curdef->convertfunc ) ( value, ( ( char * ) data ) + ( int )
curdef->offset,
- curdef->para );
+ while (!gh_null_p(desc)) {
+ ident = gh_car(desc);
+ desc = gh_cdr(desc);
+ value = gh_car(desc);
+ desc = gh_cdr(desc);
+ for (curdef = defs; curdef->name; curdef++) {
+ if (curdef->convertfunc && gh_eq_p(ident,
gh_symbol2scm(curdef->name))) {
+ (*curdef->convertfunc)(value, ((char*)data) +
(int)curdef->offset,
+ curdef->para);
break;
}
}
- if ( !curdef->name ) {
- gh_display( ident );
- errl( "invalid identifier in this context", ident );
+ if (!curdef->name) {
+ gh_display(ident);
+ errl("invalid identifier in this context", ident);
}
}
}
@@ -124,21 +126,21 @@
** @param binaryform Pointer to the structure to load/save
** @param para Pointer to a CclStructDef structure.
*/
-global void IOStruct( SCM scmform, void *binaryform, void *para )
+global void IOStruct(SCM scmform, void *binaryform, void *para)
{
CclStructDef *structDef;
- structDef = ( CclStructDef * ) para;
+ structDef = (CclStructDef*)para;
- if ( IOLoadingMode ) {
- restoreData( structDef->defs, binaryform, scmform );
+ if (IOLoadingMode) {
+ restoreData(structDef->defs, binaryform, scmform);
} else {
- CLprintf( IOOutFile, " (\n" );
- IOTabLevel++;
- saveData( structDef->defs, binaryform );
- IOTabLevel--;
+ CLprintf(IOOutFile, " (\n");
+ ++IOTabLevel;
+ saveData(structDef->defs, binaryform);
+ --IOTabLevel;
IOPrintTabs();
- CLprintf( IOOutFile, ")" );
+ CLprintf(IOOutFile, ")");
}
}
@@ -151,27 +153,25 @@
** @param binaryform Pointer to the structure'reference to load/save
( <structure-type> ** )
** @param para Pointer to a CclStructDef structure.
*/
-global void IOStructPtr( SCM scmform, void *binaryform, void *para )
+global void IOStructPtr(SCM scmform, void *binaryform, void *para)
{
void **structptr;
CclStructDef *def;
- if ( IOHandleNullPtr( scmform, binaryform ) ) {
+ if (IOHandleNullPtr(scmform, binaryform)) {
return;
}
- def = ( CclStructDef * ) para;
+ def = (CclStructDef*)para;
- structptr = ( void ** ) binaryform;
+ structptr = (void**)binaryform;
- if ( IOLoadingMode ) {
- ( *structptr ) = ( void * ) malloc( def->size );
-
- memset( ( *structptr ), 0, def->size );
-
- IOStruct( scmform, ( *structptr ), para );
+ if (IOLoadingMode) {
+ (*structptr) = (void*)malloc(def->size);
+ memset((*structptr), 0, def->size);
+ IOStruct(scmform, (*structptr), para);
} else {
- IOStruct( scmform, ( *structptr ), para );
+ IOStruct(scmform, (*structptr), para);
}
}
@@ -184,33 +184,32 @@
** @param binaryform Pointer to the structure'reference to load/save
( <structure-type> * )
** @param para Pointer to a CclStructDef structure, describing
format of the structure.
*/
-void IOStructArray( SCM from, void *binaryform, void *para )
+local void IOStructArray(SCM from, void *binaryform, void *para)
{
CclStructDef *def;
int i;
- def = ( CclStructDef * ) para;
-
- if ( IOLoadingMode ) {
- for ( i = 0; i < def->array_size; i++ ) {
+ def = (CclStructDef*) para;
- IOStruct( gh_car( from ), binaryform, para );
+ if (IOLoadingMode) {
+ for (i = 0; i < def->array_size; ++i) {
+ IOStruct(gh_car(from), binaryform, para);
- from = gh_cdr( from );
+ from = gh_cdr(from);
binaryform += def->size;
}
} else {
- CLprintf( IOOutFile, " (\n" );
- IOTabLevel++;
- for ( i = 0; i < def->array_size; i++ ) {
+ CLprintf(IOOutFile, " (\n");
+ ++IOTabLevel;
+ for (i = 0; i < def->array_size; ++i) {
IOPrintTabs();
- IOStruct( from, binaryform, para );
- CLprintf( IOOutFile, "\n" );
+ IOStruct(from, binaryform, para);
+ CLprintf(IOOutFile, "\n");
binaryform += def->size;
}
- IOTabLevel--;
+ --IOTabLevel;
IOPrintTabs();
- CLprintf( IOOutFile, ")" );
+ CLprintf(IOOutFile, ")");
}
}
@@ -225,45 +224,41 @@
** @param binaryform Pointer to the "first"'ref ( <any-structure>** )
** @param para Pointer to the CclStructDef
*/
-global void IOLinkedList( SCM scmfrom, void *binaryform, void *para )
+global void IOLinkedList(SCM scmfrom, void *binaryform, void *para)
{
SCM item;
CclStructDef *itemDef;
void **current;
- itemDef = ( CclStructDef * ) para;
+ itemDef = (CclStructDef*)para;
- if ( IOLoadingMode ) {
- current = ( void ** ) binaryform;
- while ( !gh_null_p( scmfrom ) ) {
- item = gh_car( scmfrom );
- scmfrom = gh_cdr( scmfrom );
-
- // Just to be safe...
- if ( !gh_null_p( item ) ) {
- IOStructPtr( item, current, itemDef );
-
- current =
- ( void ** ) ( ( ( char * ) ( *current ) ) + ( int )
itemDef->defs->offset );
+ if (IOLoadingMode) {
+ current = (void**)binaryform;
+ while (!gh_null_p(scmfrom)) {
+ item = gh_car(scmfrom);
+ scmfrom = gh_cdr(scmfrom);
+
+ // Just to be safe...
+ if (!gh_null_p(item)) {
+ IOStructPtr(item, current, itemDef);
+ current = (void**)(((char*)(*current)) +
(int)itemDef->defs->offset);
}
}
} else {
- current = ( ( void ** ) binaryform );
+ current = ((void**)binaryform);
- CLprintf( IOOutFile, " (\n" );
- IOTabLevel++;
- while ( *( ( void ** ) current ) ) {
+ CLprintf(IOOutFile, " (\n");
+ ++IOTabLevel;
+ while (*((void**)current)) {
IOPrintTabs();
+ IOStructPtr(gh_car(scmfrom), current, itemDef);
+ CLprintf(IOOutFile, "\n");
- IOStructPtr( gh_car( scmfrom ), current, itemDef );
- CLprintf( IOOutFile, "\n" );
-
- // Get the next...
- current =
- ( void ** ) ( ( ( char * ) ( *current ) ) + ( int )
itemDef->defs->offset );
+ // Get the next...
+ current = (void**)(((char*)(*current)) +
(int)itemDef->defs->offset);
}
- IOTabLevel--;
+ --IOTabLevel;
IOPrintTabs();
- CLprintf( IOOutFile, ")\n" );
+ CLprintf(IOOutFile, ")\n");
IOPrintTabs();
}
}
@@ -282,43 +277,42 @@
** @param binaryform Pointer to the "first"'ref ( <any-structure>** )
** @param para Pointer to the CclStructDef
*/
-global void IOTable( SCM scmfrom, void *binaryform, void *para )
+global void IOTable(SCM scmfrom, void *binaryform, void *para)
{
CclStructDef *def;
int count;
void *org;
- def = ( CclStructDef * ) para;
- if ( IOLoadingMode ) {
+ def = (CclStructDef*)para;
+ if (IOLoadingMode) {
count = 0;
org = 0;
- while ( !gh_null_p( scmfrom ) ) {
- count = count + 1;
- org = realloc( org, def->size * count );
- ( *def->defs[2].convertfunc ) ( gh_car( scmfrom ),
- ( void * ) ( ( char * ) org +
- ( def->size * ( count
- 1 ) ) ),
- def->defs[2].para );
- scmfrom = gh_cdr( scmfrom );
- }
- *( ( void ** ) ( ( char * ) binaryform + ( int ) def->defs[0].offset )
) = org;
- *( ( int * ) ( ( char * ) binaryform + ( int ) def->defs[1].offset ) )
= count;
- } else {
- CLprintf( IOOutFile, " (\n" );
- IOTabLevel++;
- count = *( ( int * ) ( ( char * ) binaryform + ( int )
def->defs[1].offset ) );
- org = *( ( void ** ) ( ( char * ) binaryform + ( int )
def->defs[0].offset ) );
+ while (!gh_null_p(scmfrom)) {
+ ++count;
+ org = realloc(org, def->size * count);
+ (*def->defs[2].convertfunc)(gh_car(scmfrom),
+ (void*)((char*)org + (def->size * (count - 1))),
+ def->defs[2].para);
+ scmfrom = gh_cdr(scmfrom);
+ }
+ *((void**)((char*)binaryform + (int)def->defs[0].offset)) = org;
+ *((int*)((char*)binaryform + (int)def->defs[1].offset)) = count;
+ } else {
+ CLprintf(IOOutFile, " (\n");
+ ++IOTabLevel;
+ count = *((int*)((char*)binaryform + (int)def->defs[1].offset));
+ org = *((void**)((char*)binaryform + (int)def->defs[0].offset));
- while ( count ) {
+ while (count) {
IOPrintTabs();
- ( *def->defs[2].convertfunc ) ( scmfrom, org, def->defs[2].para );
- CLprintf( IOOutFile, "\n" );
- org = ( void * ) ( ( char * ) org + def->size );
- count--;
+ (*def->defs[2].convertfunc)(scmfrom, org, def->defs[2].para);
+ CLprintf(IOOutFile, "\n");
+ org = (void*)((char*)org + def->size);
+ --count;
}
- IOTabLevel--;
+ --IOTabLevel;
IOPrintTabs();
- CLprintf( IOOutFile, " )" );
+ CLprintf(IOOutFile, " )");
}
}
@@ -331,12 +325,12 @@
** @param binaryform Pointer to the int value to load/save
** @param para unused
*/
-global void IOInt( SCM scmfrom, void *binaryform, void *para )
+global void IOInt(SCM scmfrom, void *binaryform, void *para)
{
- if ( IOLoadingMode ) {
- ( *( ( int * ) binaryform ) ) = gh_scm2long( scmfrom );
+ if (IOLoadingMode) {
+ (*((int*)binaryform)) = gh_scm2long(scmfrom);
} else {
- CLprintf( IOOutFile, " %d", ( *( ( int * ) binaryform ) ) );
+ CLprintf(IOOutFile, " %d", (*((int*)binaryform)));
}
}
@@ -349,15 +343,15 @@
** @param binaryform Pointer to the int value to load/save
** @param para unused
*/
-global void IOString( SCM scmfrom, void *binaryform, void *para )
+global void IOString(SCM scmfrom, void *binaryform, void *para)
{
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- if ( IOLoadingMode ) {
- ( *( ( char ** ) binaryform ) ) = gh_scm2newstr( scmfrom, 0 );
- } else { // FIXME : better string support
- CLprintf( IOOutFile, " \"%s\"", ( *( ( char ** ) binaryform ) ) );
+ if (IOLoadingMode) {
+ (*((char**)binaryform)) = gh_scm2newstr(scmfrom, 0);
+ } else { // FIXME : (pludov) better string support
+ CLprintf(IOOutFile, " \"%s\"", (*((char**)binaryform)));
}
}
@@ -370,12 +364,12 @@
** @param binaryform Pointer to the bool value to load/save ( int* )
** @param para unused
*/
-global void IOBool( SCM scmfrom, void *binaryform, void *para )
+global void IOBool(SCM scmfrom, void *binaryform, void *para)
{
- if ( IOLoadingMode ) {
- ( *( ( int * ) binaryform ) ) = ( gh_null_p( scmfrom ) ? 0 : 1 );
+ if (IOLoadingMode) {
+ (*((int*)binaryform)) = gh_null_p(scmfrom) ? 0 : 1;
} else {
- CLprintf( IOOutFile, " %s", ( *( ( int * ) binaryform ) ? "#t" : "#f" )
);
+ CLprintf(IOOutFile, " %s", (*((int*)binaryform) ? "#t" : "#f"));
}
}
@@ -388,12 +382,12 @@
** @param binaryform Pointer to the bool value to load/save ( char* )
** @param para unused
*/
-global void IOCharBool( SCM scmfrom, void *binaryform, void *para )
+global void IOCharBool(SCM scmfrom, void *binaryform, void *para)
{
- if ( IOLoadingMode ) {
- ( *( ( char * ) binaryform ) ) = ( gh_null_p( scmfrom ) ? 0 : 1 );
+ if (IOLoadingMode) {
+ (*((char*)binaryform)) = (gh_null_p(scmfrom) ? 0 : 1);
} else {
- CLprintf( IOOutFile, " %s", ( *( ( char * ) binaryform ) ? "#t" : "#f"
) );
+ CLprintf(IOOutFile, " %s", (*((char*)binaryform) ? "#t" : "#f"));
}
}
@@ -405,16 +399,16 @@
** @param binaryform Pointer to the scm value to load/save ( SCM* )
** @param para unused
*/
-global void IOCcl( SCM scmfrom, void *binaryform, void *para )
+global void IOCcl(SCM scmfrom, void *binaryform, void *para)
{
SCM *ptr;
- ptr = ( SCM * ) binaryform;
- if ( IOLoadingMode ) {
+ ptr = (SCM*)binaryform;
+ if (IOLoadingMode) {
*ptr = scmfrom;
- CclGcProtect( *ptr );
+ CclGcProtect(*ptr);
} else {
- CLprintf( IOOutFile, " " );
- lprin1CL( *ptr, IOOutFile );
+ CLprintf(IOOutFile, " ");
+ lprin1CL(*ptr, IOOutFile);
}
}
@@ -426,42 +420,42 @@
** @param binaryform Pointer to the scm value to load/save ( char* )
** @param para Array of CclFlagDef, describing possible values
( CclFlagDef * )
*/
-global void IOCharFlag( SCM scmfrom, void *binaryform, void *para )
+global void IOCharFlag(SCM scmfrom, void *binaryform, void *para)
{
CclFlagDef *flags;
flags = para;
- if ( IOLoadingMode ) {
- if ( gh_exact_p( scmfrom ) ) {
- ( *( ( char * ) binaryform ) ) = gh_scm2int( scmfrom );
- }
- while ( flags->ident ) {
- if ( gh_eq_p( scmfrom, gh_symbol2scm( flags->ident ) ) ) {
- ( *( ( char * ) binaryform ) ) = flags->value;
+ if (IOLoadingMode) {
+ if (gh_exact_p(scmfrom)) {
+ (*((char*)binaryform)) = gh_scm2int(scmfrom);
+ }
+ while (flags->ident) {
+ if (gh_eq_p(scmfrom, gh_symbol2scm(flags->ident))) {
+ (*((char*)binaryform)) = flags->value;
return;
}
- flags++;
+ ++flags;
}
- errl( "invalid flag", scmfrom );
+ errl("invalid flag", scmfrom);
} else {
- while ( flags->ident ) {
- if ( flags->value == ( *( ( char * ) binaryform ) ) ) {
- CLprintf( IOOutFile, " %s", flags->ident );
+ while (flags->ident) {
+ if (flags->value == (*((char*)binaryform))) {
+ CLprintf(IOOutFile, " %s", flags->ident);
return;
}
- flags++;
+ ++flags;
}
- CLprintf( IOOutFile, "\n;; WARNING : no flag defined for value %d\n",
- ( *( ( char * ) binaryform ) ) );
- CLprintf( IOOutFile, ";; defined flags are : " );
+ CLprintf(IOOutFile, "\n;; WARNING : no flag defined for value %d\n",
+ (*((char*)binaryform)));
+ CLprintf(IOOutFile, ";; defined flags are : ");
flags = para;
- while ( flags->ident ) {
- CLprintf( IOOutFile, " %s(%d) ", flags->ident, flags->value );
- flags++;
+ while (flags->ident) {
+ CLprintf(IOOutFile, " %s(%d) ", flags->ident, flags->value);
+ ++flags;
}
IOPrintTabs();
- CLprintf( IOOutFile, "%d", ( *( ( char * ) binaryform ) ) );
+ CLprintf(IOOutFile, "%d", (*((char*)binaryform)));
}
}
@@ -472,21 +466,21 @@
** @param binaryform Pointer to the string buffer
** @param para Max size of string ( int )
*/
-global void IOStrBuffer( SCM scmfrom, void *binaryform, void *para )
+global void IOStrBuffer(SCM scmfrom, void *binaryform, void *para)
{
int size;
char *buffer;
char *str;
- size = ( int ) para;
- buffer = ( char * ) binaryform;
- if ( IOLoadingMode ) {
- str = gh_scm2newstr( scmfrom, NULL );
- strncpy( buffer, str, size );
- free( str );
+ size = (int)para;
+ buffer = (char*)binaryform;
+ if (IOLoadingMode) {
+ str = gh_scm2newstr(scmfrom, NULL);
+ strncpy(buffer, str, size);
+ free(str);
} else {
- // TODO better string support !
- CLprintf( IOOutFile, " \"%s\"", buffer );
+ // TODO better string support !
+ CLprintf(IOOutFile, " \"%s\"", buffer);
}
}
@@ -499,16 +493,16 @@
** @param para Unused
** @return 1 if a null value was saved/loaded, meaning that no more
processing is required.
*/
-global int IOHandleNullPtr( SCM scmfrom, void *binaryform )
+global int IOHandleNullPtr(SCM scmfrom, void *binaryform)
{
- if ( IOLoadingMode ) {
- if ( gh_null_p( scmfrom ) ) {
- *( ( void ** ) binaryform ) = 0;
+ if (IOLoadingMode) {
+ if (gh_null_p(scmfrom)) {
+ *((void**)binaryform) = 0;
return 1;
}
} else {
- if ( !*( ( void ** ) binaryform ) ) {
- CLprintf( IOOutFile, " ()" );
+ if (!*((void**)binaryform)) {
+ CLprintf(IOOutFile, " ()");
return 1;
}
}
@@ -523,32 +517,33 @@
** @param binaryform Pointer to the array'ref ( int ** )
** @param para Size of array to allocate/save
*/
-global void IOIntArrayPtr( SCM scmfrom, void *binaryform, void *para )
+global void IOIntArrayPtr(SCM scmfrom, void *binaryform, void *para)
{
- int size, i;
+ int size;
+ int i;
int **array;
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- size = ( int ) para;
- array = ( int ** ) binaryform;
+ size = (int)para;
+ array = (int**)binaryform;
- if ( IOLoadingMode ) {
- ( *array ) = ( int * ) malloc( sizeof ( int ) * size );
- for ( i = 0; i < size; i++ ) {
- ( *array )[i] = gh_scm2int( gh_car( scmfrom ) );
- scmfrom = gh_cdr( scmfrom );
+ if (IOLoadingMode) {
+ (*array) = (int*)malloc(sizeof(int) * size);
+ for (i = 0; i < size; ++i) {
+ (*array)[i] = gh_scm2int(gh_car(scmfrom));
+ scmfrom = gh_cdr(scmfrom);
}
} else {
i = 0;
- CLprintf( IOOutFile, " (" );
- while ( i < size ) {
- CLprintf( IOOutFile, " %d", ( *array )[i] );
- i++;
+ CLprintf(IOOutFile, " (");
+ while (i < size) {
+ CLprintf(IOOutFile, " %d", ( *array )[i]);
+ ++i;
}
- CLprintf( IOOutFile, " )" );
+ CLprintf(IOOutFile, " )");
}
}
@@ -560,37 +555,38 @@
** @param binaryform Pointer to the array ( int * )
** @param para Size of array to allocate/save
*/
-global void IOIntArray( SCM scmfrom, void *binaryform, void *para )
+global void IOIntArray(SCM scmfrom, void *binaryform, void *para)
{
- int i, size;
- size = ( int ) para;
+ int i;
+ int size;
+
+ size = (int)para;
- if ( IOLoadingMode ) {
- for ( i = 0; i < size; i++ ) {
- ( ( int * ) binaryform )[i] = gh_scm2int( gh_car( scmfrom ) );
- scmfrom = gh_cdr( scmfrom );
+ if (IOLoadingMode) {
+ for (i = 0; i < size; ++i) {
+ ((int*)binaryform)[i] = gh_scm2int(gh_car(scmfrom));
+ scmfrom = gh_cdr(scmfrom);
}
} else {
- CLprintf( IOOutFile, " (" );
- IOTabLevel++;
- if ( size > 16 ) {
- CLprintf( IOOutFile, "\n" );
+ CLprintf(IOOutFile, " (");
+ ++IOTabLevel;
+ if (size > 16) {
+ CLprintf(IOOutFile, "\n");
IOPrintTabs();
}
- for ( i = 0; i < size; i++ ) {
- CLprintf( IOOutFile, " %d", ( ( int * ) binaryform )[i] );
- if ( ( i > 0 ) && ( !( i & 15 ) ) ) {
- CLprintf( IOOutFile, "\n" );
+ for (i = 0; i < size; ++i) {
+ CLprintf(IOOutFile, " %d", ((int*)binaryform)[i]);
+ if (i > 0 && !( i & 15 )) {
+ CLprintf(IOOutFile, "\n");
IOPrintTabs();
}
}
- CLprintf( IOOutFile, ")" );
- IOTabLevel--;
- if ( size > 16 ) {
- CLprintf( IOOutFile, "\n" );
-
+ CLprintf(IOOutFile, ")");
+ --IOTabLevel;
+ if (size > 16) {
+ CLprintf(IOOutFile, "\n");
IOPrintTabs();
}
}
@@ -604,22 +600,22 @@
** @param binaryform Pointer to the unittype'ref ( UnitType ** )
** @param para unused
*/
-global void IOUnitTypePtr( SCM scmfrom, void *binaryform, void *para )
+global void IOUnitTypePtr(SCM scmfrom, void *binaryform, void *para)
{
char *str;
- UnitType **unitType;
+ UnitType **unittype;
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- unitType = ( UnitType ** ) binaryform;
- if ( IOLoadingMode ) {
- str = gh_scm2newstr( scmfrom, NULL );
- ( *unitType ) = UnitTypeByIdent( str );
- free( str );
+ unittype = (UnitType**)binaryform;
+ if (IOLoadingMode) {
+ str = gh_scm2newstr(scmfrom, NULL);
+ (*unittype) = UnitTypeByIdent(str);
+ free(str);
} else {
- CLprintf( IOOutFile, " %s", ( *unitType )->Ident );
+ CLprintf(IOOutFile, " %s", (*unittype)->Ident);
}
}
@@ -631,22 +627,22 @@
** @param binaryform Pointer to the unittype'ref ( Upgrade ** )
** @param para unused
*/
-global void IOUpgradePtr( SCM scmfrom, void *binaryform, void *para )
+global void IOUpgradePtr(SCM scmfrom, void *binaryform, void *para)
{
char *str;
Upgrade **upgrade;
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- upgrade = ( Upgrade ** ) binaryform;
- if ( IOLoadingMode ) {
- str = gh_scm2newstr( scmfrom, NULL );
- ( *upgrade ) = UpgradeByIdent( str );
- free( str );
+ upgrade = (Upgrade**)binaryform;
+ if (IOLoadingMode) {
+ str = gh_scm2newstr(scmfrom, NULL);
+ (*upgrade) = UpgradeByIdent(str);
+ free(str);
} else {
- CLprintf( IOOutFile, " %s", ( *upgrade )->Ident );
+ CLprintf(IOOutFile, " %s", (*upgrade)->Ident);
}
}
@@ -659,18 +655,19 @@
** @param binaryform Pointer to the unit'ref ( Unit ** )
** @param para unused
*/
-global void IOUnitPtr( SCM scmfrom, void *binaryform, void *para )
+global void IOUnitPtr(SCM scmfrom, void *binaryform, void *para)
{
int slot;
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- if ( IOLoadingMode ) {
- slot = gh_scm2int( scmfrom );
- *( ( Unit ** ) binaryform ) = UnitSlots[slot];
- // FIXME : increment unit usage count !
+ if (IOLoadingMode) {
+ slot = gh_scm2int(scmfrom);
+ *((Unit**)binaryform) = UnitSlots[slot];
+ // FIXME: (pludov) increment unit usage count!
} else {
- CLprintf( IOOutFile, " %d", ( *( ( Unit ** ) binaryform ) )->Slot );
+ CLprintf(IOOutFile, " %d", (*((Unit**)binaryform))->Slot);
}
}
@@ -682,19 +679,20 @@
** @param binaryform Pointer to the unit'ref ( Player ** )
** @param para unused
*/
-global void IOPlayerPtr( SCM scmfrom, void *binaryform, void *para )
+global void IOPlayerPtr(SCM scmfrom, void *binaryform, void *para)
{
int playerid;
- if ( IOHandleNullPtr( scmfrom, binaryform ) ) {
+
+ if (IOHandleNullPtr(scmfrom, binaryform)) {
return;
}
- if ( IOLoadingMode ) {
- // Load a player from scm
- playerid = gh_scm2int( scmfrom );
- *( ( Player ** ) binaryform ) = Players + playerid;
- } else {
- // Save a player to scm
- playerid = ( *( ( Player ** ) binaryform ) )->Player;
- CLprintf( IOOutFile, " %d", playerid );
+ if (IOLoadingMode) {
+ // Load a player from scm
+ playerid = gh_scm2int(scmfrom);
+ *((Player**)binaryform) = Players + playerid;
+ } else {
+ // Save a player to scm
+ playerid = (*((Player**)binaryform))->Player;
+ CLprintf(IOOutFile, " %d", playerid);
}
}
Index: stratagus/src/include/ccl_helpers.h
diff -u stratagus/src/include/ccl_helpers.h:1.1
stratagus/src/include/ccl_helpers.h:1.2
--- stratagus/src/include/ccl_helpers.h:1.1 Thu Oct 23 15:15:09 2003
+++ stratagus/src/include/ccl_helpers.h Thu Oct 23 19:31:28 2003
@@ -26,7 +26,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
//
-// $Id: ccl_helpers.h,v 1.1 2003/10/23 19:15:09 n0body Exp $
+// $Id: ccl_helpers.h,v 1.2 2003/10/23 23:31:28 mr-russ Exp $
#ifndef __CCL_HELPERS__
#define __CCL_HELPERS__
@@ -39,90 +39,90 @@
-- Structures
----------------------------------------------------------------------------*/
-typedef struct _ccl_flag_def_ CclFlagDef;
-struct _ccl_flag_def_
+// FIXME: (mr-russ) document
+
+typedef struct _ccl_flag_def_
{
- char *ident;
- int value;
-};
+ char* ident;
+ int value;
+} CclFlagDef;
-typedef struct _ccl_field_def_ CclFieldDef;
-struct _ccl_field_def_
+typedef struct _ccl_field_def_
{
- char *name;
- void ( *convertfunc ) ( SCM scmfrom, void *binaryform, void *para );
- void *offset;
- void *para;
-};
+ char* name;
+ void (*convertfunc)(SCM scmfrom, void *binaryform, void *para);
+ void* offset;
+ void* para;
+} CclFieldDef;
-typedef struct _IOStruct_def_ CclStructDef;
-struct _IOStruct_def_
+typedef struct _IOStruct_def_
{
- char *name;
- int size;
- int array_size;
- CclFieldDef defs[];
-};
+ char* name;
+ int size;
+ int array_size;
+ CclFieldDef defs[];
+} CclStructDef;
/*----------------------------------------------------------------------------
-- Variables
----------------------------------------------------------------------------*/
extern int IOLoadingMode;
extern unsigned int IOTabLevel;
-extern CLFile *IOOutFile;
+extern CLFile* IOOutFile;
/*----------------------------------------------------------------------------
-- Functions
----------------------------------------------------------------------------*/
-/// Print "IOTabLevel" tabs on the ccl output
+ /// Print "IOTabLevel" tabs on the ccl output
extern void IOPrintTabs();
-/// Handle saving/loading of structure
-extern void IOStruct( SCM scmform, void *binaryform, void *para );
-/// Handle saving/loading a pointer to a structure.
-extern void IOStructPtr( SCM scmform, void *binaryform, void *para );
-/// Handle loading a fixed size array of structure.
-extern void IOStructArray( SCM from, void *binaryform, void *para );
-/// Handle saving/loading linked list.
-extern void IOLinkedList( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading tables.
-extern void IOTable( SCM scmfrom, void *binaryform, void *para );
-/// Handle the case of saving/loading pointers which are null
-extern int IOHandleNullPtr( SCM scmfrom, void *binaryform );
-/// Handle saving/loading of int
-extern void IOInt( SCM scmform, void *binaryform, void *para );
-/// Handle saving/loading of bool stored as int
-extern void IOBool( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading of bool stored as char
-extern void IOCharBool( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading of string
-extern void IOString( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading of SCM
-extern void IOCcl( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading of flag stored in char
-extern void IOCharFlag( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading a fixed length string
-extern void IOStrBuffer( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading a dynamic array of int
-extern void IOIntArrayPtr( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading an already allocated array of int
-extern void IOIntArray( SCM scmfrom, void *binaryform, void *para );
-
-/// Handle saving/loading an unittype pointer (UnitType*)
-extern void IOUnitTypePtr( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading a reference to an unit (Unit*)
-extern void IOUnitPtr( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading a reference to an upgrade (Upgrade*)
-extern void IOUpgradePtr( SCM scmfrom, void *binaryform, void *para );
-/// Handle saving/loading a reference to a player (Player*)
-extern void IOPlayerPtr( SCM scmfrom, void *binaryform, void *para );
-
-
-/// Handle saving/loading a reference to an aitype. (AiType*)
-/*extern void IOAiTypePtr(SCM from,void * binaryform,void * para)*/
-/// Handle saving/loading a reference to an AiScriptAction. (AiScriptAction**)
-/*extern void IOAiScriptActionPtr(SCM scmfrom,void * binaryform,void * para);*/
-
+ /// Handle saving/loading of structure
+extern void IOStruct(SCM scmform, void *binaryform, void *para);
+ /// Handle saving/loading a pointer to a structure.
+extern void IOStructPtr(SCM scmform, void *binaryform, void *para);
+ /// Handle loading a fixed size array of structure.
+extern void IOStructArray( SCM from, void *binaryform, void *para);
+ /// Handle saving/loading linked list.
+extern void IOLinkedList(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading tables.
+extern void IOTable(SCM scmfrom, void *binaryform, void *para);
+ /// Handle the case of saving/loading pointers which are null
+extern int IOHandleNullPtr(SCM scmfrom, void *binaryform);
+ /// Handle saving/loading of int
+extern void IOInt(SCM scmform, void *binaryform, void *para);
+ /// Handle saving/loading of bool stored as int
+extern void IOBool(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading of bool stored as char
+extern void IOCharBool(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading of string
+extern void IOString(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading of SCM
+extern void IOCcl(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading of flag stored in char
+extern void IOCharFlag(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading a fixed length string
+extern void IOStrBuffer(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading a dynamic array of int
+extern void IOIntArrayPtr(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading an already allocated array of int
+extern void IOIntArray(SCM scmfrom, void *binaryform, void *para);
+
+ /// Handle saving/loading an unittype pointer (UnitType*)
+extern void IOUnitTypePtr(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading a reference to an unit (Unit*)
+extern void IOUnitPtr(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading a reference to an upgrade (Upgrade*)
+extern void IOUpgradePtr(SCM scmfrom, void *binaryform, void *para);
+ /// Handle saving/loading a reference to a player (Player*)
+extern void IOPlayerPtr(SCM scmfrom, void *binaryform, void *para);
+
+
+#if 0
+ /// Handle saving/loading a reference to an aitype. (AiType*)
+extern void IOAiTypePtr(SCM from,void * binaryform,void * para);
+ /// Handle saving/loading a reference to an AiScriptAction.
(AiScriptAction**)
+extern void IOAiScriptActionPtr(SCM scmfrom,void * binaryform,void * para);
+#endif
//@}
#endif // !__CCL_H__
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Stratagus-CVS] stratagus/src include/ccl_helpers.h clone/ccl_h...,
Russell Smith <=