[Guardsoft-cvs] libaif INTERNAL,1.3,1.4 aif.h,1.45,1.46 aifint.h,1.18,1.19 conv.c,1.52,1.53 fds.c,1.
Brought to you by:
jarrah
|
From: Greg W. <ja...@us...> - 2005-05-22 15:41:09
|
Update of /cvsroot/guardsoft/libaif In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5990 Modified Files: INTERNAL aif.h aifint.h conv.c fds.c print.c testaif.c Log Message: Convert function type to string. Printing of function and void types. Index: fds.c =================================================================== RCS file: /cvsroot/guardsoft/libaif/fds.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** fds.c 9 Apr 2004 22:23:28 -0000 1.41 --- fds.c 22 May 2005 15:40:57 -0000 1.42 *************** *** 2416,2419 **** --- 2416,2425 ---- return; + case AIF_FUNCTION: + while ( **data != '\0' ) + (*data)++; + (*data)++; /* past null */ + return; + default: SetAIFError(AIFERR_TYPE, NULL); Index: INTERNAL =================================================================== RCS file: /cvsroot/guardsoft/libaif/INTERNAL,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** INTERNAL 21 Mar 2002 03:19:41 -0000 1.3 --- INTERNAL 22 May 2005 15:40:57 -0000 1.4 *************** *** 84,89 **** - a range from L to U, where L and U are integer types specified by T ! &: function: &T ! - a function that returns type T. Data consists of a string containing the name of the function --- 84,90 ---- - a range from L to U, where L and U are integer types specified by T ! &: function: &A1,A2,.../T ! - a function that returns type T and that has arguments of type ! A1, A2, ... Data consists of a null-terminated string containing the name of the function Index: aifint.h =================================================================== RCS file: /cvsroot/guardsoft/libaif/aifint.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** aifint.h 5 Oct 2003 15:01:56 -0000 1.18 --- aifint.h 22 May 2005 15:40:57 -0000 1.19 *************** *** 58,61 **** --- 58,62 ---- extern int _aif_float_to_aif_int(char **, char *, int); extern int _aif_float_to_str(int, char **, char **); + extern int _aif_function_to_str(int, char **, char **); extern int _aif_int_is_zero(char *, int); extern int _aif_int_to_aif_float(char **, char *, int); *************** *** 78,81 **** --- 79,83 ---- extern int _aif_print_enum(FILE *, int, char **, char **); extern int _aif_print_float(FILE *, int, char **, char **); + extern int _aif_print_function(FILE *, int, char **, char **); extern int _aif_print_int(FILE *, int, char **, char **); extern int _aif_print_name(FILE *, int, char **, char **); *************** *** 86,89 **** --- 88,92 ---- extern int _aif_print_struct(FILE *, int, char **, char **); extern int _aif_print_union(FILE *, int, char **, char **); + extern int _aif_print_void(FILE *, int, char **, char **); extern int _aif_reference_to_str(int, char **, char **); extern int _aif_region_to_str(int, char **, char **); *************** *** 101,104 **** --- 104,108 ---- extern int _aif_unary_op_int(aifop, char **, char *, int); extern int _aif_union_to_str(int, char **, char **); + extern int _aif_void_to_str(int, char **, char **); extern int _char_to_aif(char **, char); extern int _doublest_to_aif(char **, int, AIFDOUBLEST); *************** *** 127,130 **** --- 131,135 ---- extern void _str_init(void); extern void _str_cat(char *); + extern void _str_add(char); extern char * _str_get(void); extern void _ptrname_to_int(char *, int *); Index: print.c =================================================================== RCS file: /cvsroot/guardsoft/libaif/print.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** print.c 22 Jul 2002 22:29:47 -0000 1.24 --- print.c 22 May 2005 15:40:57 -0000 1.25 *************** *** 107,112 **** return _aif_print_union(fp, depth, fds, data); - case AIF_FUNCTION: case AIF_VOID: default: SetAIFError(AIFERR_TYPE, NULL); --- 107,116 ---- return _aif_print_union(fp, depth, fds, data); case AIF_VOID: + return _aif_print_void(fp, depth, fds, data); + + case AIF_FUNCTION: + return _aif_print_function(fp, depth, fds, data); + default: SetAIFError(AIFERR_TYPE, NULL); *************** *** 365,368 **** --- 369,410 ---- int + _aif_print_void(FILE *fp, int depth, char **fds, char **data) + { + char * str; + + _str_init(); + + if ( _aif_void_to_str(depth, fds, data) < 0 ) + return -1; + + str = _str_get(); + + fprintf(fp, "%s", str); + + _aif_free(str); + + return 0; + } + + int + _aif_print_function(FILE *fp, int depth, char **fds, char **data) + { + char * str; + + _str_init(); + + if ( _aif_function_to_str(depth, fds, data) < 0 ) + return -1; + + str = _str_get(); + + fprintf(fp, "%s", str); + + _aif_free(str); + + return 0; + } + + int AIFPrintBool(FILE *fp, int depth, AIF *a) { *************** *** 599,602 **** --- 641,680 ---- int + AIFPrintVoid(FILE *fp, int depth, AIF *a) + { + char * fmt; + char * data; + + if ( a == (AIF *)NULL ) + { + SetAIFError(AIFERR_BADARG, NULL); + return -1; + } + + fmt = AIF_FORMAT(a); + data = AIF_DATA(a); + + return _aif_print_void(fp, depth, &fmt, &data); + } + + int + AIFPrintFunction(FILE *fp, int depth, AIF *a) + { + char * fmt; + char * data; + + if ( a == (AIF *)NULL ) + { + SetAIFError(AIFERR_BADARG, NULL); + return -1; + } + + fmt = AIF_FORMAT(a); + data = AIF_DATA(a); + + return _aif_print_function(fp, depth, &fmt, &data); + } + + int AIFPrintArrayIndex(FILE *fp, AIFIndex *ix) { Index: testaif.c =================================================================== RCS file: /cvsroot/guardsoft/libaif/testaif.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** testaif.c 31 Jan 2004 16:24:28 -0000 1.17 --- testaif.c 22 May 2005 15:40:57 -0000 1.18 *************** *** 408,411 **** --- 408,415 ---- _testAscii("subtest18", "[r0..2is4][r0..1is4]is4", "000000060000000700000002000000030000000400000005", "array of two lists of pointers", flag); + _testAscii("subtest19", "v4", "00000006", "void", flag); + + _testAscii("subtest20", "&is4,^^c/is4", "6D61696E00", "function with args (int, char **) returning int", flag); + fprintf(stdout, "\n"); Index: conv.c =================================================================== RCS file: /cvsroot/guardsoft/libaif/conv.c,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** conv.c 9 Apr 2004 22:23:28 -0000 1.52 --- conv.c 22 May 2005 15:40:57 -0000 1.53 *************** *** 1494,1497 **** --- 1494,1512 ---- } + void + _str_add(char ch) + { + while ( _str_pos + 2 > _str_buf + _str_buf_len ) + { + int offset = _str_pos - _str_buf; + _str_buf_len += BUFSIZ; + _str_buf = _aif_resize(_str_buf, _str_buf_len); + _str_pos = _str_buf + offset; + } + + *_str_pos++ = ch; + *_str_pos = '\0'; + } + char * _str_get(void) *************** *** 2142,2145 **** --- 2157,2184 ---- } + int + AIFVoidToStr(char **str, int depth, AIF *a) + { + char * fmt; + char * data; + + if ( a == (AIF *)NULL ) + { + SetAIFError(AIFERR_BADARG, NULL); + return -1; + } + + fmt = AIF_FORMAT(a); + data = AIF_DATA(a); + + _str_init(); + + if ( _aif_void_to_str(depth, &fmt, &data) < 0 ) + return -1; + + *str = _str_get(); + + return 0; + } int *************** *** 2228,2231 **** --- 2267,2330 ---- int + _aif_function_to_str(int depth, char **fds, char **data) + { + char * p; + char end[2] = {FDS_FUNCTION_ARG_END, 0}; + + (*fds)++; /* past "&" */ + + p = _fds_skipto(*fds, end); + + _str_cat(++p); + _str_cat(" "); + _str_cat(*data); + _str_cat("("); + + while ( **fds != FDS_FUNCTION_ARG_END ) + { + if ( **fds == FDS_UNION_FIELD_SEP ) + _str_cat(", "); + else + _str_add(**fds); + + (*fds)++; + } + + _str_cat(")"); + + (*fds)++; /* past arg end */ + + _fds_advance(fds); + _fds_skip_data(fds, data); + + return 0; + } + + int + AIFFunctionToStr(char **str, int depth, AIF *a) + { + char * fmt; + char * data; + + if ( a == (AIF *)NULL ) + { + SetAIFError(AIFERR_BADARG, NULL); + return -1; + } + + fmt = AIF_FORMAT(a); + data = AIF_DATA(a); + + _str_init(); + + if ( _aif_function_to_str(depth, &fmt, &data) < 0 ) + return -1; + + *str = _str_get(); + + return 0; + } + + int _aif_enum_to_str(int depth, char **fds, char **data) { *************** *** 2359,2365 **** --- 2458,2468 ---- case AIF_UNION: return _aif_union_to_str(depth, fds, data); + case AIF_VOID: return _aif_void_to_str(depth, fds, data); + case AIF_FUNCTION: + return _aif_function_to_str(depth, fds, data); + default: SetAIFError(AIFERR_TYPE, NULL); Index: aif.h =================================================================== RCS file: /cvsroot/guardsoft/libaif/aif.h,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** aif.h 5 Oct 2003 15:01:56 -0000 1.45 --- aif.h 22 May 2005 15:40:57 -0000 1.46 *************** *** 281,284 **** --- 281,285 ---- extern int AIFFieldType(AIF *, char *); extern int AIFFloatToStr(char **, int, AIF *); + extern int AIFFunctionToStr(char **, int, AIF *); extern void AIFFree(AIF *); extern AIF * AIFGetEnum(AIF *); *************** *** 306,309 **** --- 307,311 ---- extern int AIFPrintEnum(FILE *, int, AIF *); extern int AIFPrintFloat(FILE *, int, AIF *); + extern int AIFPrintFunction(FILE *, int, AIF *); extern int AIFPrintInt(FILE *, int, AIF *); extern int AIFPrintName(FILE *, int, AIF *); *************** *** 314,317 **** --- 316,320 ---- extern int AIFPrintStruct(FILE *, int, AIF *); extern int AIFPrintUnion(FILE *, int, AIF *); + extern int AIFPrintVoid(FILE *, int, AIF *); extern int AIFPrintArrayIndex(FILE *, AIFIndex *); extern int AIFReferenceToStr(char **, int, AIF *); *************** *** 339,342 **** --- 342,346 ---- extern long AIFTypeSize(AIF *); extern int AIFUnionToStr(char **, int, AIF *); + extern int AIFVoidToStr(char **, int, AIF *); extern int AIFWriteSet(AIFFILE *, AIF *, char *); extern AIF * ArrayToAIF(int, int *, int *, char *, int, char *); |