A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Don't try to unregister accepted sockets from OS tables since they never were registe...
[simgrid.git]
/
src
/
gras
/
DataDesc
/
ddt_parse.c
diff --git
a/src/gras/DataDesc/ddt_parse.c
b/src/gras/DataDesc/ddt_parse.c
index
38f55ee
..
d1a495e
100644
(file)
--- a/
src/gras/DataDesc/ddt_parse.c
+++ b/
src/gras/DataDesc/ddt_parse.c
@@
-1,19
+1,21
@@
/* $Id$ */
/* $Id$ */
-/* DataDesc/ddt_parse.c -- automatic parsing of data structures */
+/* DataDesc/ddt_parse.c -- automatic parsing of data structures
*/
-/* Authors: Arnaud Legrand, Martin Quinson */
-/* Copyright (C) 2003, 2004 Martin Quinson. */
+/* Copyright (c) 2003 Arnaud Legrand. */
+/* Copyright (c) 2003, 2004 Martin Quinson. */
+/* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* This program is free software; you can redistribute it and/or modify it
-
under the terms of the license (GNU LGPL) which comes with this package. */
+
*
under the terms of the license (GNU LGPL) which comes with this package. */
#include <ctype.h> /* isdigit */
#include <ctype.h> /* isdigit */
-#include "DataDesc/datadesc_private.h"
-#include "DataDesc/ddt_parse.yy.h"
+#include "
gras/
DataDesc/datadesc_private.h"
+#include "
gras/
DataDesc/ddt_parse.yy.h"
-GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_parse,datadesc);
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(ddt_parse,datadesc,
+ "Parsing C data structures to build GRAS data description");
typedef struct s_type_modifier{
short is_unsigned;
typedef struct s_type_modifier{
short is_unsigned;
@@
-25,20
+27,20
@@
typedef struct s_type_modifier{
short is_enum;
short is_ref;
short is_enum;
short is_ref;
-} type_modifier_t;
+}
s_type_modifier_t,*
type_modifier_t;
typedef struct s_field {
typedef struct s_field {
- gras_datadesc_type_t
*
type;
+ gras_datadesc_type_t type;
char *type_name;
char *name;
char *type_name;
char *name;
- type_modifier_t tm;
-} identifier_t;
+
s_
type_modifier_t tm;
+}
s_
identifier_t;
extern char *gras_ddt_parse_text; /* text being considered in the parser */
/* local functions */
extern char *gras_ddt_parse_text; /* text being considered in the parser */
/* local functions */
-static void parse_type_modifier(type_modifier_t
*
type_modifier) {
-
GRAS
_IN;
+static void parse_type_modifier(type_modifier_t type_modifier) {
+
XBT
_IN;
do {
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_STAR) {
/* This only used when parsing 'short *' since this function returns when int, float, double,... is encountered */
do {
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_STAR) {
/* This only used when parsing 'short *' since this function returns when int, float, double,... is encountered */
@@
-84,13
+86,13
@@
static void parse_type_modifier(type_modifier_t *type_modifier) {
break;
}
} while(1);
break;
}
} while(1);
-
GRAS
_OUT;
+
XBT
_OUT;
}
}
-static void print_type_modifier(type_modifier_t tm) {
+static void print_type_modifier(
s_
type_modifier_t tm) {
int i;
int i;
-
GRAS
_IN;
+
XBT
_IN;
if (tm.is_unsigned) printf("(unsigned) ");
if (tm.is_short) printf("(short) ");
for (i=0 ; i<tm.is_long ; i++) printf("(long) ");
if (tm.is_unsigned) printf("(unsigned) ");
if (tm.is_short) printf("(short) ");
for (i=0 ; i<tm.is_long ; i++) printf("(long) ");
@@
-100,89
+102,85
@@
static void print_type_modifier(type_modifier_t tm) {
if(tm.is_union) printf("(union) ");
for (i=0 ; i<tm.is_ref ; i++) printf("(ref) ");
if(tm.is_union) printf("(union) ");
for (i=0 ; i<tm.is_ref ; i++) printf("(ref) ");
-
GRAS
_OUT;
+
XBT
_OUT;
}
}
-static gras_error_t change_to_fixed_array(gras_dynar_t *dynar, long int size) {
- gras_error_t errcode;
- identifier_t former,array;
+static void change_to_fixed_array(xbt_dynar_t dynar, long int size) {
+ s_identifier_t former,array;
memset(&array,0,sizeof(array));
memset(&array,0,sizeof(array));
-
GRAS
_IN;
-
gras
_dynar_pop(dynar,&former);
- array.type_name=
malloc(strlen(former.type->name)+20
);
+
XBT
_IN;
+
xbt
_dynar_pop(dynar,&former);
+ array.type_name=
(char*)xbt_malloc(strlen(former.type->name)+48
);
DEBUG2("Array specification (size=%ld, elm='%s'), change pushed type",
size,former.type_name);
DEBUG2("Array specification (size=%ld, elm='%s'), change pushed type",
size,former.type_name);
- sprintf(array.type_name,"%s[%ld]",former.type_name,size);
+ sprintf(array.type_name,"%s%s%s%s[%ld]",
+ (former.tm.is_unsigned?"u ":""),
+ (former.tm.is_short?"s ":""),
+ (former.tm.is_long?"l ":""),
+ former.type_name,
+ size);
free(former.type_name);
free(former.type_name);
- TRY(gras_datadesc_array_fixed(array.type_name, former.type, size, &array.type)); /* redeclaration are ignored */
-
+ array.type = gras_datadesc_array_fixed(array.type_name, former.type, size); /* redeclaration are ignored */
array.name = former.name;
array.name = former.name;
- TRY(gras_dynar_push(dynar,&array));
- GRAS_OUT;
- return no_error;
+ xbt_dynar_push(dynar,&array);
+ XBT_OUT;
}
}
-static gras_error_t change_to_ref(gras_dynar_t *dynar) {
- gras_error_t errcode;
- identifier_t former,ref;
+static void change_to_ref(xbt_dynar_t dynar) {
+ s_identifier_t former,ref;
memset(&ref,0,sizeof(ref));
memset(&ref,0,sizeof(ref));
-
GRAS
_IN;
-
gras
_dynar_pop(dynar,&former);
- ref.type_name=malloc(strlen(former.type->name)+2);
+
XBT
_IN;
+
xbt
_dynar_pop(dynar,&former);
+ ref.type_name=
(char*)xbt_
malloc(strlen(former.type->name)+2);
DEBUG1("Ref specification (elm='%s'), change pushed type", former.type_name);
sprintf(ref.type_name,"%s*",former.type_name);
free(former.type_name);
DEBUG1("Ref specification (elm='%s'), change pushed type", former.type_name);
sprintf(ref.type_name,"%s*",former.type_name);
free(former.type_name);
- TRY(gras_datadesc_ref(ref.type_name, former.type, &ref.type)); /* redeclaration are ignored */
-
+ ref.type = gras_datadesc_ref(ref.type_name, former.type); /* redeclaration are ignored */
ref.name = former.name;
ref.name = former.name;
- TRY(gras_dynar_push(dynar,&ref));
- GRAS_OUT;
- return no_error;
+ xbt_dynar_push(dynar,&ref);
+ XBT_OUT;
}
}
-static gras_error_t change_to_ref_pop_array(gras_dynar_t *dynar) {
- gras_error_t errcode;
- identifier_t former,ref;
+static void change_to_ref_pop_array(xbt_dynar_t dynar) {
+ s_identifier_t former,ref;
memset(&ref,0,sizeof(ref));
memset(&ref,0,sizeof(ref));
-
GRAS
_IN;
-
gras
_dynar_pop(dynar,&former);
-
TRY(gras_datadesc_ref_pop_arr(former.type,&ref.type)
); /* redeclaration are ignored */
- ref.type_name = strdup(ref.type->name);
+
XBT
_IN;
+
xbt
_dynar_pop(dynar,&former);
+
ref.type = gras_datadesc_ref_pop_arr(former.type
); /* redeclaration are ignored */
+ ref.type_name =
(char*)
strdup(ref.type->name);
ref.name = former.name;
free(former.type_name);
ref.name = former.name;
free(former.type_name);
- TRY(gras_dynar_push(dynar,&ref));
- GRAS_OUT;
- return no_error;
+ xbt_dynar_push(dynar,&ref);
+ XBT_OUT;
}
}
-static gras_error_t parse_statement(char *definition,
- gras_dynar_t *identifiers,
- gras_dynar_t *fields_to_push) {
- gras_error_t errcode;
+static xbt_error_t parse_statement(char *definition,
+ xbt_dynar_t identifiers,
+ xbt_dynar_t fields_to_push) {
char buffname[512];
char buffname[512];
- identifier_t identifier;
+
s_
identifier_t identifier;
int expect_id_separator = 0;
int expect_id_separator = 0;
-
GRAS
_IN;
+
XBT
_IN;
memset(&identifier,0,sizeof(identifier));
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
memset(&identifier,0,sizeof(identifier));
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RA) {
-
GRAS
_OUT;
+
XBT
_OUT;
return mismatch_error; /* end of the englobing structure or union */
}
return mismatch_error; /* end of the englobing structure or union */
}
- if (
GRAS_LOG_ISENABLED(ddt_parse,gras
_log_priority_debug)) {
+ if (
XBT_LOG_ISENABLED(ddt_parse,xbt
_log_priority_debug)) {
int colon_pos;
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';';
int colon_pos;
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';';
@@
-219,10
+217,10
@@
static gras_error_t parse_statement(char *definition,
strcmp(gras_ddt_parse_text,"int") ) {
/* bastard user, they omited "int" ! */
strcmp(gras_ddt_parse_text,"int") ) {
/* bastard user, they omited "int" ! */
- identifier.type_name=strdup("int");
+ identifier.type_name=
(char*)
strdup("int");
DEBUG0("the base type is 'int', which were omited (you vicious user)");
} else {
DEBUG0("the base type is 'int', which were omited (you vicious user)");
} else {
- identifier.type_name=strdup(gras_ddt_parse_text);
+ identifier.type_name=
(char*)
strdup(gras_ddt_parse_text);
DEBUG1("the base type is '%s'",identifier.type_name);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
}
DEBUG1("the base type is '%s'",identifier.type_name);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
}
@@
-236,7
+234,7
@@
static gras_error_t parse_statement(char *definition,
} else if (identifier.tm.is_struct) {
sprintf(buffname,"struct %s",identifier.type_name);
} else if (identifier.tm.is_struct) {
sprintf(buffname,"struct %s",identifier.type_name);
-
TRY(gras_datadesc_struct(buffname,&identifier.type)
); /* Get created when does not exist */
+
identifier.type = gras_datadesc_struct(buffname
); /* Get created when does not exist */
} else if (identifier.tm.is_unsigned) {
if (!strcmp(identifier.type_name,"int")) {
} else if (identifier.tm.is_unsigned) {
if (!strcmp(identifier.type_name,"int")) {
@@
-282,8
+280,11
@@
static gras_error_t parse_statement(char *definition,
} else if (!strcmp(identifier.type_name, "char")) {
identifier.type = gras_datadesc_by_name("char");
} else if (!strcmp(identifier.type_name, "char")) {
identifier.type = gras_datadesc_by_name("char");
- } else { /* impossible */
- PARSE_ERROR0("The Impossible Did Happen (once again)");
+ } else {
+ DEBUG1("Base type is a constructed one (%s)",identifier.type_name);
+ identifier.type = gras_datadesc_by_name(identifier.type_name);
+ if (!identifier.type)
+ PARSE_ERROR1("Unknown base type '%s'",identifier.type_name);
}
}
/* Now identifier.type and identifier.name speak about the base type.
}
}
/* Now identifier.type and identifier.name speak about the base type.
@@
-293,7
+294,7
@@
static gras_error_t parse_statement(char *definition,
/**** look for the symbols of this type ****/
for(expect_id_separator = 0;
/**** look for the symbols of this type ****/
for(expect_id_separator = 0;
- (/
/(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_EMPTY) && FIXME
+ (/
*(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_EMPTY) && FIXME*/
(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_SEMI_COLON)) ;
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump() ) {
(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_SEMI_COLON)) ;
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump() ) {
@@
-317,7
+318,7
@@
static gras_error_t parse_statement(char *definition,
PARSE_ERROR1("Unparsable size of array (found '%c', expected number)",*end);
/* replace the previously pushed type to an array of it */
PARSE_ERROR1("Unparsable size of array (found '%c', expected number)",*end);
/* replace the previously pushed type to an array of it */
-
TRY(change_to_fixed_array(identifiers,size)
);
+
change_to_fixed_array(identifiers,size
);
/* eat the closing bracket */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
/* eat the closing bracket */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
@@
-332,7
+333,7
@@
static gras_error_t parse_statement(char *definition,
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
/* Handle annotation */
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
/* Handle annotation */
- identifier_t array;
+
s_
identifier_t array;
char *keyname = NULL;
char *keyval = NULL;
memset(&array,0,sizeof(array));
char *keyname = NULL;
char *keyval = NULL;
memset(&array,0,sizeof(array));
@@
-347,7
+348,7
@@
static gras_error_t parse_statement(char *definition,
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1("Unparsable annotation: Expected key name, got '%s'",gras_ddt_parse_text);
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1("Unparsable annotation: Expected key name, got '%s'",gras_ddt_parse_text);
- keyname = strdup(gras_ddt_parse_text);
+ keyname =
(char*)
strdup(gras_ddt_parse_text);
while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
@@
-358,7
+359,7
@@
static gras_error_t parse_statement(char *definition,
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1("Unparsable annotation: Expected key value, got '%s'",gras_ddt_parse_text);
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
PARSE_ERROR1("Unparsable annotation: Expected key value, got '%s'",gras_ddt_parse_text);
- keyval = strdup(gras_ddt_parse_text);
+ keyval =
(char*)
strdup(gras_ddt_parse_text);
while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
while ( (gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump()) == GRAS_DDT_PARSE_TOKEN_EMPTY );
@@
-375,7
+376,7
@@
static gras_error_t parse_statement(char *definition,
identifier.tm.is_ref--;
if (!strcmp(keyval,"1")) {
identifier.tm.is_ref--;
if (!strcmp(keyval,"1")) {
-
TRY(change_to_ref(identifiers)
);
+
change_to_ref(identifiers
);
free(keyval);
continue;
} else {
free(keyval);
continue;
} else {
@@
-385,14
+386,14
@@
static gras_error_t parse_statement(char *definition,
if (! isdigit(*p) )
fixed = 0;
if (fixed) {
if (! isdigit(*p) )
fixed = 0;
if (fixed) {
-
TRY(change_to_fixed_array(identifiers,atoi(keyval)
));
-
TRY(change_to_ref(identifiers)
);
+
change_to_fixed_array(identifiers,atoi(keyval
));
+
change_to_ref(identifiers
);
free(keyval);
continue;
} else {
free(keyval);
continue;
} else {
-
TRY(change_to_ref_pop_array(identifiers)
);
-
TRY(gras_dynar_push(fields_to_push,&keyval)
);
+
change_to_ref_pop_array(identifiers
);
+
xbt_dynar_push(fields_to_push,&keyval
);
continue;
}
}
continue;
}
}
@@
-419,11
+420,11
@@
static gras_error_t parse_statement(char *definition,
/* found a symbol name. Build the type and push it to dynar */
if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
/* found a symbol name. Build the type and push it to dynar */
if(gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
- identifier.name=strdup(gras_ddt_parse_text);
+ identifier.name=
(char*)
strdup(gras_ddt_parse_text);
DEBUG1("Found the identifier \"%s\"",identifier.name);
DEBUG1("Found the identifier \"%s\"",identifier.name);
-
TRY(gras_dynar_push(identifiers, &identifier)
);
- DEBUG1("Dynar_len=%
d",gras
_dynar_length(identifiers));
+
xbt_dynar_push(identifiers, &identifier
);
+ DEBUG1("Dynar_len=%
lu",xbt
_dynar_length(identifiers));
expect_id_separator = 1;
continue;
}
expect_id_separator = 1;
continue;
}
@@
-431,42
+432,38
@@
static gras_error_t parse_statement(char *definition,
PARSE_ERROR0("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
PARSE_ERROR0("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
-
GRAS
_OUT;
+
XBT
_OUT;
return no_error;
}
return no_error;
}
-static gras_datadesc_type_t
*
parse_struct(char *definition) {
+static gras_datadesc_type_t parse_struct(char *definition) {
-
gras
_error_t errcode;
+
xbt
_error_t errcode;
char buffname[32];
static int anonymous_struct=0;
char buffname[32];
static int anonymous_struct=0;
-
gras_dynar_t *
identifiers;
- identifier_t field;
+
xbt_dynar_t
identifiers;
+
s_
identifier_t field;
int i;
int i;
-
gras_dynar_t *
fields_to_push;
+
xbt_dynar_t
fields_to_push;
char *name;
char *name;
- gras_datadesc_type_t
*
struct_type;
+ gras_datadesc_type_t struct_type;
- GRAS_IN;
- errcode=gras_dynar_new(&identifiers,sizeof(identifier_t),NULL);
- errcode=gras_dynar_new(&fields_to_push,sizeof(char*),NULL);
- if (errcode != no_error) {
- GRAS_OUT;
- return NULL;
- }
+ XBT_IN;
+ identifiers = xbt_dynar_new(sizeof(s_identifier_t),NULL);
+ fields_to_push = xbt_dynar_new(sizeof(char*),NULL);
/* Create the struct descriptor */
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
/* Create the struct descriptor */
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
-
TRYFAIL(gras_datadesc_struct(gras_ddt_parse_text,&struct_type)
);
+
struct_type = gras_datadesc_struct(gras_ddt_parse_text
);
VERB1("Parse the struct '%s'", gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
} else {
sprintf(buffname,"anonymous struct %d",anonymous_struct++);
VERB1("Parse the anonymous struct nb %d", anonymous_struct);
VERB1("Parse the struct '%s'", gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
} else {
sprintf(buffname,"anonymous struct %d",anonymous_struct++);
VERB1("Parse the anonymous struct nb %d", anonymous_struct);
-
TRYFAIL(gras_datadesc_struct(buffname,&struct_type)
);
+
struct_type = gras_datadesc_struct(buffname
);
}
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LA)
}
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LA)
@@
-478,34
+475,34
@@
static gras_datadesc_type_t *parse_struct(char *definition) {
errcode == no_error ;
errcode=parse_statement(definition,identifiers,fields_to_push)) {
errcode == no_error ;
errcode=parse_statement(definition,identifiers,fields_to_push)) {
- DEBUG1("This statement contained %
d identifiers",gras
_dynar_length(identifiers));
+ DEBUG1("This statement contained %
lu identifiers",xbt
_dynar_length(identifiers));
/* append the identifiers we've found */
/* append the identifiers we've found */
-
gras
_dynar_foreach(identifiers,i, field) {
+
xbt
_dynar_foreach(identifiers,i, field) {
if (field.tm.is_ref)
PARSE_ERROR2("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
field.name,field.tm.is_ref);
if (field.tm.is_ref)
PARSE_ERROR2("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
field.name,field.tm.is_ref);
- VERB2("Append field '%s' to %p",field.name, struct_type);
-
TRYFAIL(gras_datadesc_struct_append(struct_type, field.name, field.type)
);
+ VERB2("Append field '%s' to %p",field.name,
(void*)
struct_type);
+
gras_datadesc_struct_append(struct_type, field.name, field.type
);
free(field.name);
free(field.type_name);
}
free(field.name);
free(field.type_name);
}
-
gras
_dynar_reset(identifiers);
- DEBUG1("struct_type=%p",struct_type);
+
xbt
_dynar_reset(identifiers);
+ DEBUG1("struct_type=%p",
(void*)
struct_type);
/* Make sure that all fields declaring a size push it into the cbps */
/* Make sure that all fields declaring a size push it into the cbps */
-
gras
_dynar_foreach(fields_to_push,i, name) {
- DEBUG1("struct_type=%p",struct_type);
- VERB2("Push field '%s' into size stack of %p", name, struct_type);
+
xbt
_dynar_foreach(fields_to_push,i, name) {
+ DEBUG1("struct_type=%p",
(void*)
struct_type);
+ VERB2("Push field '%s' into size stack of %p", name,
(void*)
struct_type);
gras_datadesc_cb_field_push(struct_type, name);
free(name);
}
gras_datadesc_cb_field_push(struct_type, name);
free(name);
}
-
gras
_dynar_reset(fields_to_push);
+
xbt
_dynar_reset(fields_to_push);
}
gras_datadesc_struct_close(struct_type);
if (errcode != mismatch_error) {
}
gras_datadesc_struct_close(struct_type);
if (errcode != mismatch_error) {
-
GRAS
_OUT;
+
XBT
_OUT;
return NULL; /* FIXME: LEAK! */
}
return NULL; /* FIXME: LEAK! */
}
@@
-516,20
+513,20
@@
static gras_datadesc_type_t *parse_struct(char *definition) {
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
-
gras_dynar_free(
identifiers);
-
gras_dynar_free(
fields_to_push);
-
GRAS
_OUT;
+
xbt_dynar_free(&
identifiers);
+
xbt_dynar_free(&
fields_to_push);
+
XBT
_OUT;
return struct_type;
}
return struct_type;
}
-static gras_datadesc_type_t
*
parse_typedef(char *definition) {
+static gras_datadesc_type_t parse_typedef(char *definition) {
- type_modifier_t tm;
+
s_
type_modifier_t tm;
- gras_datadesc_type_t
*
struct_desc=NULL;
- gras_datadesc_type_t
*
typedef_desc=NULL;
+ gras_datadesc_type_t struct_desc=NULL;
+ gras_datadesc_type_t typedef_desc=NULL;
-
GRAS
_IN;
+
XBT
_IN;
memset(&tm,0,sizeof(tm));
/* get the aliased type */
memset(&tm,0,sizeof(tm));
/* get the aliased type */
@@
-552,7
+549,7
@@
static gras_datadesc_type_t * parse_typedef(char *definition) {
/* (FIXME: should) build the alias */
PARSE_ERROR0("Cannot handle typedef yet");
/* (FIXME: should) build the alias */
PARSE_ERROR0("Cannot handle typedef yet");
-
GRAS
_OUT;
+
XBT
_OUT;
return typedef_desc;
}
return typedef_desc;
}
@@
-562,21
+559,21
@@
static gras_datadesc_type_t * parse_typedef(char *definition) {
*
* Create a datadescription from the result of parsing the C type description
*/
*
* Create a datadescription from the result of parsing the C type description
*/
-gras_datadesc_type_t
*
+gras_datadesc_type_t
gras_datadesc_parse(const char *name,
const char *C_statement) {
gras_datadesc_parse(const char *name,
const char *C_statement) {
- gras_datadesc_type_t
*
res=NULL;
+ gras_datadesc_type_t res=NULL;
char *definition;
int semicolon_count=0;
int def_count,C_count;
char *definition;
int semicolon_count=0;
int def_count,C_count;
-
GRAS
_IN;
+
XBT
_IN;
/* reput the \n in place for debug */
for (C_count=0; C_statement[C_count] != '\0'; C_count++)
if (C_statement[C_count] == ';' || C_statement[C_count] == '{')
semicolon_count++;
/* reput the \n in place for debug */
for (C_count=0; C_statement[C_count] != '\0'; C_count++)
if (C_statement[C_count] == ';' || C_statement[C_count] == '{')
semicolon_count++;
- definition = malloc(C_count + semicolon_count + 1);
+ definition =
(char*)xbt_
malloc(C_count + semicolon_count + 1);
for (C_count=0,def_count=0; C_statement[C_count] != '\0'; C_count++) {
definition[def_count++] = C_statement[C_count];
if (C_statement[C_count] == ';' || C_statement[C_count] == '{') {
for (C_count=0,def_count=0; C_statement[C_count] != '\0'; C_count++) {
definition[def_count++] = C_statement[C_count];
if (C_statement[C_count] == ';' || C_statement[C_count] == '{') {
@@
-602,7
+599,7
@@
gras_datadesc_parse(const char *name,
} else {
ERROR1("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",definition);
} else {
ERROR1("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",definition);
-
gras
_abort();
+
xbt
_abort();
}
gras_ddt_parse_pointer_string_close();
}
gras_ddt_parse_pointer_string_close();
@@
-612,9
+609,10
@@
gras_datadesc_parse(const char *name,
if (strcmp(res->name,name)) {
ERROR2("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
name,res->name);
if (strcmp(res->name,name)) {
ERROR2("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
name,res->name);
-
gras
_abort();
+
xbt
_abort();
}
}
- GRAS_OUT;
+ gras_ddt_parse_lex_destroy();
+ XBT_OUT;
return res;
}
return res;
}