[settings] update test generator script

This commit is contained in:
Armin Novak 2023-10-16 19:22:36 +02:00 committed by akallabeth
parent 81d7558184
commit 8e9b6a9201

View File

@ -48,8 +48,8 @@ def write_str(f, entry_dict):
f.write('} FREERDP_SETTINGS_TYPE;\n') f.write('} FREERDP_SETTINGS_TYPE;\n')
f.write('\n') f.write('\n')
f.write('struct settings_str_entry {\n') f.write('struct settings_str_entry {\n')
f.write('\tsize_t id;\n') f.write('\tSSIZE_T id;\n')
f.write('\tsize_t type;\n') f.write('\tSSIZE_T type;\n')
f.write('\tconst char* str;\n') f.write('\tconst char* str;\n')
f.write('};\n') f.write('};\n')
f.write('static const struct settings_str_entry settings_map[] =\n') f.write('static const struct settings_str_entry settings_map[] =\n')
@ -63,398 +63,6 @@ def write_str(f, entry_dict):
write_str_case(f, entry_types.index(entry_type), val) write_str_case(f, entry_types.index(entry_type), val)
f.write('};\n\n') f.write('};\n\n')
f.write('\n') f.write('\n')
f.write('BOOL freerdp_settings_clone_keys(rdpSettings* dst, const rdpSettings* src)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(dst);\n')
f.write('\tWINPR_ASSERT(src);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tswitch(cur->type)\n')
f.write('\t\t{\n')
f.write('\t\t\tcase 0: /* bool */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tBOOL sval = freerdp_settings_get_bool(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_bool(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 1: /* UINT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT16 sval = freerdp_settings_get_uint16(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_uint16(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 2: /* INT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT16 sval = freerdp_settings_get_int16(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_int16(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 3: /* UINT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT32 sval = freerdp_settings_get_uint32(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_uint32(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 4: /* INT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT32 sval = freerdp_settings_get_int32(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_int32(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 5: /* UINT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT64 sval = freerdp_settings_get_uint64(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_uint64(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 6: /* INT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT64 sval = freerdp_settings_get_int64(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_int64(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 7: /* strings */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst char* sval = freerdp_settings_get_string(src, cur->id);\n')
f.write('\t\t\t\t\tsize_t len = 0;\n')
f.write('\t\t\t\t\tif (sval) len = strlen(sval);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_string_copy_(dst, cur->id, sval, len, FALSE))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 8: /* pointer */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst void* sval = freerdp_settings_get_pointer(src, cur->id);\n')
f.write('\t\t\t\tif (!freerdp_settings_set_pointer(dst, cur->id, sval))\n')
f.write('\t\t\t\t\treturn FALSE;\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t}\n')
f.write('\t}\n')
f.write('\treturn TRUE;\n')
f.write('}\n')
f.write('\n')
f.write('BOOL freerdp_settings_print_diff(wLog* log, DWORD level, const rdpSettings* settings, const rdpSettings* other)\n')
f.write('{\n')
f.write('\tBOOL rc = FALSE;\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(log);\n')
f.write('\tWINPR_ASSERT(settings);\n')
f.write('\tWINPR_ASSERT(other);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tswitch(cur->type)\n')
f.write('\t\t{\n')
f.write('\t\t\tcase 0: /* bool */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tBOOL sval = freerdp_settings_get_bool(settings, cur->id);\n')
f.write('\t\t\t\tBOOL cval = freerdp_settings_get_bool(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\t\tWLog_Print(log, level, "%s [BOOL]: %s -> %s", cur->str, sval ? "TRUE" : "FALSE", cval ? "TRUE" : "FALSE");\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 1: /* UINT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT16 sval = freerdp_settings_get_uint16(settings, cur->id);\n')
f.write('\t\t\t\tUINT16 cval = freerdp_settings_get_uint16(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT16]: %" PRIu16 " -> %" PRIu16, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 2: /* INT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT16 sval = freerdp_settings_get_int16(settings, cur->id);\n')
f.write('\t\t\t\tINT16 cval = freerdp_settings_get_int16(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT16]: %" PRId16 " -> %" PRId16, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 3: /* UINT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT32 sval = freerdp_settings_get_uint32(settings, cur->id);\n')
f.write('\t\t\t\tUINT32 cval = freerdp_settings_get_uint32(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT32]: %" PRIu32 " -> %" PRIu32, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 4: /* INT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT32 sval = freerdp_settings_get_int32(settings, cur->id);\n')
f.write('\t\t\t\tINT32 cval = freerdp_settings_get_int32(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT32]: %" PRId32 " -> %" PRId32, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 5: /* UINT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT64 sval = freerdp_settings_get_uint64(settings, cur->id);\n')
f.write('\t\t\t\tUINT64 cval = freerdp_settings_get_uint64(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT64]: %" PRIu64 " -> %" PRIu64, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 6: /* INT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT64 sval = freerdp_settings_get_int64(settings, cur->id);\n')
f.write('\t\t\t\tINT64 cval = freerdp_settings_get_int64(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT64]: %" PRId64 " -> %" PRId64, cur->str, sval, cval);\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 7: /* strings */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst char* sval = freerdp_settings_get_string(settings, cur->id);\n')
f.write('\t\t\t\tconst char* cval = freerdp_settings_get_string(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\tif (!sval || !cval || (strcmp(sval, cval) != 0))\n')
f.write('\t\t\t\t\t{\n')
f.write('\t\t\t\t\trc = TRUE;\n')
f.write('\t\t\t\t\t\tWLog_Print(log, level, "%s [STRING]: \'%s\' -> \'%s\'", cur->str, sval, cval);\n')
f.write('\t\t\t\t\t}\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 8: /* pointer */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst void* sval = freerdp_settings_get_pointer(settings, cur->id);\n')
f.write('\t\t\t\tconst void* cval = freerdp_settings_get_pointer(other, cur->id);\n')
f.write('\t\t\t\tif (sval != cval)\n')
f.write('\t\t\t\t{\n')
f.write('\t\t\t\t\tif ((sval && !cval) || (!sval && cval))\n')
f.write('\t\t\t\t\t{\n')
f.write('\t\t\t\t\t\trc=TRUE;\n')
f.write('\t\t\t\t\t\tWLog_Print(log, level, "%s [POINTER]: \'%p\' -> \'%p\'", cur->str, sval, cval);\n')
f.write('\t\t\t\t\t}\n')
f.write('\t\t\t\t}\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t}\n')
f.write('\t}\n')
f.write('\treturn rc;\n')
f.write('}\n')
f.write('\n')
f.write('void freerdp_settings_dump(wLog* log, DWORD level, const rdpSettings* settings)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(log);\n')
f.write('\tWINPR_ASSERT(settings);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tswitch(cur->type)\n')
f.write('\t\t{\n')
f.write('\t\t\tcase 0: /* bool */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tBOOL sval = freerdp_settings_get_bool(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [BOOL]: %s", cur->str, sval ? "TRUE" : "FALSE");\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 1: /* UINT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT16 sval = freerdp_settings_get_uint16(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT16]: %" PRIu16, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 2: /* INT16 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT16 sval = freerdp_settings_get_int16(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT16]: %" PRId16, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 3: /* UINT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT32 sval = freerdp_settings_get_uint32(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT32]: %" PRIu32, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 4: /* INT32 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT32 sval = freerdp_settings_get_int32(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT32]: %" PRId32, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 5: /* UINT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tUINT64 sval = freerdp_settings_get_uint64(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [UINT64]: %" PRIu64, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 6: /* INT64 */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tINT64 sval = freerdp_settings_get_int64(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [INT64]: %" PRId64, cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 7: /* strings */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst char* sval = freerdp_settings_get_string(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [STRING]: \'%s\'", cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 8: /* pointer */\n')
f.write('\t\t\t{\n')
f.write('\t\t\t\tconst void* sval = freerdp_settings_get_pointer(settings, cur->id);\n')
f.write('\t\t\t\tWLog_Print(log, level, "%s [POINTER]: \'%p\'", cur->str, sval);\n')
f.write('\t\t\t}\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t}\n')
f.write('\t}\n')
f.write('}\n')
f.write('\n')
f.write('void freerdp_settings_free_keys(rdpSettings* dst, BOOL cleanup)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(dst);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tswitch(cur->type)\n')
f.write('\t\t{\n')
f.write('\t\t\tcase 7: /* strings */\n')
f.write('\t\t\t\tfreerdp_settings_set_string_copy_(dst, cur->id, NULL, 0, cleanup);\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t\tcase 8: /* pointer */\n')
f.write('\t\t\t\tfreerdp_settings_set_pointer_len(dst, cur->id, NULL, 0);\n')
f.write('\t\t\tbreak;\n')
f.write('\t\t}\n')
f.write('\t}\n')
f.write('}\n')
f.write('\n')
f.write('SSIZE_T freerdp_settings_get_key_for_name(const char* value)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(value);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tif (strcmp(value, cur->str) == 0)\n')
f.write('\t\t\treturn cur->id;\n')
f.write('\t}\n')
f.write('\treturn -1;\n')
f.write('}\n')
f.write('\n')
f.write('SSIZE_T freerdp_settings_get_type_for_name(const char* value)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tWINPR_ASSERT(value);\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tif (strcmp(value, cur->str) == 0)\n')
f.write('\t\t\treturn cur->type;\n')
f.write('\t}\n')
f.write('\treturn -1;\n')
f.write('}\n')
f.write('\n')
f.write('const char* freerdp_settings_get_type_name_for_key(size_t key)\n')
f.write('{\n')
f.write('\tconst SSIZE_T type = freerdp_settings_get_type_for_key(key);\n')
f.write('\treturn freerdp_settings_get_type_name_for_type(type);\n')
f.write('}\n')
f.write('\n')
f.write('const char* freerdp_settings_get_type_name_for_type(SSIZE_T type)\n')
f.write('{\n')
f.write('\tswitch(type)\n')
f.write('\t{\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_BOOL:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_BOOL";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_UINT16:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_UINT16";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_INT16:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_INT16";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_UINT32:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_UINT32";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_INT32:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_INT32";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_UINT64:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_UINT64";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_INT64:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_INT64";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_STRING:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_STRING";\n')
f.write('\t\tcase FREERDP_SETTINGS_TYPE_POINTER:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_POINTER";\n')
f.write('\t\tdefault:\n')
f.write('\t\t\treturn "FREERDP_SETTINGS_TYPE_UNKNOWN";\n')
f.write('\t}')
f.write('}\n')
f.write('\n')
f.write('SSIZE_T freerdp_settings_get_type_for_key(size_t key)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tif (cur->id == key)\n')
f.write('\t\t\treturn cur->type;\n')
f.write('\t}\n')
f.write('\treturn -1;\n')
f.write('}\n')
f.write('\n')
f.write('const char* freerdp_settings_get_name_for_key(size_t key)\n')
f.write('{\n')
f.write('\tsize_t x;\n')
f.write('\n')
f.write('\tfor(x=0; x<ARRAYSIZE(settings_map); x++)\n')
f.write('\t{\n')
f.write('\t\tconst struct settings_str_entry* cur = &settings_map[x];\n')
f.write('\t\tif (cur->id == key)\n')
f.write('\t\t\treturn cur->str;\n')
f.write('\t}\n')
f.write('\treturn NULL;\n')
f.write('}\n')
f.write('\n')
def write_getter_case(f, val): def write_getter_case(f, val):
f.write('\t\tcase FreeRDP_' + val + ':\n') f.write('\t\tcase FreeRDP_' + val + ':\n')
@ -479,6 +87,9 @@ def write_getter(f, entry_dict, entry_type, entry_name, postfix):
isPointer = 'pointer' in entry_name isPointer = 'pointer' in entry_name
values = get_values(entry_dict, entry_type) values = get_values(entry_dict, entry_type)
typestr = 'FreeRDP_Settings_Keys_' + entry_name.capitalize()
typestr = typestr.replace('_Uint', '_UInt')
if isPointer: if isPointer:
f.write('void*') f.write('void*')
elif isString: elif isString:
@ -487,9 +98,9 @@ def write_getter(f, entry_dict, entry_type, entry_name, postfix):
f.write(entry_type) f.write(entry_type)
if isPointer: if isPointer:
f.write(' freerdp_settings_get_pointer_writable(rdpSettings* settings, size_t id)\n') f.write(' freerdp_settings_get_pointer_writable(rdpSettings* settings, ' + typestr + ' id)\n')
else: else:
f.write(' freerdp_settings_get_' + entry_name.lower() + '(const rdpSettings* settings, size_t id)\n') f.write(' freerdp_settings_get_' + entry_name.lower() + '(const rdpSettings* settings, ' + typestr + ' id)\n')
if isString or isPointer: if isString or isPointer:
ret = 'NULL'; ret = 'NULL';
elif 'bool' in entry_name: elif 'bool' in entry_name:
@ -500,7 +111,7 @@ def write_getter(f, entry_dict, entry_type, entry_name, postfix):
write_getter_body(f, values, ret) write_getter_body(f, values, ret)
if isString: if isString:
f.write('char* freerdp_settings_get_' + entry_name.lower() + '_writable(rdpSettings* settings, size_t id)\n') f.write('char* freerdp_settings_get_' + entry_name.lower() + '_writable(rdpSettings* settings, ' + typestr + ' id)\n')
write_getter_body(f, values, ret) write_getter_body(f, values, ret)
def write_setter_case(f, val, postfix, isPointer): def write_setter_case(f, val, postfix, isPointer):
@ -521,9 +132,11 @@ def write_setter(f, entry_dict, entry_type, entry_name, postfix):
isPointer = 'pointer' in entry_name isPointer = 'pointer' in entry_name
values = get_values(entry_dict, entry_type) values = get_values(entry_dict, entry_type)
typestr = 'FreeRDP_Settings_Keys_' + entry_name.capitalize()
typestr = typestr.replace('_Uint', '_UInt')
f.write('BOOL freerdp_settings_set_' + entry_name.lower()) f.write('BOOL freerdp_settings_set_' + entry_name.lower())
f.write(postfix) f.write(postfix)
f.write('(rdpSettings* settings, size_t id, ') f.write('(rdpSettings* settings, ' + typestr + ' id, ')
if isString and len(postfix) > 1 or isPointer: if isString and len(postfix) > 1 or isPointer:
f.write('const ') f.write('const ')
if not isPointer: if not isPointer:
@ -566,13 +179,13 @@ def write_setter(f, entry_dict, entry_type, entry_name, postfix):
f.write('}\n\n') f.write('}\n\n')
f.write('\n') f.write('\n')
if isString and len(postfix) <= 1: if isString and len(postfix) <= 1:
f.write('BOOL freerdp_settings_set_string_len(rdpSettings* settings, size_t id, const char* val, size_t len)\n') f.write('BOOL freerdp_settings_set_string_len(rdpSettings* settings, FreeRDP_Settings_Keys_String id, const char* val, size_t len)\n')
f.write('{\n') f.write('{\n')
f.write('\treturn freerdp_settings_set_string_copy_(settings, id, val, len, TRUE);\n') f.write('\treturn freerdp_settings_set_string_copy_(settings, id, val, len, TRUE);\n')
f.write('}\n') f.write('}\n')
f.write('\n') f.write('\n')
f.write('BOOL freerdp_settings_set_string(rdpSettings* settings, size_t id, const char* val)\n') f.write('BOOL freerdp_settings_set_string(rdpSettings* settings, FreeRDP_Settings_Keys_String id, const char* val)\n')
f.write('{\n') f.write('{\n')
f.write('\tsize_t len = 0;\n') f.write('\tsize_t len = 0;\n')
f.write('\tif (val) len = strlen(val);\n') f.write('\tif (val) len = strlen(val);\n')
@ -588,7 +201,7 @@ print('begin parsing settings header')
try: try:
type_list = dict() type_list = dict()
with open(name + "/../include/freerdp/settings.h", "r") as f: with open(name + "/../include/freerdp/settings_types_private.h", "r") as f:
lines = f.readlines() lines = f.readlines()
started = False started = False
for line in lines: for line in lines:
@ -610,10 +223,10 @@ try:
if 'padding' in sline: if 'padding' in sline:
continue continue
if sline.startswith('ALIGN64'): if sline.startswith('SETTINGS_DEPRECATED(ALIGN64'):
sline = sline[7:].strip() sline = sline[27:].strip()
sline = sline[:sline.find(';')] sline = sline[:sline.find(');')]
pair = sline.split() pair = sline.split()
if pair[0] in type_list: if pair[0] in type_list:
type_list[pair[0]].append(pair[1]) type_list[pair[0]].append(pair[1])
@ -622,10 +235,10 @@ try:
with open(name + '/../libfreerdp/common/settings_getters.c', 'w+') as f: with open(name + '/../libfreerdp/common/settings_getters.c', 'w+') as f:
f.write('/* Generated by ' + '' + ' */\n\n') f.write('/* Generated by ' + '' + ' */\n\n')
f.write('#include "../core/settings.h"\n\n')
f.write('#include <winpr/assert.h>\n') f.write('#include <winpr/assert.h>\n')
f.write('#include <freerdp/settings.h>\n') f.write('#include <freerdp/settings.h>\n')
f.write('#include <freerdp/log.h>\n\n') f.write('#include <freerdp/log.h>\n\n')
f.write('#include "../core/settings.h"\n\n')
f.write('#define TAG FREERDP_TAG("common.settings")\n\n') f.write('#define TAG FREERDP_TAG("common.settings")\n\n')
f.write('static void free_string(char** current, BOOL cleanup)\n') f.write('static void free_string(char** current, BOOL cleanup)\n')
@ -697,15 +310,18 @@ try:
f.write('\n') f.write('\n')
with open(name + '/../libfreerdp/common/settings_str.c', 'w+') as f: with open(name + '/../libfreerdp/common/settings_str.h', 'w+') as f:
f.write('/* Generated by ' + '' + ' */\n\n') f.write('/* Generated by ' + '' + ' */\n\n')
f.write('#ifndef FREERDP_CORE_SETTINGS_STR_H\n')
f.write('#define FREERDP_CORE_SETTINGS_STR_H\n\n')
f.write('#include "../core/settings.h"\n\n')
f.write('#include <freerdp/settings.h>\n') f.write('#include <freerdp/settings.h>\n')
f.write('#include <freerdp/log.h>\n\n') f.write('#include <freerdp/log.h>\n\n')
f.write('#include "../core/settings.h"\n\n')
f.write('#define TAG FREERDP_TAG("common.settings")\n\n') f.write('#define TAG FREERDP_TAG("common.settings")\n\n')
getter_list = dict(type_list) getter_list = dict(type_list)
write_str(f, getter_list) write_str(f, getter_list)
f.write('#endif\n')
f.write('\n') f.write('\n')