On Fri, 24 Dec 2010 12:19:31 -0800 "Enlightenment SVN" <no-re...@enlightenment.org> wrote:
> Log: > allow "special" names to be used for struct members (ie not valid C names) > using something like string crazy_string > { this_...@$#:_is&the+name::\\of|the%struct^member* }; > > Author: discomfitor > Date: 2010-12-24 12:19:31 -0800 (Fri, 24 Dec 2010) > New Revision: 55750 > Trac: http://trac.enlightenment.org/e/changeset/55750 > > Modified: > trunk/PROTO/azy/src/bin/azy.c trunk/PROTO/azy/src/bin/azy.h > trunk/PROTO/azy/src/bin/azy_parser.yre trunk/PROTO/azy/src/bin/main.c > trunk/PROTO/azy/src/tests/test.azy > > Modified: trunk/PROTO/azy/src/bin/azy.c > =================================================================== > --- trunk/PROTO/azy/src/bin/azy.c 2010-12-24 18:15:34 UTC (rev 55749) > +++ trunk/PROTO/azy/src/bin/azy.c 2010-12-24 20:19:31 UTC (rev 55750) > @@ -191,11 +191,6 @@ > return strcmp(m1->name, m2->name); > } > > -void > -azy_process(Azy_Model *azy __UNUSED__) > -{ > -} > - > Azy_Error_Code * > azy_error_new(Azy_Model *azy, > Azy_Server_Module *module, > > Modified: trunk/PROTO/azy/src/bin/azy.h > =================================================================== > --- trunk/PROTO/azy/src/bin/azy.h 2010-12-24 18:15:34 UTC (rev 55749) > +++ trunk/PROTO/azy/src/bin/azy.h 2010-12-24 20:19:31 UTC (rev 55750) > @@ -55,6 +55,7 @@ > struct _Azy_Struct_Member > { > const char *name; > + const char *strname; > Azy_Typedef *type; > }; > > @@ -154,8 +155,6 @@ > const char *azy_typedef_vala_name(Azy_Typedef *t); > const char *azy_typedef_azy_name(Azy_Typedef *t); > > -void azy_process(Azy_Model *ctx); > - > const char *azy_stringshare_toupper(const char *str); > > #endif > > Modified: trunk/PROTO/azy/src/bin/azy_parser.yre > =================================================================== > --- trunk/PROTO/azy/src/bin/azy_parser.yre 2010-12-24 18:15:34 UTC > (rev 55749) +++ trunk/PROTO/azy/src/bin/azy_parser.yre 2010-12-24 > 20:19:31 UTC (rev 55750) @@ -30,10 +30,12 @@ > #include "azy_parser_lib.h" > #include "azy_parser.h" > #include "azy.h" > +#include <ctype.h> > > #define YYCTYPE char > #define YYCURSOR c > #define YYMARKER q > +#define YYCTXMARKER t > > #define AZY_EOF 0 > #define AZY_UNKNOWN (-1) > @@ -62,7 +64,7 @@ > static Azy_Token * > azy_parser_stream_to_token(Azy_Stream *s) > { > - const char *c, *b, *q; > + const char *c, *b, *q, *t; > > if (s->length == s->index) > return azy_parser_token_new(s, AZY_EOF, 0); > @@ -81,6 +83,7 @@ > D = [0-9]; > L = [A-Za-z_]; > C = [A-Za-z0-9_ !?,.]; > + S = [\041-\172\|~]; > CODESTART = "<%"; > CODEEND = "%>"; > SLCOM = "//" (.\ENDINPUT)* ("\n"|ENDINPUT); > @@ -102,7 +105,8 @@ > "Azy_Module" { RET(AZY_MODULE); } > "array" { RET(AZY_ARRAY); } > "struct" { RET(AZY_STRUCT); } > - ("{" C+ "}") { RET(AZY_ERRMSG); } > + "{" C+ "}" { RET(AZY_ERRMSG); } > + [{][ ]S+/[ ][}] { RET(AZY_STRUCTMEMSTR); } > L (L|D)* { RET(AZY_ID); } > D+ { RET(AZY_INTEGER); } > "=" { RET(AZY_EQ); } > @@ -114,33 +118,33 @@ > "(" { RET(AZY_LP); } > ")" { RET(AZY_RP); } > "," { RET(AZY_COMMA); } > - ENDINPUT { RET(AZY_EOF); } > + ENDINPUT { RET(AZY_EOF); } > NONPRINT { RET(AZY_UNKNOWN); } > > */ > > code: > /*!re2c > - "%>" { RET(AZY_CODE); } > + "%>" { RET(AZY_CODE); } > ENDINPUT { RET(AZY_UNKNOWN); } > NONPRINT { goto code; } > */ > > comment: > /*!re2c > - "*/" { NEXT; goto main; } > - ENDINPUT { RET(AZY_UNKNOWN); } > - NONPRINT { goto comment; } > + "*/" { NEXT; goto main; } > + ENDINPUT { RET(AZY_UNKNOWN); } > + NONPRINT { goto comment; } > */ > > return NULL; > } > > - Azy_Model *azy_parse_string(const char *str, Eina_Bool * err) > + Azy_Model *azy_parse_string(const char *str, Eina_Bool *err) > { > return azy_parser_string_parse(str, err, azy_parser_, > azy_parser_Alloc, azy_parser_Free, azy_parser_stream_to_token); } > - Azy_Model *azy_parse_file(const char *path, Eina_Bool * err) > + Azy_Model *azy_parse_file(const char *path, Eina_Bool *err) > { > return azy_parser_file_parse(path, err, azy_parser_, azy_parser_Alloc, > azy_parser_Free, azy_parser_stream_to_token); } > @@ -210,6 +214,7 @@ > struct_members(Y) ::= struct_member(X). {Y = eina_list_append(NULL, X);} > struct_members(Y) ::= struct_members(L) struct_member(X). {Y = > eina_list_append(L, X);} > +/* struct member without special name */ > %type struct_member {Azy_Struct_Member *} > struct_member(Y) ::= type(T) ID(N) SEMICOL. { > Y = calloc(sizeof(Azy_Struct_Member), 1); > @@ -217,7 +222,21 @@ > Y->name = eina_stringshare_add(N->text); > azy_parser_token_free(N); > } > +/* struct member with special name */ > +struct_member(Y) ::= type(T) ID(N) STRUCTMEMSTR(S) RB SEMICOL. { > + Y = calloc(sizeof(Azy_Struct_Member), 1); > + Y->type = T; > + Y->name = eina_stringshare_add(N->text); > + { > + const char *nospaces = S->text + 1; /* skip LB */ > > + while (isspace(*nospaces)) nospaces++; /* skip spaces */ > + Y->strname = eina_stringshare_add(nospaces); > + } > + azy_parser_token_free(N); > + azy_parser_token_free(S); > +} > + > module_decl ::= module_decl_head module_decl_body. > module_decl_head ::= opt_doc_comment(C) MODULE ID(N). { > if (!MODEL)_MODEL = azy_new(); > > Modified: trunk/PROTO/azy/src/bin/main.c > =================================================================== > --- trunk/PROTO/azy/src/bin/main.c 2010-12-24 18:15:34 UTC (rev 55749) > +++ trunk/PROTO/azy/src/bin/main.c 2010-12-24 20:19:31 UTC (rev 55750) > @@ -193,7 +193,7 @@ > > EINA_LIST_FOREACH(t->struct_members, l, m) > { > - EL(1, "azy_value_struct_member_set(azy_value_struct, \"%s\", > %s);", m->name, m->name); > + EL(1, "azy_value_struct_member_set(azy_value_struct, \"%s\", > %s);", m->strname ? m->strname : m->name, m->name); } > > EL(1, "return azy_value_struct;"); > @@ -220,7 +220,7 @@ > > EINA_LIST_FOREACH(t->struct_members, l, m) > { > - EL(1, "v = azy_value_struct_member_get(azy_value_struct, > \"%s\");", m->name); > + EL(1, "v = azy_value_struct_member_get(azy_value_struct, > \"%s\");", m->strname ? m->strname : m->name); EL(1, "if (v && (!%s(v, > &azy_user_type_tmp->%s)))", m->type->demarch_name, m->name); EL(2, "goto > error;"); } > @@ -457,7 +457,7 @@ > { > if (m->type->hash_func) > { > - EL(1, "new->%s = %s(eina_hash_find(h, \"%s\"));", m->name, > m->type->hash_func, m->name); > + EL(1, "new->%s = %s(eina_hash_find(h, \"%s\"));", m->name, > m->type->hash_func, m->strname ? m->strname : m->name); EL(1, > "EINA_SAFETY_ON_NULL_GOTO(new->%s, error);", m->name); } > else > @@ -1803,7 +1803,6 @@ > printf("Error parsing file!\n"); > exit(1); > } > - azy_process(azy); > sep = (azy->name) ? "_" : ""; > name = (azy->name) ? azy->name : ""; > > > Modified: trunk/PROTO/azy/src/tests/test.azy > =================================================================== > --- trunk/PROTO/azy/src/tests/test.azy 2010-12-24 18:15:34 UTC (rev > 55749) +++ trunk/PROTO/azy/src/tests/test.azy 2010-12-24 20:19:31 UTC > (rev 55750) @@ -37,6 +37,7 @@ > /** string member named v_string; strings are stringshared > * const char* > */ > + string crazy_string { this_...@$#:_is&the+name::\\of|the%struct^member* }; > string v_string; > }; > > > > ------------------------------------------------------------------------------ > Learn how Oracle Real Application Clusters (RAC) One Node allows customers > to consolidate database storage, standardize their database environment, and, > should the need arise, upgrade to a full multi-node Oracle RAC database > without downtime or disruption > http://p.sf.net/sfu/oracle-sfdevnl > _______________________________________________ > enlightenment-svn mailing list > enlightenment-...@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn This allows struct member name aliasing to get around struct members which have names that use [:?$] or the like, but has no impact on members defined without aliases. -- Mike Blumenkrantz Zentific: We run the three-legged race individually. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ enlightenment-devel mailing list enlightenment-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-devel