gwenhywfar  5.4.1
tm_builder.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Thu Jul 02 2009
3  copyright : (C) 2009 by Martin Preuss
4  email : martin@libchipcard.de
5 
6  ***************************************************************************
7  * Please see toplevel file COPYING for license details *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 # include <config.h>
12 #endif
13 
14 
15 #include "tm_builder_p.h"
16 #include "tm_member.h"
17 
18 #include <gwenhywfar/debug.h>
19 #include <gwenhywfar/misc.h>
20 
21 #include <assert.h>
22 #include <errno.h>
23 #include <string.h>
24 #include <ctype.h>
25 
26 
27 
28 /* ------------------------------------------------------------------------------------------------
29  * forward declarations
30  * ------------------------------------------------------------------------------------------------
31  */
32 
33 
34 static void setCharValueWithTypePrefix(GWEN_DB_NODE *db, const char *prefix, const char *varName, const char *value);
36  TYPEMAKER2_TYPE *ty,
38  GWEN_DB_NODE *db,
39  int withTypePrefix);
40 
41 
42 /* ------------------------------------------------------------------------------------------------
43  * implementations
44  * ------------------------------------------------------------------------------------------------
45  */
46 
47 
48 
50 
51 
52 
54 {
56 
59 
60  tb->declarationsPublic=GWEN_StringList_new();
61  tb->declarationsLibrary=GWEN_StringList_new();
62  tb->declarationsProtected=GWEN_StringList_new();
63  tb->declarationsPrivate=GWEN_StringList_new();
64  tb->code=GWEN_StringList_new();
65 
66  return tb;
67 }
68 
69 
70 
72 {
73  if (tb) {
75 
76  GWEN_StringList_free(tb->declarationsPublic);
77  GWEN_StringList_free(tb->declarationsLibrary);
78  GWEN_StringList_free(tb->declarationsProtected);
79  GWEN_StringList_free(tb->declarationsPrivate);
80  GWEN_StringList_free(tb->code);
81  free(tb->fileNamePublic);
82  free(tb->fileNameLibrary);
83  free(tb->fileNameProtected);
84  free(tb->fileNamePrivate);
85  free(tb->fileNameCode);
86  free(tb->destFolder);
87  GWEN_FREE_OBJECT(tb);
88  }
89 }
90 
91 
92 
94 {
95  assert(tb);
96  return tb->declarationsPublic;
97 }
98 
99 
100 
102 {
103  assert(tb);
104  return tb->declarationsLibrary;
105 }
106 
107 
108 
110 {
111  assert(tb);
112  return tb->declarationsProtected;
113 }
114 
115 
116 
118 {
119  assert(tb);
120  return tb->declarationsPrivate;
121 }
122 
123 
124 
126 {
127  assert(tb);
128  return tb->code;
129 }
130 
131 
132 
134 {
135  assert(tb);
136  return tb->typeManager;
137 }
138 
139 
140 
142 {
143  assert(tb);
144  tb->typeManager=tm;
145 }
146 
147 
148 
150 {
151  assert(tb);
152  GWEN_StringList_AppendString(tb->declarationsPublic, s, 0, 0);
153 }
154 
155 
156 
158 {
159  assert(tb);
160  GWEN_StringList_AppendString(tb->declarationsLibrary, s, 0, 0);
161 }
162 
163 
164 
166 {
167  assert(tb);
168  GWEN_StringList_AppendString(tb->declarationsProtected, s, 0, 0);
169 }
170 
171 
172 
174 {
175  assert(tb);
176  GWEN_StringList_AppendString(tb->declarationsPrivate, s, 0, 0);
177 }
178 
179 
180 
182 {
183  assert(tb);
184  GWEN_StringList_AppendString(tb->code, s, 0, 0);
185 }
186 
187 
188 
190 {
191  assert(tb);
192  return tb->fileNamePublic;
193 }
194 
195 
196 
198 {
199  assert(tb);
200  free(tb->fileNamePublic);
201  if (s)
202  tb->fileNamePublic=strdup(s);
203  else
204  tb->fileNamePublic=NULL;
205 }
206 
207 
208 
210 {
211  assert(tb);
212  return tb->fileNameLibrary;
213 }
214 
215 
216 
218 {
219  assert(tb);
220  free(tb->fileNameLibrary);
221  if (s)
222  tb->fileNameLibrary=strdup(s);
223  else
224  tb->fileNameLibrary=NULL;
225 }
226 
227 
228 
230 {
231  assert(tb);
232  return tb->fileNameProtected;
233 }
234 
235 
236 
238 {
239  assert(tb);
240  free(tb->fileNameProtected);
241  if (s)
242  tb->fileNameProtected=strdup(s);
243  else
244  tb->fileNameProtected=NULL;
245 }
246 
247 
248 
250 {
251  assert(tb);
252  return tb->fileNamePrivate;
253 }
254 
255 
256 
258 {
259  assert(tb);
260  free(tb->fileNamePrivate);
261  if (s)
262  tb->fileNamePrivate=strdup(s);
263  else
264  tb->fileNamePrivate=NULL;
265 }
266 
267 
268 
270 {
271  assert(tb);
272  return tb->fileNameCode;
273 }
274 
275 
276 
278 {
279  assert(tb);
280  free(tb->fileNameCode);
281  if (s)
282  tb->fileNameCode=strdup(s);
283  else
284  tb->fileNameCode=NULL;
285 }
286 
287 
288 
290 {
291  assert(tb);
292  return tb->sourceFileName;
293 }
294 
295 
296 
298 {
299  assert(tb);
300  free(tb->sourceFileName);
301  if (s)
302  tb->sourceFileName=strdup(s);
303  else
304  tb->sourceFileName=NULL;
305 }
306 
307 
308 
310 {
311  assert(tb);
312  return tb->destFolder;
313 }
314 
315 
316 
318 {
319  assert(tb);
320  free(tb->destFolder);
321  if (s)
322  tb->destFolder=strdup(s);
323  else
324  tb->destFolder=NULL;
325 }
326 
327 
328 
330 {
331  assert(tb);
332  tb->buildFn=fn;
333 }
334 
335 
336 
338 {
339  assert(tb);
340  if (tb->buildFn)
341  return tb->buildFn(tb, ty);
342  else
344 }
345 
346 
347 
349  TYPEMAKER2_TYPE *ty,
350  TYPEMAKER2_MEMBER *tm,
351  const char *src,
352  const char *dst)
353 {
354  GWEN_DB_NODE *db;
355  const char *s;
356 
357  db=GWEN_DB_Group_new("vars");
358 
359  if (tb->typeManager) {
360  s=Typemaker2_TypeManager_GetApiDeclaration(tb->typeManager);
361  if (s && *s)
363  else
365  }
366 
367  /* set some type vars */
368  if (ty) {
369  TYPEMAKER2_TYPE *bty;
370  TYPEMAKER2_MEMBER_LIST *tml;
371 
373  if (s && *s)
374  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "struct_type", s);
375 
377  if (s && *s)
378  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "struct_prefix", s);
379 
381  if (bty) {
383  if (s && *s)
384  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "basetype_type", s);
385 
387  if (s && *s)
388  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "basetype_prefix", s);
389  }
390 
392  if (tml) {
393  TYPEMAKER2_MEMBER *tmm;
394 
395  tmm=Typemaker2_Member_List_First(tml);
396  while (tmm) {
397  /* write members with prefix */
398  addMemberInfoToCallDb(tb, ty, tmm, db, 1);
399  tmm=Typemaker2_Member_List_Next(tmm);
400  }
401  }
402  }
403 
404  /* set some member vars */
405  if (tm)
406  /* write specific member without prefix */
407  addMemberInfoToCallDb(tb, ty, tm, db, 0);
408 
409  /* set src and dst */
410  if (src && *src)
412  if (dst && *dst)
414 
415  /* set some fixed vars */
416  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "retval", "p_rv");
418  GWEN_DB_SetCharValue(db, GWEN_DB_FLAGS_OVERWRITE_VARS, "buffer", "p_buffer");
419 
420  return db;
421 }
422 
423 
424 
427  TYPEMAKER2_MEMBER *tm,
428  GWEN_DB_NODE *db,
429  int withTypePrefix)
430 {
431  const char *s;
432  const char *prefix=NULL;
433  char numbuf[32];
434  TYPEMAKER2_TYPE *mty;
435 
437  if (withTypePrefix)
438  prefix=s;
439 
440  if (s && *s) {
441  GWEN_BUFFER *tbuf;
442 
443  setCharValueWithTypePrefix(db, prefix, "name", s);
444 
445  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
446  GWEN_Buffer_AppendByte(tbuf, toupper(*s));
447  GWEN_Buffer_AppendString(tbuf, s+1);
448  setCharValueWithTypePrefix(db, prefix, "nameWithCapital", GWEN_Buffer_GetStart(tbuf));
449  GWEN_Buffer_free(tbuf);
450  }
451 
453  if (s && *s)
454  setCharValueWithTypePrefix(db, prefix, "element_name", s);
455  else
456  /* default behaviour is to use the name "element" for list members in GWEN_DBs */
457  setCharValueWithTypePrefix(db, prefix, "element_name", "element");
458 
460 
462 
464  /* set field number for toObject/fromObject */
466  if (s && *s)
467  setCharValueWithTypePrefix(db, prefix, "fieldid", s);
468  }
469 
470  /* maxlen */
471  snprintf(numbuf, sizeof(numbuf)-1, "%d", Typemaker2_Member_GetMaxLen(tm));
472  setCharValueWithTypePrefix(db, prefix, "maxlen", numbuf);
473 
474  /* set basetype stuff */
476  assert(mty);
477  if (mty) {
478  TYPEMAKER2_TYPE *bty;
479 
480  setCharValueWithTypePrefix(db, prefix, "member_type", Typemaker2_Type_GetIdentifier(mty));
481  setCharValueWithTypePrefix(db, prefix, "member_prefix", Typemaker2_Type_GetPrefix(mty));
482 
484  if (bty) {
485  setCharValueWithTypePrefix(db, prefix, "member_basetype_type", Typemaker2_Type_GetIdentifier(bty));
486  setCharValueWithTypePrefix(db, prefix, "member_basetype_prefix", Typemaker2_Type_GetPrefix(bty));
487  }
488  }
489 
490  /* set enum-specific stuff */
492  TYPEMAKER2_ENUM *te;
493 
495  if (te) {
496  setCharValueWithTypePrefix(db, prefix, "enum_fromstring_fn", Typemaker2_Enum_GetFromStringFn(te));
497  setCharValueWithTypePrefix(db, prefix, "enum_tostring_fn", Typemaker2_Enum_GetToStringFn(te));
498  }
499  }
500 }
501 
502 
503 
504 void setCharValueWithTypePrefix(GWEN_DB_NODE *db, const char *prefix, const char *varName, const char *value)
505 {
506  if (value) {
507  if (prefix && *prefix) {
508  GWEN_BUFFER *tbuf;
509 
510  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
511  GWEN_Buffer_AppendString(tbuf, prefix);
512  GWEN_Buffer_AppendString(tbuf, ".");
513  GWEN_Buffer_AppendString(tbuf, varName);
515  GWEN_Buffer_free(tbuf);
516  }
517  else {
519  }
520  }
521 }
522 
523 
524 
526  GWEN_DB_NODE *db,
527  GWEN_BUFFER *dbuf)
528 {
529  const char *p;
530 
531  p=s;
532  while (*p) {
533  if (*p=='$') {
534  p++;
535  if (*p=='$')
536  GWEN_Buffer_AppendByte(dbuf, '$');
537  else if (*p=='(') {
538  const char *pStart;
539 
540  p++;
541  pStart=p;
542  while (*p && *p!=')')
543  p++;
544  if (*p!=')') {
545  DBG_ERROR(GWEN_LOGDOMAIN, "Unterminated variable name in code");
546  return GWEN_ERROR_BAD_DATA;
547  }
548  else {
549  int len;
550  char *name;
551  const char *v;
552 
553  len=p-pStart;
554  if (len<1) {
555  DBG_ERROR(GWEN_LOGDOMAIN, "Empty variable name in code");
556  return GWEN_ERROR_BAD_DATA;
557  }
558  name=(char *) malloc(len+1);
559  assert(name);
560  memmove(name, pStart, len);
561  name[len]=0;
562  v=GWEN_DB_GetCharValue(db, name, 0, NULL);
563  if (v) {
564  free(name);
565  GWEN_Buffer_AppendString(dbuf, v);
566  }
567 #if 0 /* just replace with empty value */
568  else {
569  GWEN_Buffer_AppendString(dbuf, " [__VALUE OF ");
570  GWEN_Buffer_AppendString(dbuf, name);
571  GWEN_Buffer_AppendString(dbuf, " WAS NOT SET__] ");
572  free(name);
573  }
574 #endif
575  }
576  }
577  else {
578  DBG_ERROR(GWEN_LOGDOMAIN, "Bad variable string in code");
579  return GWEN_ERROR_BAD_DATA;
580  }
581  p++;
582  }
583  else {
584  if (*p=='#') {
585  /* let # lines begin on a new line */
586  GWEN_Buffer_AppendByte(dbuf, '\n');
587  GWEN_Buffer_AppendByte(dbuf, *p);
588 
589  /* skip introducing cross and copy all stuff until the next cross
590  * upon which wa inject a newline (to make the preprocessor happy)
591  */
592  p++;
593  while (*p && *p!='#') {
594  GWEN_Buffer_AppendByte(dbuf, *p);
595  p++;
596  }
597  if (*p=='#') {
598  GWEN_Buffer_AppendByte(dbuf, '\n');
599  p++;
600  }
601  }
602  else if (*p=='\\') {
603  /* check for recognized control escapes */
604  if (tolower(p[1])=='n') {
605  GWEN_Buffer_AppendByte(dbuf, '\n');
606  p+=2; /* skip introducing backslash and control character */
607  }
608  else if (tolower(p[1])=='t') {
609  GWEN_Buffer_AppendByte(dbuf, '\t');
610  p+=2; /* skip introducing backslash and control character */
611  }
612  else if (tolower(p[1])=='\\') {
613  GWEN_Buffer_AppendByte(dbuf, '\\');
614  p+=2; /* skip introducing backslash and control character */
615  }
616  else {
617  /* no known escape character, just add literally */
618  GWEN_Buffer_AppendByte(dbuf, *p);
619  p++;
620  }
621  }
622  else {
623  GWEN_Buffer_AppendByte(dbuf, *p);
624  p++;
625  }
626  }
627  }
628 
629  return 0;
630 }
631 
632 
633 
634 #define INVOKE_FN(macro_var1) \
635  int Typemaker2_Builder_Invoke_##macro_var1##Fn(TYPEMAKER2_BUILDER *tb, \
636  TYPEMAKER2_TYPE *ty, \
637  TYPEMAKER2_MEMBER *tm, \
638  const char *src, \
639  const char *dst, \
640  GWEN_BUFFER *dbuf) { \
641  if (tm) { \
642  TYPEMAKER2_TYPE *mty; \
643  TYPEMAKER2_CODE *tc; \
644  const char *s=NULL; \
645  \
646  mty=Typemaker2_Member_GetTypePtr(tm); \
647  if (mty==NULL) { \
648  DBG_ERROR(GWEN_LOGDOMAIN, "No type pointer for member"); \
649  return GWEN_ERROR_NO_DATA; \
650  } \
651  tc=Typemaker2_Type_FindCodeForMember(mty, tm, __STRING(macro_var1));\
652  if (tc) \
653  s=Typemaker2_Code_GetCode(tc); \
654  if (s && *s) { \
655  GWEN_DB_NODE *db; \
656  int rv; \
657  \
658  db=Typemaker2_Builder_CreateDbForCall(tb, ty, tm, src, dst); \
659  if (db==NULL) { \
660  DBG_INFO(GWEN_LOGDOMAIN, "here"); \
661  return GWEN_ERROR_BAD_DATA; \
662  } \
663  \
664  if (0) { \
665  GWEN_Buffer_AppendString(dbuf, "/* function \""); \
666  GWEN_Buffer_AppendString(dbuf, __STRING(macro_var1)); \
667  GWEN_Buffer_AppendString(dbuf, "\" of type \""); \
668  GWEN_Buffer_AppendString(dbuf, Typemaker2_Type_GetName(mty)); \
669  GWEN_Buffer_AppendString(dbuf, "\" */\n"); \
670  } \
671  rv=Typemaker2_Builder_ReplaceVars(s, db, dbuf); \
672  GWEN_DB_Group_free(db); \
673  if (rv<0) { \
674  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv); \
675  return rv; \
676  } \
677  return 0; \
678  } \
679  else { \
680  DBG_INFO(GWEN_LOGDOMAIN, "No code for type [%s]", \
681  Typemaker2_Type_GetName(mty)); \
682  return 0; \
683  } \
684  } \
685  else { \
686  DBG_ERROR(GWEN_LOGDOMAIN, "No member information"); \
687  return GWEN_ERROR_NO_DATA; \
688  } \
689  }
690 
691 
692 INVOKE_FN(Construct);
693 INVOKE_FN(Destruct);
694 INVOKE_FN(Assign);
695 INVOKE_FN(Dup);
696 INVOKE_FN(Compare);
697 INVOKE_FN(ToDb);
698 INVOKE_FN(FromDb);
699 INVOKE_FN(ToXml);
700 INVOKE_FN(FromXml);
701 INVOKE_FN(ToObject);
702 INVOKE_FN(FromObject);
703 INVOKE_FN(ToHashString);
704 
705 
706 
707 
709  TYPEMAKER2_TYPE *ty,
710  const char *fileName,
711  GWEN_STRINGLIST *sl,
712  int acc)
713 {
715  FILE *f;
716 
717  f=fopen(fileName, "w");
718  if (f==NULL) {
719  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
720  fileName,
721  strerror(errno),
722  errno);
723  return GWEN_ERROR_IO;
724  }
725 
726  fprintf(f,
727  "/**********************************************************\n"
728  " * This file has been automatically created by \"typemaker2\"\n"
729  " * from the file \"%s\".\n"
730  " * Please do not edit this file, all changes will be lost.\n"
731  " * Better edit the mentioned source file instead.\n"
732  " **********************************************************/\n"
733  "\n",
735 
736  if (acc==TypeMaker2_Access_Unknown) {
737  const char *s;
738  TYPEMAKER2_HEADER_LIST *hl;
739 
740  fprintf(f, "#ifdef HAVE_CONFIG_H\n# include <config.h>\n#endif\n\n");
741 
742  s=tb->fileNamePrivate;
743  if (s==NULL)
744  s=tb->fileNameLibrary;
745  if (s==NULL)
746  s=tb->fileNameProtected;
747  if (s==NULL)
748  s=tb->fileNamePublic;
749  if (s) {
750  fprintf(f, "#include \"%s\"\n\n", s);
751  }
752 
753  /* add some needed headers */
754  fprintf(f, "#include <gwenhywfar/misc.h>\n");
755  fprintf(f, "#include <gwenhywfar/debug.h>\n");
756 
757  /* write code headers */
758  fprintf(f, "\n");
759  fprintf(f, "/* code headers */\n");
761  if (hl) {
763 
764  h=Typemaker2_Header_List_First(hl);
765  while (h) {
768  fprintf(f, "#include <%s>\n", Typemaker2_Header_GetFileName(h));
769  else
770  fprintf(f, "#include \"%s\"\n", Typemaker2_Header_GetFileName(h));
771  }
772  h=Typemaker2_Header_List_Next(h);
773  }
774  }
775  fprintf(f, "\n");
776  }
777  else {
778  GWEN_BUFFER *xbuf;
779  char *p;
780  const char *s;
781 
782  xbuf=GWEN_Buffer_new(0, 256, 0, 1);
784  GWEN_Buffer_AppendString(xbuf, s);
785  GWEN_Buffer_AppendString(xbuf, "_");
786  s=strrchr(fileName, GWEN_DIR_SEPARATOR);
787  if (s && *s)
788  GWEN_Buffer_AppendString(xbuf, s+1);
789  else
790  GWEN_Buffer_AppendString(xbuf, fileName);
791  p=GWEN_Buffer_GetStart(xbuf);
792  while (*p) {
793  if (!isalnum(*p))
794  *p='_';
795  else
796  *p=toupper(*p);
797  p++;
798  }
799  fprintf(f, "#ifndef %s\n", GWEN_Buffer_GetStart(xbuf));
800  fprintf(f, "#define %s\n\n", GWEN_Buffer_GetStart(xbuf));
801 
802  s=NULL;
803  switch (acc) {
805  s=tb->fileNamePrivate;
806  if (s)
807  break;
809  s=tb->fileNameLibrary;
810  if (s)
811  break;
813  s=tb->fileNameProtected;
814  if (s)
815  break;
817  s=tb->fileNamePublic;
818  if (s)
819  break;
820  default:
821  break;
822  }
823 
824  if (s) {
825  fprintf(f, "#include \"%s\"\n\n", s);
826  }
827 
828  fprintf(f, "\n");
829  fprintf(f, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n");
830  GWEN_Buffer_free(xbuf);
831  }
832 
834  while (se) {
835  const char *s;
836 
838  if (s)
839  fprintf(f, "%s\n", s);
840 
842  }
843 
844  if (acc==TypeMaker2_Access_Unknown) {
845  TYPEMAKER2_HEADER_LIST *hl;
846 
847  /* write codeEnd headers */
848  fprintf(f, "\n");
849  fprintf(f, "/* code headers */\n");
851  if (hl) {
853 
854  h=Typemaker2_Header_List_First(hl);
855  while (h) {
858  fprintf(f, "#include <%s>\n", Typemaker2_Header_GetFileName(h));
859  else
860  fprintf(f, "#include \"%s\"\n", Typemaker2_Header_GetFileName(h));
861  }
862  h=Typemaker2_Header_List_Next(h);
863  }
864  }
865  fprintf(f, "\n");
866  }
867 
868  if (acc!=TypeMaker2_Access_Unknown) {
869  fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n");
870  fprintf(f, "#endif\n\n");
871  }
872 
873  if (fclose(f)) {
874  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
875  fileName,
876  strerror(errno),
877  errno);
878  return GWEN_ERROR_IO;
879  }
880 
881  return 0;
882 }
883 
884 
885 
887  TYPEMAKER2_TYPE *ty,
888  const char *fileName)
889 {
890  FILE *f;
891 
892  f=fopen(fileName, "w");
893  if (f==NULL) {
894  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
895  fileName,
896  strerror(errno),
897  errno);
898  return GWEN_ERROR_IO;
899  }
900 
901  fprintf(f, "<?xml?>\n");
902  fprintf(f, "\n");
903  fprintf(f, "<tm2>\n");
904 
905  fprintf(f, " <typedef id=\"%s\" type=\"pointer\" lang=\"c\" extends=\"struct_base\">\n",
907 
908  fprintf(f, " <identifier>%s</identifier>\n", Typemaker2_Type_GetName(ty));
909  fprintf(f, " <prefix>%s</prefix>\n", Typemaker2_Type_GetPrefix(ty));
910 
911  fprintf(f, " </typedef>\n");
912  fprintf(f, "</tm2>\n");
913 
914  if (fclose(f)) {
915  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
916  fileName,
917  strerror(errno),
918  errno);
919  return GWEN_ERROR_IO;
920  }
921 
922  return 0;
923 }
924 
925 
926 
928  TYPEMAKER2_TYPE *ty,
929  const char *fileName)
930 {
931  FILE *f;
932 
933  f=fopen(fileName, "w");
934  if (f==NULL) {
935  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
936  fileName,
937  strerror(errno),
938  errno);
939  return GWEN_ERROR_IO;
940  }
941 
942  fprintf(f, "<?xml?>\n");
943  fprintf(f, "\n");
944  fprintf(f, "<tm2>\n");
945 
946  fprintf(f, " <typedef id=\"%s_LIST\" type=\"pointer\" lang=\"c\" extends=\"list1_base\" "
947  "basetype=\"%s\">\n",
950 
951  fprintf(f, " <identifier>%s_LIST</identifier>\n", Typemaker2_Type_GetName(ty));
952  fprintf(f, " <prefix>%s_List</prefix>\n", Typemaker2_Type_GetPrefix(ty));
953 
954  fprintf(f, " </typedef>\n");
955  fprintf(f, "</tm2>\n");
956 
957  if (fclose(f)) {
958  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
959  fileName,
960  strerror(errno),
961  errno);
962  return GWEN_ERROR_IO;
963  }
964 
965  return 0;
966 }
967 
968 
969 
971  TYPEMAKER2_TYPE *ty,
972  const char *fileName)
973 {
974  FILE *f;
975 
976  f=fopen(fileName, "w");
977  if (f==NULL) {
978  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
979  fileName,
980  strerror(errno),
981  errno);
982  return GWEN_ERROR_IO;
983  }
984 
985  fprintf(f, "<?xml?>\n");
986  fprintf(f, "\n");
987  fprintf(f, "<tm2>\n");
988 
989  fprintf(f, " <typedef id=\"%s_LIST2\" type=\"pointer\" lang=\"c\" extends=\"list2_base\" "
990  "basetype=\"%s\">\n",
993 
994  fprintf(f, " <identifier>%s_LIST2</identifier>\n", Typemaker2_Type_GetName(ty));
995  fprintf(f, " <prefix>%s_List2</prefix>\n", Typemaker2_Type_GetPrefix(ty));
996 
997  fprintf(f, " </typedef>\n");
998  fprintf(f, "</tm2>\n");
999 
1000  if (fclose(f)) {
1001  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
1002  fileName,
1003  strerror(errno),
1004  errno);
1005  return GWEN_ERROR_IO;
1006  }
1007 
1008  return 0;
1009 }
1010 
1011 
1012 
1014  TYPEMAKER2_TYPE *ty,
1015  const char *fileName)
1016 {
1017  FILE *f;
1018 
1019  f=fopen(fileName, "w");
1020  if (f==NULL) {
1021  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
1022  fileName,
1023  strerror(errno),
1024  errno);
1025  return GWEN_ERROR_IO;
1026  }
1027 
1028  fprintf(f, "<?xml?>\n");
1029  fprintf(f, "\n");
1030  fprintf(f, "<tm2>\n");
1031 
1032  fprintf(f, " <typedef id=\"%s_TREE\" type=\"pointer\" lang=\"c\" extends=\"tree_base\" "
1033  "basetype=\"%s\">\n",
1036 
1037  fprintf(f, " <identifier>%s_TREE</identifier>\n", Typemaker2_Type_GetName(ty));
1038  fprintf(f, " <prefix>%s_Tree</prefix>\n", Typemaker2_Type_GetPrefix(ty));
1039 
1040  fprintf(f, " </typedef>\n");
1041  fprintf(f, "</tm2>\n");
1042 
1043  if (fclose(f)) {
1044  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
1045  fileName,
1046  strerror(errno),
1047  errno);
1048  return GWEN_ERROR_IO;
1049  }
1050 
1051  return 0;
1052 }
1053 
1054 
1055 
1057  TYPEMAKER2_TYPE *ty,
1058  const char *fileName)
1059 {
1060  FILE *f;
1061 
1062  f=fopen(fileName, "w");
1063  if (f==NULL) {
1064  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
1065  fileName,
1066  strerror(errno),
1067  errno);
1068  return GWEN_ERROR_IO;
1069  }
1070 
1071  fprintf(f, "<?xml?>\n");
1072  fprintf(f, "\n");
1073  fprintf(f, "<tm2>\n");
1074 
1075  fprintf(f, " <typedef id=\"%s_TREE2\" type=\"pointer\" lang=\"c\" extends=\"tree_base\" "
1076  "basetype=\"%s\">\n",
1079 
1080  fprintf(f, " <identifier>%s_TREE2</identifier>\n", Typemaker2_Type_GetName(ty));
1081  fprintf(f, " <prefix>%s_Tree2</prefix>\n", Typemaker2_Type_GetPrefix(ty));
1082 
1083  fprintf(f, " </typedef>\n");
1084  fprintf(f, "</tm2>\n");
1085 
1086  if (fclose(f)) {
1087  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
1088  fileName,
1089  strerror(errno),
1090  errno);
1091  return GWEN_ERROR_IO;
1092  }
1093 
1094  return 0;
1095 }
1096 
1097 
1098 
1100  TYPEMAKER2_TYPE *ty,
1101  const char *fileName)
1102 {
1103  FILE *f;
1104 
1105  f=fopen(fileName, "w");
1106  if (f==NULL) {
1107  DBG_ERROR(GWEN_LOGDOMAIN, "fopen(%s): %s (%d)",
1108  fileName,
1109  strerror(errno),
1110  errno);
1111  return GWEN_ERROR_IO;
1112  }
1113 
1114  fprintf(f, "<?xml?>\n");
1115  fprintf(f, "\n");
1116  fprintf(f, "<tm2>\n");
1117 
1118  fprintf(f, " <typedef id=\"%s_IDMAP\" type=\"pointer\" lang=\"c\" extends=\"idmap_base\" "
1119  "basetype=\"%s\">\n",
1122 
1123  fprintf(f, " <identifier>%s_IDMAP</identifier>\n", Typemaker2_Type_GetName(ty));
1124  fprintf(f, " <prefix>%s_IdMap</prefix>\n", Typemaker2_Type_GetPrefix(ty));
1125 
1126  fprintf(f, " </typedef>\n");
1127  fprintf(f, "</tm2>\n");
1128 
1129  if (fclose(f)) {
1130  DBG_ERROR(GWEN_LOGDOMAIN, "fclose(%s): %s (%d)",
1131  fileName,
1132  strerror(errno),
1133  errno);
1134  return GWEN_ERROR_IO;
1135  }
1136 
1137  return 0;
1138 }
1139 
1140 
1141 
1142 
1143 
1145 {
1146  const char *fname;
1147 
1148  if (GWEN_StringList_Count(tb->declarationsPublic)) {
1149  fname=tb->fileNamePublic;
1150  if (fname==NULL || *fname==0) {
1151  const char *s;
1152  char *t;
1153  GWEN_BUFFER *tbuf;
1154 
1156  if (s==NULL || *s==0) {
1158  if (s==NULL || *s==0) {
1159  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1160  return GWEN_ERROR_BAD_DATA;
1161  }
1162  }
1163  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1164  if (tb->destFolder) {
1165  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1167  }
1168  GWEN_Buffer_AppendString(tbuf, s);
1169  t=GWEN_Buffer_GetStart(tbuf);
1170  while (*t) {
1171  *t=tolower(*t);
1172  t++;
1173  }
1174  GWEN_Buffer_AppendString(tbuf, ".h");
1175  fname=GWEN_Buffer_GetStart(tbuf);
1177  GWEN_Buffer_free(tbuf);
1178  }
1179  }
1180 
1181  if (GWEN_StringList_Count(tb->declarationsLibrary)) {
1182  fname=tb->fileNameLibrary;
1183  if (fname==NULL || *fname==0) {
1184  const char *s;
1185  char *t;
1186  GWEN_BUFFER *tbuf;
1187 
1189  if (s==NULL || *s==0) {
1191  if (s==NULL || *s==0) {
1192  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1193  return GWEN_ERROR_BAD_DATA;
1194  }
1195  }
1196  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1197  if (tb->destFolder) {
1198  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1200  }
1201  GWEN_Buffer_AppendString(tbuf, s);
1202  t=GWEN_Buffer_GetStart(tbuf);
1203  while (*t) {
1204  *t=tolower(*t);
1205  t++;
1206  }
1207  GWEN_Buffer_AppendString(tbuf, "_l.h");
1208  fname=GWEN_Buffer_GetStart(tbuf);
1210  GWEN_Buffer_free(tbuf);
1211  }
1212  }
1213 
1214  if (GWEN_StringList_Count(tb->declarationsProtected)) {
1215  fname=tb->fileNameProtected;
1216  if (fname==NULL || *fname==0) {
1217  const char *s;
1218  char *t;
1219  GWEN_BUFFER *tbuf;
1220 
1222  if (s==NULL || *s==0) {
1224  if (s==NULL || *s==0) {
1225  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1226  return GWEN_ERROR_BAD_DATA;
1227  }
1228  }
1229  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1230  if (tb->destFolder) {
1231  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1233  }
1234  GWEN_Buffer_AppendString(tbuf, s);
1235  t=GWEN_Buffer_GetStart(tbuf);
1236  while (*t) {
1237  *t=tolower(*t);
1238  t++;
1239  }
1240  GWEN_Buffer_AppendString(tbuf, "_be.h");
1241  fname=GWEN_Buffer_GetStart(tbuf);
1243  GWEN_Buffer_free(tbuf);
1244  }
1245  }
1246 
1247  if (GWEN_StringList_Count(tb->declarationsPrivate)) {
1248  fname=tb->fileNamePrivate;
1249  if (fname==NULL || *fname==0) {
1250  const char *s;
1251  char *t;
1252  GWEN_BUFFER *tbuf;
1253 
1255  if (s==NULL || *s==0) {
1257  if (s==NULL || *s==0) {
1258  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1259  return GWEN_ERROR_BAD_DATA;
1260  }
1261  }
1262  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1263  if (tb->destFolder) {
1264  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1266  }
1267  GWEN_Buffer_AppendString(tbuf, s);
1268  t=GWEN_Buffer_GetStart(tbuf);
1269  while (*t) {
1270  *t=tolower(*t);
1271  t++;
1272  }
1273  GWEN_Buffer_AppendString(tbuf, "_p.h");
1274  fname=GWEN_Buffer_GetStart(tbuf);
1276  GWEN_Buffer_free(tbuf);
1277  }
1278  }
1279 
1280  if (GWEN_StringList_Count(tb->code)) {
1281  fname=tb->fileNameCode;
1282  if (fname==NULL || *fname==0) {
1283  const char *s;
1284  char *t;
1285  GWEN_BUFFER *tbuf;
1286 
1288  if (s==NULL || *s==0) {
1290  if (s==NULL || *s==0) {
1291  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1292  return GWEN_ERROR_BAD_DATA;
1293  }
1294  }
1295  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1296  if (tb->destFolder) {
1297  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1299  }
1300  GWEN_Buffer_AppendString(tbuf, s);
1301  t=GWEN_Buffer_GetStart(tbuf);
1302  while (*t) {
1303  *t=tolower(*t);
1304  t++;
1305  }
1306  GWEN_Buffer_AppendString(tbuf, ".c");
1307  fname=GWEN_Buffer_GetStart(tbuf);
1309  GWEN_Buffer_free(tbuf);
1310  }
1311  }
1312 
1313  return 0;
1314 }
1315 
1316 
1317 
1319 {
1320  const char *fname;
1321  int rv;
1322 
1324  if (rv<0) {
1325  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1326  return rv;
1327  }
1328 
1330  if (GWEN_StringList_Count(tb->declarationsPublic)) {
1331  fname=tb->fileNamePublic;
1332  assert(fname);
1333 
1334  rv=Typemaker2_Builder_WriteFile(tb, ty, fname, tb->declarationsPublic,
1336  if (rv<0) {
1337  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1338  return rv;
1339  }
1340  }
1341 
1342  if (GWEN_StringList_Count(tb->declarationsLibrary)) {
1343  fname=tb->fileNameLibrary;
1344  assert(fname);
1345 
1346  rv=Typemaker2_Builder_WriteFile(tb, ty, fname, tb->declarationsLibrary,
1348  if (rv<0) {
1349  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1350  return rv;
1351  }
1352  }
1353 
1354  if (GWEN_StringList_Count(tb->declarationsProtected)) {
1355  fname=tb->fileNameProtected;
1356  assert(fname);
1357 
1358  rv=Typemaker2_Builder_WriteFile(tb, ty, fname, tb->declarationsProtected,
1360  if (rv<0) {
1361  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1362  return rv;
1363  }
1364  }
1365 
1366  if (GWEN_StringList_Count(tb->declarationsPrivate)) {
1367  fname=tb->fileNamePrivate;
1368  assert(fname);
1369 
1370  rv=Typemaker2_Builder_WriteFile(tb, ty, fname, tb->declarationsPrivate,
1372  if (rv<0) {
1373  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1374  return rv;
1375  }
1376  }
1377 
1378  if (GWEN_StringList_Count(tb->code)) {
1379  fname=tb->fileNameCode;
1380  assert(fname);
1381 
1382  rv=Typemaker2_Builder_WriteFile(tb, ty, fname, tb->code,
1384  if (rv<0) {
1385  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1386  return rv;
1387  }
1388  }
1389  }
1390 
1391  /* write typedef file */
1393  if (1) {
1394  const char *s;
1395  char *t;
1396  GWEN_BUFFER *tbuf;
1397 
1399  if (s==NULL || *s==0) {
1400  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1401  return GWEN_ERROR_BAD_DATA;
1402  }
1403  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1404  if (tb->destFolder) {
1405  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1407  }
1408  GWEN_Buffer_AppendString(tbuf, s);
1409  t=GWEN_Buffer_GetStart(tbuf);
1410  while (*t) {
1411  *t=tolower(*t);
1412  t++;
1413  }
1414  GWEN_Buffer_AppendString(tbuf, ".tm2");
1415  fname=GWEN_Buffer_GetStart(tbuf);
1416  rv=Typemaker2_Builder_WriteTypedefFile(tb, ty, fname);
1417  GWEN_Buffer_free(tbuf);
1418  if (rv<0) {
1419  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1420  return rv;
1421  }
1422  }
1423 
1424  /* write typedef file for list1 */
1426  const char *s;
1427  char *t;
1428  GWEN_BUFFER *tbuf;
1429 
1431  if (s==NULL || *s==0) {
1432  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1433  return GWEN_ERROR_BAD_DATA;
1434  }
1435  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1436  if (tb->destFolder) {
1437  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1439  }
1440  GWEN_Buffer_AppendString(tbuf, s);
1441  t=GWEN_Buffer_GetStart(tbuf);
1442  while (*t) {
1443  *t=tolower(*t);
1444  t++;
1445  }
1446  GWEN_Buffer_AppendString(tbuf, "_list.tm2");
1447  fname=GWEN_Buffer_GetStart(tbuf);
1449  GWEN_Buffer_free(tbuf);
1450  if (rv<0) {
1451  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1452  return rv;
1453  }
1454  }
1455 
1456  /* write typedef file for list2 */
1458  const char *s;
1459  char *t;
1460  GWEN_BUFFER *tbuf;
1461 
1463  if (s==NULL || *s==0) {
1464  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1465  return GWEN_ERROR_BAD_DATA;
1466  }
1467  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1468  if (tb->destFolder) {
1469  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1471  }
1472  GWEN_Buffer_AppendString(tbuf, s);
1473  t=GWEN_Buffer_GetStart(tbuf);
1474  while (*t) {
1475  *t=tolower(*t);
1476  t++;
1477  }
1478  GWEN_Buffer_AppendString(tbuf, "_list2.tm2");
1479  fname=GWEN_Buffer_GetStart(tbuf);
1481  GWEN_Buffer_free(tbuf);
1482  if (rv<0) {
1483  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1484  return rv;
1485  }
1486  }
1487 
1488  /* write typedef file for tree */
1490  const char *s;
1491  char *t;
1492  GWEN_BUFFER *tbuf;
1493 
1495  if (s==NULL || *s==0) {
1496  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1497  return GWEN_ERROR_BAD_DATA;
1498  }
1499  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1500  if (tb->destFolder) {
1501  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1503  }
1504  GWEN_Buffer_AppendString(tbuf, s);
1505  t=GWEN_Buffer_GetStart(tbuf);
1506  while (*t) {
1507  *t=tolower(*t);
1508  t++;
1509  }
1510  GWEN_Buffer_AppendString(tbuf, "_tree.tm2");
1511  fname=GWEN_Buffer_GetStart(tbuf);
1512  rv=Typemaker2_Builder_WriteTypedefFile_Tree(tb, ty, fname);
1513  GWEN_Buffer_free(tbuf);
1514  if (rv<0) {
1515  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1516  return rv;
1517  }
1518  }
1519 
1520  /* write typedef file for tree2 */
1522  const char *s;
1523  char *t;
1524  GWEN_BUFFER *tbuf;
1525 
1527  if (s==NULL || *s==0) {
1528  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1529  return GWEN_ERROR_BAD_DATA;
1530  }
1531  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1532  if (tb->destFolder) {
1533  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1535  }
1536  GWEN_Buffer_AppendString(tbuf, s);
1537  t=GWEN_Buffer_GetStart(tbuf);
1538  while (*t) {
1539  *t=tolower(*t);
1540  t++;
1541  }
1542  GWEN_Buffer_AppendString(tbuf, "_tree2.tm2");
1543  fname=GWEN_Buffer_GetStart(tbuf);
1545  GWEN_Buffer_free(tbuf);
1546  if (rv<0) {
1547  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1548  return rv;
1549  }
1550  }
1551 
1552  /* write typedef file for idmap */
1554  const char *s;
1555  char *t;
1556  GWEN_BUFFER *tbuf;
1557 
1559  if (s==NULL || *s==0) {
1560  DBG_ERROR(GWEN_LOGDOMAIN, "Type has no name");
1561  return GWEN_ERROR_BAD_DATA;
1562  }
1563  tbuf=GWEN_Buffer_new(0, 256, 0, 1);
1564  if (tb->destFolder) {
1565  GWEN_Buffer_AppendString(tbuf, tb->destFolder);
1567  }
1568  GWEN_Buffer_AppendString(tbuf, s);
1569  t=GWEN_Buffer_GetStart(tbuf);
1570  while (*t) {
1571  *t=tolower(*t);
1572  t++;
1573  }
1574  GWEN_Buffer_AppendString(tbuf, "_idmap.tm2");
1575  fname=GWEN_Buffer_GetStart(tbuf);
1577  GWEN_Buffer_free(tbuf);
1578  if (rv<0) {
1579  DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", rv);
1580  return rv;
1581  }
1582  }
1583  }
1584 
1585  return 0;
1586 }
1587 
1588 
1589 
1590 
1591 
int Typemaker2_Header_GetType(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:90
#define TYPEMAKER2_TYPEFLAGS_WITH_TREE2
Definition: tm_type.h:71
TYPEMAKER2_TYPEMANAGER * Typemaker2_Builder_GetTypeManager(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:133
#define INVOKE_FN(macro_var1)
Definition: tm_builder.c:634
void Typemaker2_Builder_SetFileNameProtected(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:237
void Typemaker2_Builder_SetSourceFileName(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:297
void Typemaker2_Builder_SetBuildFn(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_BUILDER_BUILD_FN fn)
Definition: tm_builder.c:329
TYPEMAKER2_TYPE * Typemaker2_Member_GetTypePtr(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:467
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
Definition: buffer.c:235
struct GWEN_STRINGLISTENTRYSTRUCT GWEN_STRINGLISTENTRY
Definition: stringlist.h:51
uint32_t Typemaker2_Member_GetFlags(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:237
const char * Typemaker2_Enum_GetFromStringFn(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:210
#define GWEN_DB_FLAGS_OVERWRITE_VARS
Definition: db.h:121
void Typemaker2_Builder_SetFileNameCode(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:277
const char * Typemaker2_Header_GetFileName(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:68
struct GWEN_DB_NODE GWEN_DB_NODE
Definition: db.h:228
#define GWEN_INHERIT_FINI(t, element)
Definition: inherit.h:238
GWEN_STRINGLIST * Typemaker2_Builder_GetProtectedDeclarations(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:109
int Typemaker2_Builder_WriteTypedefFile_IdMap(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:1099
#define GWEN_DIR_SEPARATOR_S
const char * Typemaker2_Builder_GetFileNamePrivate(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:249
TYPEMAKER2_HEADER_LIST * Typemaker2_Type_GetHeaders(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:650
const char * Typemaker2_Member_GetFieldId(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:171
int(* TYPEMAKER2_BUILDER_BUILD_FN)(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty)
Definition: tm_builder.h:35
TYPEMAKER2_ENUM * Typemaker2_Member_GetEnumPtr(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:485
void Typemaker2_Builder_SetFileNameLibrary(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:217
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define NULL
Definition: binreloc.c:300
int Typemaker2_Header_GetLocation(const TYPEMAKER2_HEADER *th)
Definition: tm_header.c:108
void Typemaker2_Builder_free(TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:71
int Typemaker2_Builder_DetermineOutFileNames(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty)
Definition: tm_builder.c:1144
TYPEMAKER2_TYPE * Typemaker2_Type_GetBaseTypePtr(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:623
#define TYPEMAKER2_BUILDER_WRITEFILE_FLAGS_WRITE_TYPE
Definition: tm_builder.h:23
#define GWEN_LOGDOMAIN
Definition: logger.h:35
int Typemaker2_Builder_WriteTypedefFile_List1(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:927
void Typemaker2_Builder_SetTypeManager(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPEMANAGER *tm)
Definition: tm_builder.c:141
int Typemaker2_Builder_WriteTypedefFile(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:886
struct TYPEMAKER2_HEADER TYPEMAKER2_HEADER
Definition: tm_header.h:19
struct TYPEMAKER2_ENUM TYPEMAKER2_ENUM
Definition: tm_enum.h:24
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
Definition: buffer.c:42
int Typemaker2_Member_GetMaxLen(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:369
GWEN_STRINGLISTENTRY * GWEN_StringList_FirstEntry(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:386
#define GWEN_ERROR_IO
Definition: error.h:123
const char * GWEN_StringListEntry_Data(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:402
void Typemaker2_Builder_SetDestFolderName(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:317
void Typemaker2_Builder_AddPrivateDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:173
void Typemaker2_Builder_SetFileNamePrivate(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:257
int Typemaker2_Builder_ReplaceVars(const char *s, GWEN_DB_NODE *db, GWEN_BUFFER *dbuf)
Definition: tm_builder.c:525
static void addMemberInfoToCallDb(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, GWEN_DB_NODE *db, int withTypePrefix)
const char * Typemaker2_Member_GetPresetValue(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:414
#define GWEN_ERROR_BAD_DATA
Definition: error.h:121
void GWEN_StringList_free(GWEN_STRINGLIST *sl)
Definition: stringlist.c:58
const char * Typemaker2_Builder_GetFileNameLibrary(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:209
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
int Typemaker2_Builder_Build(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty)
Definition: tm_builder.c:337
const char * Typemaker2_Builder_GetFileNamePublic(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:189
const char * Typemaker2_Builder_GetSourceFileName(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:289
int GWEN_StringList_AppendString(GWEN_STRINGLIST *sl, const char *s, int take, int checkDouble)
Definition: stringlist.c:241
GWEN_STRINGLIST * Typemaker2_Builder_GetPrivateDeclarations(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:117
const char * Typemaker2_Type_GetIdentifier(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:543
void Typemaker2_Builder_AddProtectedDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:165
struct GWEN_STRINGLISTSTRUCT GWEN_STRINGLIST
Definition: stringlist.h:54
#define TYPEMAKER2_TYPEFLAGS_WITH_TREE
Definition: tm_type.h:60
const char * Typemaker2_Builder_GetFileNameProtected(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:229
int GWEN_Buffer_AppendByte(GWEN_BUFFER *bf, char c)
Definition: buffer.c:394
const char * GWEN_DB_GetCharValue(GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
Definition: db.c:969
int Typemaker2_Builder_WriteTypedefFile_Tree(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:1013
#define GWEN_INHERIT_INIT(t, element)
Definition: inherit.h:223
struct TYPEMAKER2_BUILDER TYPEMAKER2_BUILDER
Definition: tm_builder.h:26
#define TYPEMAKER2_FLAGS_ENUM
Definition: tm_type.h:38
TYPEMAKER2_MEMBER_LIST * Typemaker2_Type_GetMembers(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:641
void GWEN_Buffer_free(GWEN_BUFFER *bf)
Definition: buffer.c:89
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
Definition: buffer.h:38
const char * Typemaker2_Type_GetName(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:127
int Typemaker2_Builder_WriteFile(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName, GWEN_STRINGLIST *sl, int acc)
Definition: tm_builder.c:708
const char * Typemaker2_Member_GetDefaultValue(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:388
void Typemaker2_Builder_AddCode(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:181
const char * Typemaker2_Builder_GetFileNameCode(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:269
unsigned int GWEN_StringList_Count(const GWEN_STRINGLIST *sl)
Definition: stringlist.c:423
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
struct TYPEMAKER2_TYPE TYPEMAKER2_TYPE
Definition: tm_type.h:21
void Typemaker2_Builder_AddPublicDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:149
int Typemaker2_Builder_WriteTypedefFile_List2(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:970
#define TYPEMAKER2_TYPEFLAGS_WITH_IDMAP
Definition: tm_type.h:59
void Typemaker2_Builder_SetFileNamePublic(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:197
#define GWEN_ERROR_NOT_SUPPORTED
Definition: error.h:109
int GWEN_DB_SetCharValue(GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
Definition: db.c:995
#define GWEN_DIR_SEPARATOR
GWEN_STRINGLISTENTRY * GWEN_StringListEntry_Next(const GWEN_STRINGLISTENTRY *se)
Definition: stringlist.c:394
struct TYPEMAKER2_TYPEMANAGER TYPEMAKER2_TYPEMANAGER
GWEN_STRINGLIST * Typemaker2_Builder_GetCode(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:125
static void setCharValueWithTypePrefix(GWEN_DB_NODE *db, const char *prefix, const char *varName, const char *value)
Definition: tm_builder.c:504
#define DBG_INFO(dbg_logger, format, args...)
Definition: debug.h:178
void Typemaker2_Builder_AddLibraryDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
Definition: tm_builder.c:157
const char * Typemaker2_Builder_GetDestFolderName(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:309
const char * Typemaker2_Type_GetPrefix(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:565
TYPEMAKER2_BUILDER * Typemaker2_Builder_new()
Definition: tm_builder.c:53
const char * Typemaker2_TypeManager_GetApiDeclaration(const TYPEMAKER2_TYPEMANAGER *tym)
GWEN_DB_NODE * GWEN_DB_Group_new(const char *name)
Definition: db.c:171
GWEN_STRINGLIST * Typemaker2_Builder_GetPublicDeclarations(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:93
GWEN_STRINGLIST * Typemaker2_Builder_GetLibraryDeclarations(const TYPEMAKER2_BUILDER *tb)
Definition: tm_builder.c:101
struct TYPEMAKER2_MEMBER TYPEMAKER2_MEMBER
Definition: tm_member.h:21
const char * Typemaker2_Enum_GetToStringFn(const TYPEMAKER2_ENUM *p_struct)
Definition: tm_enum.c:204
int Typemaker2_Builder_WriteTypedefFile_Tree2(GWEN_UNUSED TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, const char *fileName)
Definition: tm_builder.c:1056
const char * Typemaker2_Member_GetElementName(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:127
GWEN_STRINGLIST * GWEN_StringList_new(void)
Definition: stringlist.c:46
uint32_t Typemaker2_Type_GetFlags(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:341
#define TYPEMAKER2_TYPEFLAGS_WITH_LIST2
Definition: tm_type.h:57
const char * Typemaker2_Member_GetName(const TYPEMAKER2_MEMBER *tm)
Definition: tm_member.c:83
#define TYPEMAKER2_BUILDER_WRITEFILE_FLAGS_WRITE_DEFS
Definition: tm_builder.h:22
#define GWEN_INHERIT_FUNCTIONS(t)
Definition: inherit.h:163
#define TYPEMAKER2_FLAGS_VOLATILE
Definition: tm_type.h:32
int Typemaker2_Builder_WriteFiles(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, uint32_t writeFlags)
Definition: tm_builder.c:1318
#define GWEN_UNUSED
int GWEN_Buffer_AppendString(GWEN_BUFFER *bf, const char *buffer)
Definition: buffer.c:989
const char * Typemaker2_Type_GetBaseFileName(const TYPEMAKER2_TYPE *ty)
Definition: tm_type.c:221
GWEN_DB_NODE * Typemaker2_Builder_CreateDbForCall(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, const char *src, const char *dst)
Definition: tm_builder.c:348
#define TYPEMAKER2_TYPEFLAGS_WITH_LIST1
Definition: tm_type.h:56