Commit d03a067b authored by Michael Meskes's avatar Michael Meskes

ecpg now recognizes named structs/unions. So you don't have to list the whole...

ecpg now recognizes named structs/unions. So you don't have to list the whole definition everytime you declare a variable anymore.
parent 0b5b3e9e
...@@ -1432,6 +1432,10 @@ Tue May 20 11:47:00 CEST 2003 ...@@ -1432,6 +1432,10 @@ Tue May 20 11:47:00 CEST 2003
- Reversed my fix for ifdef. It was the example, not ecpg which was - Reversed my fix for ifdef. It was the example, not ecpg which was
incorrect. incorrect.
- Changed DBPATH variable to PG_DBPATH. - Changed DBPATH variable to PG_DBPATH.
Thu May 22 09:33:54 CEST 2003
- ecpg now recognizes named struct/union usage.
- Set ecpg version to 2.12.0. - Set ecpg version to 2.12.0.
- Set ecpg library to 3.4.2. - Set ecpg library to 3.4.2.
- Set pgtypes library to 1.0.0 - Set pgtypes library to 1.0.0
......
...@@ -192,7 +192,7 @@ output_get_descr(char *desc_name, char *index) ...@@ -192,7 +192,7 @@ output_get_descr(char *desc_name, char *index)
break; break;
} }
fprintf(yyout, "%s,", get_dtype(results->value)); fprintf(yyout, "%s,", get_dtype(results->value));
ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL); ECPGdump_a_type(yyout, v->name, v->type, NULL, NULL, NULL, NULL, NULL, NULL, make_str("0"), NULL, NULL);
} }
drop_assignments(); drop_assignments();
fputs("ECPGd_EODT);\n", yyout); fputs("ECPGd_EODT);\n", yyout);
......
...@@ -73,8 +73,8 @@ extern void add_descriptor(char *, char *); ...@@ -73,8 +73,8 @@ extern void add_descriptor(char *, char *);
extern void drop_descriptor(char *, char *); extern void drop_descriptor(char *, char *);
extern struct descriptor *lookup_descriptor(char *, char *); extern struct descriptor *lookup_descriptor(char *, char *);
extern struct variable *descriptor_variable(const char *name, int input); extern struct variable *descriptor_variable(const char *name, int input);
extern void add_variable(struct arguments **, struct variable *, struct variable *); extern void add_variable(struct arguments **, struct variable *, char *i, struct variable *, char *);
extern void append_variable(struct arguments **, struct variable *, struct variable *); extern void append_variable(struct arguments **, struct variable *, char *, struct variable *, char *);
extern void dump_variables(struct arguments *, int); extern void dump_variables(struct arguments *, int);
extern struct typedefs *get_typedef(char *); extern struct typedefs *get_typedef(char *);
extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int); extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int);
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.109 2003/05/20 11:05:27 meskes Exp $ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.110 2003/05/22 07:58:41 meskes Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -434,20 +434,6 @@ cppline {space}*#(.*\\{space})+.* ...@@ -434,20 +434,6 @@ cppline {space}*#(.*\\{space})+.*
else else
return yytext[0]; return yytext[0];
} }
<C>{informix_special}{struct} {
/* are we simulating Informix? */
if (compat == ECPG_COMPAT_INFORMIX)
{
string_unput("typedef struct ");
BEGIN SQL;
return SQL_START;
}
else
{
string_unput("struct ");
return S_ANYTHING;
}
}
<SQL>{self} { /* <SQL>{self} { /*
* We may find a ';' inside a structure * We may find a ';' inside a structure
* definition in a TYPE or VAR statement. * definition in a TYPE or VAR statement.
...@@ -905,7 +891,7 @@ cppline {space}*#(.*\\{space})+.* ...@@ -905,7 +891,7 @@ cppline {space}*#(.*\\{space})+.*
<xskip>{other} { /* ignore */ } <xskip>{other} { /* ignore */ }
<xcond>{identifier}{space}*';' { <xcond>{identifier}{space}*";" {
if ( preproc_tos >= MAX_NESTED_IF-1 ) { if ( preproc_tos >= MAX_NESTED_IF-1 ) {
mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions"); mmerror(PARSE_ERROR, ET_FATAL, "Too many nested 'EXEC SQL IFDEF' conditions");
} }
......
This diff is collapsed.
...@@ -214,7 +214,8 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c ...@@ -214,7 +214,8 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, c
void void
ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type, ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
const char *ind_name, struct ECPGtype * ind_type, const char *var_array_element, const char *ind_name,
struct ECPGtype * ind_type, const char *ind_array_element,
const char *prefix, const char *ind_prefix, const char *prefix, const char *ind_prefix,
char *arr_str_siz, const char *struct_sizeof, char *arr_str_siz, const char *struct_sizeof,
const char *ind_struct_sizeof) const char *ind_struct_sizeof)
...@@ -450,7 +451,11 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz, ...@@ -450,7 +451,11 @@ ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, char *arrsiz,
for (p = type->u.members; p; p = p->next) for (p = type->u.members; p; p = p->next)
{ {
ECPGdump_a_type(o, p->name, p->type, (ind_p != NULL) ? ind_p->name : NULL, (ind_p != NULL) ? ind_p->type : NULL, prefix, ind_prefix, arrsiz, type->struct_sizeof, (ind_p != NULL) ? ind_type->struct_sizeof : NULL); ECPGdump_a_type(o, p->name, p->type, NULL,
(ind_p != NULL) ? ind_p->name : NULL,
(ind_p != NULL) ? ind_p->type : NULL, NULL,
prefix, ind_prefix, arrsiz, type->struct_sizeof,
(ind_p != NULL) ? ind_type->struct_sizeof : NULL);
if (ind_p != NULL && ind_p != &struct_no_indicator) if (ind_p != NULL && ind_p != &struct_no_indicator)
ind_p = ind_p->next; ind_p = ind_p->next;
} }
......
...@@ -50,8 +50,8 @@ void ECPGfree_type(struct ECPGtype *); ...@@ -50,8 +50,8 @@ void ECPGfree_type(struct ECPGtype *);
the variable (required to do array fetches of structs). the variable (required to do array fetches of structs).
*/ */
void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const char *, void ECPGdump_a_type(FILE *, const char *, struct ECPGtype *, const char *,
struct ECPGtype *, const char *, const char *, char *, const char *, struct ECPGtype *, const char *, const char *,
const char *, const char *); const char *, char *, const char *, const char *);
/* A simple struct to keep a variable and its type. */ /* A simple struct to keep a variable and its type. */
struct ECPGtemp_type struct ECPGtemp_type
...@@ -141,7 +141,9 @@ struct variable ...@@ -141,7 +141,9 @@ struct variable
struct arguments struct arguments
{ {
struct variable *variable; struct variable *variable;
char *var_array_element;
struct variable *indicator; struct variable *indicator;
char *ind_array_element;
struct arguments *next; struct arguments *next;
}; };
......
...@@ -194,19 +194,21 @@ reset_variables(void) ...@@ -194,19 +194,21 @@ reset_variables(void)
/* Insert a new variable into our request list. */ /* Insert a new variable into our request list. */
void void
add_variable(struct arguments ** list, struct variable * var, struct variable * ind) add_variable(struct arguments ** list, struct variable * var, char * var_array_element, struct variable * ind, char * ind_array_element)
{ {
struct arguments *p = (struct arguments *) mm_alloc(sizeof(struct arguments)); struct arguments *p = (struct arguments *) mm_alloc(sizeof(struct arguments));
p->variable = var; p->variable = var;
p->var_array_element = var_array_element;
p->indicator = ind; p->indicator = ind;
p->ind_array_element = ind_array_element;
p->next = *list; p->next = *list;
*list = p; *list = p;
} }
/* Append a new variable to our request list. */ /* Append a new variable to our request list. */
void void
append_variable(struct arguments ** list, struct variable * var, struct variable * ind) append_variable(struct arguments ** list, struct variable * var, char * var_array_element, struct variable * ind, char * ind_array_element)
{ {
struct arguments *p, struct arguments *p,
*new = (struct arguments *) mm_alloc(sizeof(struct arguments)); *new = (struct arguments *) mm_alloc(sizeof(struct arguments));
...@@ -214,7 +216,9 @@ append_variable(struct arguments ** list, struct variable * var, struct variable ...@@ -214,7 +216,9 @@ append_variable(struct arguments ** list, struct variable * var, struct variable
for (p = *list; p && p->next; p = p->next); for (p = *list; p && p->next; p = p->next);
new->variable = var; new->variable = var;
new->var_array_element = var_array_element;
new->indicator = ind; new->indicator = ind;
new->ind_array_element = ind_array_element;
new->next = NULL; new->next = NULL;
if (p) if (p)
...@@ -241,8 +245,9 @@ dump_variables(struct arguments * list, int mode) ...@@ -241,8 +245,9 @@ dump_variables(struct arguments * list, int mode)
dump_variables(list->next, mode); dump_variables(list->next, mode);
/* Then the current element and its indicator */ /* Then the current element and its indicator */
ECPGdump_a_type(yyout, list->variable->name, list->variable->type, ECPGdump_a_type(yyout, list->variable->name, list->variable->type, list->var_array_element,
list->indicator->name, list->indicator->type, NULL, NULL, 0, NULL, NULL); list->indicator->name, list->indicator->type, list->ind_array_element,
NULL, NULL, 0, NULL, NULL);
/* Then release the list element. */ /* Then release the list element. */
if (mode != 0) if (mode != 0)
......
...@@ -9,20 +9,19 @@ typedef char* c; ...@@ -9,20 +9,19 @@ typedef char* c;
exec sql type ind is union { int integer; short smallint; }; exec sql type ind is union { int integer; short smallint; };
typedef union { int integer; short smallint; } ind; typedef union { int integer; short smallint; } ind;
#define BUFSIZ 8 #define BUFFERSIZ 8
exec sql type str is varchar[BUFSIZ]; exec sql type str is varchar[BUFFERSIZ];
int int
main () main ()
{ {
typedef struct { long born; short age; } birthinfo; exec sql struct birthinfo { long born; short age; };
exec sql type birthinfo is struct { long born; short age; };
exec sql begin declare section; exec sql begin declare section;
struct personal_struct { str name; struct personal_struct { str name;
birthinfo birth; struct birthinfo birth;
} personal, *p; } personal, *p;
struct personal_indicator { int ind_name; struct personal_indicator { int ind_name;
birthinfo ind_birth; struct birthinfo ind_birth;
} ind_personal, *i; } ind_personal, *i;
ind ind_children; ind ind_children;
c testname="Petra"; c testname="Petra";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment