18 #include <gwenhywfar/debug.h> 23 #define GBAA GWEN_Buffer_AppendArgs 24 #define GBAS GWEN_Buffer_AppendString 112 const char *sTypePrefix;
113 const char *sMemberName;
127 GBAA(tbuf,
" %s *p_struct;\n\n", sTypeId);
128 GBAS(tbuf,
" assert(p_object);\n");
129 GBAA(tbuf,
" p_struct = %s_Tree2_GetFirstChild(p_object);\n", sTypePrefix);
130 GBAS(tbuf,
" while(p_struct) {\n");
131 GBAS(tbuf,
" int p_rv;\n");
141 GBAS(srcbuf,
"p_cmp");
144 GBAA(dstbuf,
"p_struct->%s", sMemberName);
161 GBAS(tbuf,
" if (p_rv == 0)\n");
162 GBAS(tbuf,
" return p_struct;\n");
163 GBAA(tbuf,
" p_struct = %s_Tree2_GetBelow(p_struct);\n", sTypePrefix);
166 GBAS(tbuf,
" return NULL;\n");
181 const char *sTypePrefix;
182 const char *sMemberName;
183 const char *sMemberTypeId;
194 "%s *%s_Tree2_GetBy%c%s(const %s *p_object, ",
197 toupper(*sMemberName),
202 GBAA(tbuf,
" const %s *", sMemberTypeId);
204 GBAA(tbuf,
"%s ", sMemberTypeId);
205 GBAS(tbuf,
"p_cmp)");
232 GBAA(tbuf,
"%s ", s);
246 const char *sTypePrefix;
247 const char *sMemberName;
260 GBAA(tbuf,
" %s_Tree2_SortChildren(p_tree2, (GWEN_TREE2_COMPARE_CB)(p_ascending?%s_Tree2_Compare_%c%s_asc:%s_Tree2_Compare_%c%s_desc));\n",
262 sTypePrefix, toupper(*sMemberName), sMemberName+1,
263 sTypePrefix, toupper(*sMemberName), sMemberName+1);
276 const char *sTypePrefix;
277 const char *sMemberName;
287 "void %s_Tree2_SortChildrenBy%c%s(%s *p_tree2, int p_ascending)",
289 toupper(*sMemberName),
302 GBAS(tbuf,
"static ");
316 const char *sMemberName;
327 GBAS(tbuf,
" int p_rv;\n");
336 GBAA(srcbuf,
"p_a->%s", sMemberName);
339 GBAA(dstbuf,
"p_b->%s", sMemberName);
356 GBAS(tbuf,
" return p_rv;\n");
358 GBAS(tbuf,
" return -p_rv;\n");
373 const char *sTypePrefix;
374 const char *sMemberName;
384 "int GWENHYWFAR_CB %s_Tree2_Compare_%c%s_%s(const %s *p_a, const %s *p_b)",
386 toupper(*sMemberName),
388 ascending?
"asc":
"desc",
int Typemaker2_Builder_Invoke_CompareFn(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, const char *src, const char *dst, GWEN_BUFFER *dbuf)
TYPEMAKER2_TYPEMANAGER * Typemaker2_Builder_GetTypeManager(const TYPEMAKER2_BUILDER *tb)
TYPEMAKER2_TYPE * Typemaker2_Member_GetTypePtr(const TYPEMAKER2_MEMBER *tm)
char * GWEN_Buffer_GetStart(const GWEN_BUFFER *bf)
static void _addGetByMemberDeclaration(TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, GWEN_BUFFER *tbuf)
static int _addCompareMemberImplementation(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, int ascending)
static void _addCompareMemberDeclaration(TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, GWEN_BUFFER *tbuf, int ascending)
static void _addCompareMemberProtoType(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, int ascending)
int TM2C_BuildTree2SortByMember(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
GWEN_BUFFER * GWEN_Buffer_new(char *buffer, uint32_t size, uint32_t used, int take)
static void _addSortByMemberDeclaration(TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm, GWEN_BUFFER *tbuf)
void Typemaker2_Builder_AddPrivateDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
static void _addSortByMemberImplementation(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
const char * Typemaker2_Type_GetIdentifier(const TYPEMAKER2_TYPE *ty)
struct TYPEMAKER2_BUILDER TYPEMAKER2_BUILDER
void GWEN_Buffer_free(GWEN_BUFFER *bf)
struct GWEN_BUFFER GWEN_BUFFER
A dynamically resizeable text buffer.
int TM2C_BuildTree2GetByMember(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
void Typemaker2_Builder_AddCode(TYPEMAKER2_BUILDER *tb, const char *s)
struct TYPEMAKER2_TYPE TYPEMAKER2_TYPE
void Typemaker2_Builder_AddPublicDeclaration(TYPEMAKER2_BUILDER *tb, const char *s)
struct TYPEMAKER2_TYPEMANAGER TYPEMAKER2_TYPEMANAGER
const char * Typemaker2_Type_GetPrefix(const TYPEMAKER2_TYPE *ty)
int Typemaker2_Type_GetType(const TYPEMAKER2_TYPE *ty)
static void _addGetByMemberProtoType(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
const char * Typemaker2_TypeManager_GetApiDeclaration(const TYPEMAKER2_TYPEMANAGER *tym)
struct TYPEMAKER2_MEMBER TYPEMAKER2_MEMBER
static int _addGetByMemberImplementation(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
#define DBG_INFO(dbg_logger, format,...)
static void _addSortByMemberProtoType(TYPEMAKER2_BUILDER *tb, TYPEMAKER2_TYPE *ty, TYPEMAKER2_MEMBER *tm)
const char * Typemaker2_Member_GetName(const TYPEMAKER2_MEMBER *tm)