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 */
type_modifier->is_unsigned = 1;
} else if (!strcmp(gras_ddt_parse_text, "short")) {
type_modifier->is_unsigned = 1;
} else if (!strcmp(gras_ddt_parse_text, "short")) {
type_modifier->is_short = 1;
} else if (!strcmp(gras_ddt_parse_text, "long")) {
type_modifier->is_short = 1;
} else if (!strcmp(gras_ddt_parse_text, "long")) {
type_modifier->is_long++; /* handle "long long" */
} else if (!strcmp(gras_ddt_parse_text, "struct")) {
type_modifier->is_long++; /* handle "long long" */
} else if (!strcmp(gras_ddt_parse_text, "struct")) {
type_modifier->is_struct = 1;
} else if (!strcmp(gras_ddt_parse_text, "union")) {
type_modifier->is_struct = 1;
} else if (!strcmp(gras_ddt_parse_text, "union")) {
type_modifier->is_union = 1;
} else if (!strcmp(gras_ddt_parse_text, "enum")) {
type_modifier->is_union = 1;
} else if (!strcmp(gras_ddt_parse_text, "enum")) {
break;
}
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if ((gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD) &&
(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_STAR)) {
break;
}
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if ((gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD) &&
(gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_STAR)) {
- DEBUG2("Done with modifiers (got %s,%d)", gras_ddt_parse_text,
+ XBT_DEBUG("Done with modifiers (got %s,%d)", gras_ddt_parse_text,
s_identifier_t former, array;
memset(&array, 0, sizeof(array));
s_identifier_t former, array;
memset(&array, 0, sizeof(array));
xbt_dynar_pop(dynar, &former);
array.type_name = (char *) xbt_malloc(strlen(former.type->name) + 48);
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",
+ XBT_DEBUG("Array specification (size=%ld, elm='%s'), change pushed type",
size, former.type_name);
sprintf(array.type_name, "%s%s%s%s[%ld]",
(former.tm.is_unsigned ? "u " : ""),
size, former.type_name);
sprintf(array.type_name, "%s%s%s%s[%ld]",
(former.tm.is_unsigned ? "u " : ""),
array.name = former.name;
xbt_dynar_push(dynar, &array);
array.name = former.name;
xbt_dynar_push(dynar, &array);
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
xbt_dynar_pop(dynar, &former);
ref.type_name = (char *) xbt_malloc(strlen(former.type->name) + 2);
xbt_dynar_pop(dynar, &former);
ref.type_name = (char *) xbt_malloc(strlen(former.type->name) + 2);
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
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);
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);
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
xbt_dynar_pop(dynar, &former);
ref.type = gras_datadesc_dynar(subtype, NULL); /* redeclaration are ignored */
ref.type_name = (char *) strdup(ref.type->name);
xbt_dynar_pop(dynar, &former);
ref.type = gras_datadesc_dynar(subtype, NULL); /* redeclaration are ignored */
ref.type_name = (char *) strdup(ref.type->name);
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
xbt_dynar_pop(dynar, &former);
ref.type = gras_datadesc_matrix(subtype, NULL); /* redeclaration are ignored */
ref.type_name = (char *) strdup(ref.type->name);
xbt_dynar_pop(dynar, &former);
ref.type = gras_datadesc_matrix(subtype, NULL); /* redeclaration are ignored */
ref.type_name = (char *) strdup(ref.type->name);
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
s_identifier_t former, ref;
memset(&ref, 0, sizeof(ref));
xbt_dynar_pop(dynar, &former);
memcpy(former.type->extra, free_f, sizeof(free_f));
xbt_dynar_push(dynar, &former);
xbt_dynar_pop(dynar, &former);
memcpy(former.type->extra, free_f, sizeof(free_f));
xbt_dynar_push(dynar, &former);
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) {
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';'; colon_pos++);
definition[colon_pos] = '\0';
for (colon_pos = gras_ddt_parse_col_pos;
definition[colon_pos] != ';'; colon_pos++);
definition[colon_pos] = '\0';
gras_ddt_parse_text,
definition + gras_ddt_parse_col_pos, gras_ddt_parse_col_pos);
definition[colon_pos] = ';';
}
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
gras_ddt_parse_text,
definition + gras_ddt_parse_col_pos, gras_ddt_parse_col_pos);
definition[colon_pos] = ';';
}
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
/* FIXME: This does not detect recursive definitions at all? */
if (identifier.tm.is_union || identifier.tm.is_enum
|| identifier.tm.is_struct)
/* FIXME: This does not detect recursive definitions at all? */
if (identifier.tm.is_union || identifier.tm.is_enum
|| identifier.tm.is_struct)
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle recursive type definition yet");
/**** get the base type, giving "short a" the needed love ****/
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle recursive type definition yet");
/**** get the base type, giving "short a" the needed love ****/
/* bastard user, they omited "int" ! */
identifier.type_name = (char *) strdup("int");
/* bastard user, they omited "int" ! */
identifier.type_name = (char *) strdup("int");
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
}
/**** build the base type for latter use ****/
if (identifier.tm.is_union) {
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
}
/**** build the base type for latter use ****/
if (identifier.tm.is_union) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle union yet (get callback from annotation?)");
} else if (identifier.tm.is_enum) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle union yet (get callback from annotation?)");
} else if (identifier.tm.is_enum) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle enum yet");
} else if (identifier.tm.is_struct) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot handle enum yet");
} else if (identifier.tm.is_struct) {
} else if (!strcmp(identifier.type_name, "double")) {
if (identifier.tm.is_long)
} else if (!strcmp(identifier.type_name, "double")) {
if (identifier.tm.is_long)
if (!strcmp(identifier.type_name, "xbt_matrix_t")) {
identifier.tm.is_matrix = 1;
} else if (!strcmp(identifier.type_name, "xbt_dynar_t")) {
if (!strcmp(identifier.type_name, "xbt_matrix_t")) {
identifier.tm.is_matrix = 1;
} else if (!strcmp(identifier.type_name, "xbt_dynar_t")) {
/* Handle fixed size arrays */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RB) {
/* Handle fixed size arrays */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_RB) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot deal with [] constructs (yet)");
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
("Unimplemented feature: GRAS_DEFINE_TYPE cannot deal with [] constructs (yet)");
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
("Unparsable size of array. Found '%s', expected number or known constant. Need to use gras_datadesc_set_const(), huh?",
gras_ddt_parse_text);
}
("Unparsable size of array. Found '%s', expected number or known constant. Need to use gras_datadesc_set_const(), huh?",
gras_ddt_parse_text);
}
/* eat the closing bracket */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RB)
/* eat the closing bracket */
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_RB)
- PARSE_ERROR0("Unparsable size of array");
- DEBUG1("Fixed size array, size=%ld", size);
+ PARSE_ERROR("Unparsable size of array");
+ XBT_DEBUG("Fixed size array, size=%ld", size);
char *keyval = NULL;
memset(&array, 0, sizeof(array));
if (strcmp(gras_ddt_parse_text, "GRAS_ANNOTE"))
char *keyval = NULL;
memset(&array, 0, sizeof(array));
if (strcmp(gras_ddt_parse_text, "GRAS_ANNOTE"))
("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",
gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP)
("Unparsable symbol: Expected 'GRAS_ANNOTE', got '%s'",
gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_LP)
("Unparsable annotation: Expected key name, got '%s'",
gras_ddt_parse_text);
keyname = (char *) strdup(gras_ddt_parse_text);
("Unparsable annotation: Expected key name, got '%s'",
gras_ddt_parse_text);
keyname = (char *) strdup(gras_ddt_parse_text);
("Unparsable annotation: expected ',' after the key name, got '%s'",
gras_ddt_parse_text);
("Unparsable annotation: expected ',' after the key name, got '%s'",
gras_ddt_parse_text);
("Unparsable annotation: Expected key value, got '%s'",
gras_ddt_parse_text);
keyval = (char *) strdup(gras_ddt_parse_text);
("Unparsable annotation: Expected key value, got '%s'",
gras_ddt_parse_text);
keyval = (char *) strdup(gras_ddt_parse_text);
if (!strcmp(keyname, "size")) {
if (!identifier.tm.is_ref)
if (!strcmp(keyname, "size")) {
if (!identifier.tm.is_ref)
change_to_dynar_of(identifiers, subtype);
identifier.tm.is_dynar = -1;
} else {
change_to_dynar_of(identifiers, subtype);
identifier.tm.is_dynar = -1;
} else {
} else if (!strcmp(keyname, "free_f")) {
int *storage = xbt_dict_get_or_null(gras_dd_constants, keyval);
if (!storage)
} else if (!strcmp(keyname, "free_f")) {
int *storage = xbt_dict_get_or_null(gras_dd_constants, keyval);
if (!storage)
("value for free_f annotation of field %s is not a known constant",
identifier.name);
if (identifier.tm.is_matrix == -1) {
("value for free_f annotation of field %s is not a known constant",
identifier.name);
if (identifier.tm.is_matrix == -1) {
add_free_f(identifiers, *(void_f_pvoid_t *) storage);
identifier.tm.is_dynar = 0;
} else {
add_free_f(identifiers, *(void_f_pvoid_t *) storage);
identifier.tm.is_dynar = 0;
} else {
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
("Unparsable symbol: Got '%s' instead of expected comma (',')",
gras_ddt_parse_text);
}
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_COLON) {
("Unparsable symbol: Got '%s' instead of expected comma (',')",
gras_ddt_parse_text);
}
} else if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_COLON) {
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
identifier.name = (char *) strdup(gras_ddt_parse_text);
if (gras_ddt_parse_tok_num == GRAS_DDT_PARSE_TOKEN_WORD) {
identifier.name = (char *) strdup(gras_ddt_parse_text);
("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
if (identifier.tm.is_matrix > 0)
("Unparasable symbol (maybe a def struct in a def struct or a parser bug ;)");
}
if (identifier.tm.is_matrix > 0)
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) {
struct_type = gras_datadesc_struct(gras_ddt_parse_text);
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) {
struct_type = gras_datadesc_struct(gras_ddt_parse_text);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
} else {
sprintf(buffname, "anonymous struct %d", anonymous_struct++);
gras_ddt_parse_tok_num = gras_ddt_parse_lex_n_dump();
} else {
sprintf(buffname, "anonymous struct %d", anonymous_struct++);
xbt_dynar_length(identifiers));
/* append the identifiers we've found */
xbt_dynar_foreach(identifiers, iter, field) {
if (field.tm.is_ref)
xbt_dynar_length(identifiers));
/* append the identifiers we've found */
xbt_dynar_foreach(identifiers, iter, field) {
if (field.tm.is_ref)
("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
field.name, field.tm.is_ref);
("Not enough GRAS_ANNOTATE to deal with all dereferencing levels of %s (%d '*' left)",
field.name, field.tm.is_ref);
gras_datadesc_struct_append(struct_type, field.name, field.type);
free(field.name);
free(field.type_name);
}
xbt_dynar_reset(identifiers);
gras_datadesc_struct_append(struct_type, field.name, field.type);
free(field.name);
free(field.type_name);
}
xbt_dynar_reset(identifiers);
/* Make sure that all fields declaring a size push it into the cbps */
xbt_dynar_foreach(fields_to_push, iter, name) {
/* Make sure that all fields declaring a size push it into the cbps */
xbt_dynar_foreach(fields_to_push, iter, name) {
name + 1, (void *) struct_type);
gras_datadesc_cb_field_push_multiplier(struct_type, name + 1);
} else {
name + 1, (void *) struct_type);
gras_datadesc_cb_field_push_multiplier(struct_type, name + 1);
} else {
name, (void *) struct_type);
gras_datadesc_cb_field_push(struct_type, name);
}
name, (void *) struct_type);
gras_datadesc_cb_field_push(struct_type, name);
}
memset(&tm, 0, sizeof(tm));
/* get the aliased type */
memset(&tm, 0, sizeof(tm));
/* get the aliased type */
("GRAS_DEFINE_TYPE cannot handle reference without annotation");
/* get the aliasing name */
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
("GRAS_DEFINE_TYPE cannot handle reference without annotation");
/* get the aliasing name */
if (gras_ddt_parse_tok_num != GRAS_DDT_PARSE_TOKEN_WORD)
("Unparsable typedef: Expected the alias name, and got '%s'",
gras_ddt_parse_text);
/* (FIXME: should) build the alias */
("Unparsable typedef: Expected the alias name, and got '%s'",
gras_ddt_parse_text);
/* (FIXME: should) build the alias */
/* 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] == '{')
/* 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] == '{')
gras_ddt_parse_pointer_string_init(definition);
/* Do I have a typedef, or a raw struct ? */
gras_ddt_parse_pointer_string_init(definition);
/* Do I have a typedef, or a raw struct ? */
("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",
definition);
xbt_abort();
}
gras_ddt_parse_pointer_string_close();
("Failed to parse the following symbol (not a struct neither a typedef) :\n%s",
definition);
xbt_abort();
}
gras_ddt_parse_pointer_string_close();
free(definition);
/* register it under the name provided as symbol */
if (strcmp(res->name, name)) {
free(definition);
/* register it under the name provided as symbol */
if (strcmp(res->name, name)) {
("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
name, res->name);
xbt_abort();
}
gras_ddt_parse_lex_destroy();
("In GRAS_DEFINE_TYPE, the provided symbol (here %s) must be the C type name (here %s)",
name, res->name);
xbt_abort();
}
gras_ddt_parse_lex_destroy();