diff --git a/tools/widl/expr.c b/tools/widl/expr.c index 0a9d81ecc5a..405b5def1b6 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -290,20 +290,18 @@ static int is_integer_type(const type_t *type) case TYPE_ENUM: return TRUE; case TYPE_BASIC: - switch (type_basic_get_fc(type)) + switch (type_basic_get_type(type)) { - case RPC_FC_BYTE: - case RPC_FC_CHAR: - case RPC_FC_SMALL: - case RPC_FC_USMALL: - case RPC_FC_WCHAR: - case RPC_FC_SHORT: - case RPC_FC_USHORT: - case RPC_FC_LONG: - case RPC_FC_ULONG: - case RPC_FC_INT3264: - case RPC_FC_UINT3264: - case RPC_FC_HYPER: + case TYPE_BASIC_INT8: + case TYPE_BASIC_INT16: + case TYPE_BASIC_INT32: + case TYPE_BASIC_INT64: + case TYPE_BASIC_INT: + case TYPE_BASIC_CHAR: + case TYPE_BASIC_HYPER: + case TYPE_BASIC_BYTE: + case TYPE_BASIC_WCHAR: + case TYPE_BASIC_ERROR_STATUS_T: return TRUE; default: return FALSE; @@ -316,8 +314,8 @@ static int is_integer_type(const type_t *type) static int is_float_type(const type_t *type) { return (type_get_type(type) == TYPE_BASIC && - (type_basic_get_fc(type) == RPC_FC_FLOAT || - type_basic_get_fc(type) == RPC_FC_DOUBLE)); + (type_basic_get_type(type) == TYPE_BASIC_FLOAT || + type_basic_get_type(type) == TYPE_BASIC_DOUBLE)); } static void check_scalar_type(const struct expr_loc *expr_loc, diff --git a/tools/widl/header.c b/tools/widl/header.c index ed88284cfd7..9b6167e1913 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -416,7 +416,7 @@ void check_for_additional_prototype_types(const var_list_t *list) break; } if ((type_get_type(type) != TYPE_BASIC || - type_basic_get_fc(type) != RPC_FC_BIND_PRIMITIVE) && + type_basic_get_type(type) != TYPE_BASIC_HANDLE) && is_attr(type->attrs, ATTR_HANDLE)) { if (!generic_handle_registered(name)) { @@ -576,7 +576,7 @@ const var_t* get_explicit_handle_var(const var_t *func) LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry ) { const type_t *type = var->type; - if (type_get_type(type) == TYPE_BASIC && type_basic_get_fc(type) == RPC_FC_BIND_PRIMITIVE) + if (type_get_type(type) == TYPE_BASIC && type_basic_get_type(type) == TYPE_BASIC_HANDLE) return var; } @@ -589,7 +589,7 @@ const type_t* get_explicit_generic_handle_type(const var_t* var) for (t = var->type; is_ptr(t) || type_is_alias(t); t = type_is_alias(t) ? type_alias_get_aliasee(t) : type_pointer_get_ref(t)) - if ((type_get_type_detect_alias(t) != TYPE_BASIC || type_basic_get_fc(t) != RPC_FC_BIND_PRIMITIVE) && + if ((type_get_type_detect_alias(t) != TYPE_BASIC || type_basic_get_type(t) != TYPE_BASIC_HANDLE) && is_attr(t->attrs, ATTR_HANDLE)) return t; return NULL; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 5664c77bb47..fe3db868fd3 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1685,9 +1685,9 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at t = type_pointer_get_ref(t); if (type_get_type(t) != TYPE_BASIC && - (type_basic_get_fc(t) != RPC_FC_CHAR && - type_basic_get_fc(t) != RPC_FC_BYTE && - type_basic_get_fc(t) != RPC_FC_WCHAR)) + (get_basic_fc(t) != RPC_FC_CHAR && + get_basic_fc(t) != RPC_FC_BYTE && + get_basic_fc(t) != RPC_FC_WCHAR)) { decl = LIST_ENTRY( list_head( decls ), const declarator_t, entry ); error_loc("'%s': [string] attribute is only valid on 'char', 'byte', or 'wchar_t' pointers and arrays\n", @@ -2118,18 +2118,18 @@ static int is_allowed_conf_type(const type_t *type) case TYPE_ENUM: return TRUE; case TYPE_BASIC: - switch (type_basic_get_fc(type)) + switch (type_basic_get_type(type)) { - case RPC_FC_CHAR: - case RPC_FC_SMALL: - case RPC_FC_BYTE: - case RPC_FC_USMALL: - case RPC_FC_WCHAR: - case RPC_FC_SHORT: - case RPC_FC_USHORT: - case RPC_FC_LONG: - case RPC_FC_ULONG: - case RPC_FC_ERROR_STATUS_T: + case TYPE_BASIC_INT8: + case TYPE_BASIC_INT16: + case TYPE_BASIC_INT32: + case TYPE_BASIC_INT64: + case TYPE_BASIC_INT: + case TYPE_BASIC_CHAR: + case TYPE_BASIC_HYPER: + case TYPE_BASIC_BYTE: + case TYPE_BASIC_WCHAR: + case TYPE_BASIC_ERROR_STATUS_T: return TRUE; default: return FALSE; diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 4c5a96f95ac..ce4d3d7da80 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -120,6 +120,28 @@ const char *string_of_type(unsigned char type) } } +unsigned char get_basic_fc(const type_t *type) +{ + int sign = type_basic_get_sign(type); + switch (type_basic_get_type(type)) + { + case TYPE_BASIC_INT8: return (sign <= 0 ? RPC_FC_SMALL : RPC_FC_USMALL); + case TYPE_BASIC_INT16: return (sign <= 0 ? RPC_FC_SHORT : RPC_FC_USHORT); + case TYPE_BASIC_INT32: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG); + case TYPE_BASIC_INT64: return RPC_FC_HYPER; + case TYPE_BASIC_INT: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG); + case TYPE_BASIC_BYTE: return RPC_FC_BYTE; + case TYPE_BASIC_CHAR: return RPC_FC_CHAR; + case TYPE_BASIC_WCHAR: return RPC_FC_WCHAR; + case TYPE_BASIC_HYPER: return RPC_FC_HYPER; + case TYPE_BASIC_FLOAT: return RPC_FC_FLOAT; + case TYPE_BASIC_DOUBLE: return RPC_FC_DOUBLE; + case TYPE_BASIC_ERROR_STATUS_T: return RPC_FC_ERROR_STATUS_T; + case TYPE_BASIC_HANDLE: return RPC_FC_BIND_PRIMITIVE; + default: return 0; + } +} + unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param) { const type_t *t; @@ -736,7 +758,7 @@ static unsigned int write_procformatstring_type(FILE *file, int indent, } else { - fc = type_basic_get_fc(type); + fc = get_basic_fc(type); if (fc == RPC_FC_BIND_PRIMITIVE) fc = RPC_FC_IGNORE; @@ -827,7 +849,7 @@ static int write_base_type(FILE *file, const type_t *type, int convert_to_signed unsigned char fc; if (type_get_type(type) == TYPE_BASIC) - fc = type_basic_get_fc(type); + fc = get_basic_fc(type); else if (type_get_type(type) == TYPE_ENUM) fc = get_enum_fc(type); else @@ -975,7 +997,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *structure, if (type_get_type(correlation_variable) == TYPE_BASIC) { - switch (type_basic_get_fc(correlation_variable)) + switch (get_basic_fc(correlation_variable)) { case RPC_FC_CHAR: case RPC_FC_SMALL: @@ -1000,7 +1022,7 @@ static unsigned int write_conf_or_var_desc(FILE *file, const type_t *structure, break; default: error("write_conf_or_var_desc: conformance variable type not supported 0x%x\n", - type_basic_get_fc(correlation_variable)); + get_basic_fc(correlation_variable)); } } else if (type_get_type(correlation_variable) == TYPE_ENUM) @@ -1133,7 +1155,7 @@ unsigned int type_memsize(const type_t *t, unsigned int *align) switch (type_get_type(t)) { case TYPE_BASIC: - switch (type_basic_get_fc(t)) + switch (get_basic_fc(t)) { case RPC_FC_BYTE: case RPC_FC_CHAR: @@ -1161,7 +1183,7 @@ unsigned int type_memsize(const type_t *t, unsigned int *align) if (size > *align) *align = size; break; default: - error("type_memsize: Unknown type 0x%x\n", type_basic_get_fc(t)); + error("type_memsize: Unknown type 0x%x\n", get_basic_fc(t)); size = 0; } break; @@ -1316,7 +1338,7 @@ static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs, c if (type_get_type(ref) == TYPE_ENUM) fc = get_enum_fc(ref); else - fc = type_basic_get_fc(ref); + fc = get_basic_fc(ref); print_file(file, 2, "0x%02x, 0x%x,\t/* %s [simple_pointer] */\n", pointer_fc, RPC_FC_P_SIMPLEPOINTER, string_of_type(pointer_fc)); @@ -1401,7 +1423,7 @@ static void write_user_tfs(FILE *file, type_t *type, unsigned int *tfsoff) if (type_get_type(utype) == TYPE_ENUM) fc = get_enum_fc(utype); else - fc = type_basic_get_fc(utype); + fc = get_basic_fc(utype); absoff = *tfsoff; print_start_tfs_comment(file, utype, absoff); @@ -1978,7 +2000,7 @@ static unsigned int write_string_tfs(FILE *file, const attr_list_t *attrs, return start_offset; } - rtype = type_basic_get_fc(elem_type); + rtype = get_basic_fc(elem_type); if ((rtype != RPC_FC_BYTE) && (rtype != RPC_FC_CHAR) && (rtype != RPC_FC_WCHAR)) { error("write_string_tfs: Unimplemented for type 0x%x of name: %s\n", rtype, name); @@ -2363,7 +2385,7 @@ static void write_branch_type(FILE *file, const type_t *t, unsigned int *tfsoff) { unsigned char fc; if (type_get_type(t) == TYPE_BASIC) - fc = type_basic_get_fc(t); + fc = get_basic_fc(t); else fc = get_enum_fc(t); print_file(file, 2, "NdrFcShort(0x80%02x),\t/* Simple arm type: %s */\n", @@ -2420,7 +2442,7 @@ static unsigned int write_union_tfs(FILE *file, type_t *type, unsigned int *tfso if (type_get_type(st) == TYPE_BASIC) { - switch (type_basic_get_fc(st)) + switch (get_basic_fc(st)) { case RPC_FC_CHAR: case RPC_FC_SMALL: @@ -2431,7 +2453,7 @@ static unsigned int write_union_tfs(FILE *file, type_t *type, unsigned int *tfso case RPC_FC_USHORT: case RPC_FC_LONG: case RPC_FC_ULONG: - fc = type_basic_get_fc(st); + fc = get_basic_fc(st); break; default: fc = 0; @@ -2456,7 +2478,7 @@ static unsigned int write_union_tfs(FILE *file, type_t *type, unsigned int *tfso if (type_get_type(st) == TYPE_BASIC) { - switch (type_basic_get_fc(st)) + switch (get_basic_fc(st)) { case RPC_FC_CHAR: case RPC_FC_SMALL: @@ -2467,7 +2489,7 @@ static unsigned int write_union_tfs(FILE *file, type_t *type, unsigned int *tfso case RPC_FC_ULONG: case RPC_FC_ENUM16: case RPC_FC_ENUM32: - fc = type_basic_get_fc(st); + fc = get_basic_fc(st); break; default: fc = 0; @@ -2692,7 +2714,7 @@ static unsigned int write_typeformatstring_var(FILE *file, int indent, const var if (type_get_type(ref) == TYPE_ENUM) fc = get_enum_fc(ref); else - fc = type_basic_get_fc(ref); + fc = get_basic_fc(ref); print_file(file, indent, "0x%x, 0x%x, /* %s %s[simple_pointer] */\n", get_pointer_fc(type, var->attrs, toplevel_param), @@ -2885,7 +2907,7 @@ static unsigned int get_required_buffer_size_type( return get_required_buffer_size_type(utype, uname, NULL, FALSE, alignment); } case TGT_BASIC: - switch (type_basic_get_fc(type)) + switch (get_basic_fc(type)) { case RPC_FC_BYTE: case RPC_FC_CHAR: @@ -2918,7 +2940,7 @@ static unsigned int get_required_buffer_size_type( default: error("get_required_buffer_size: unknown basic type 0x%02x\n", - type_basic_get_fc(type)); + get_basic_fc(type)); return 0; } break; @@ -3100,7 +3122,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, } else { - switch (type_basic_get_fc(ref)) + switch (get_basic_fc(ref)) { case RPC_FC_BYTE: case RPC_FC_CHAR: @@ -3138,7 +3160,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, default: error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n", - var->name, type_basic_get_fc(ref)); + var->name, get_basic_fc(ref)); size = 0; } } diff --git a/tools/widl/typegen.h b/tools/widl/typegen.h index 40b397c7fc4..8c8ba11da64 100644 --- a/tools/widl/typegen.h +++ b/tools/widl/typegen.h @@ -88,6 +88,7 @@ expr_t *get_size_is_expr(const type_t *t, const char *name); int is_full_pointer_function(const var_t *func); void write_full_pointer_init(FILE *file, int indent, const var_t *func, int is_server); void write_full_pointer_free(FILE *file, int indent, const var_t *func); +unsigned char get_basic_fc(const type_t *type); unsigned char get_pointer_fc(const type_t *type, const attr_list_t *attrs, int toplevel_param); unsigned char get_struct_fc(const type_t *type); enum typegen_type typegen_detect_type(const type_t *type, const attr_list_t *attrs, unsigned int flags); diff --git a/tools/widl/typelib.c b/tools/widl/typelib.c index 52f48a1aea9..d675ea951cf 100644 --- a/tools/widl/typelib.c +++ b/tools/widl/typelib.c @@ -116,10 +116,10 @@ static unsigned short builtin_vt(const type_t *t) elem_type = type_pointer_get_ref(t); if (type_get_type(elem_type) == TYPE_BASIC) { - switch (type_basic_get_fc(elem_type)) + switch (type_basic_get_type(elem_type)) { - case RPC_FC_CHAR: return VT_LPSTR; - case RPC_FC_WCHAR: return VT_LPWSTR; + case TYPE_BASIC_CHAR: return VT_LPSTR; + case TYPE_BASIC_WCHAR: return VT_LPWSTR; default: break; } } diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 5ada41fc9b7..fb0401b87a6 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -63,31 +63,6 @@ static inline enum type_type type_get_type(const type_t *type) return type_get_type_detect_alias(type_get_real_type(type)); } -static inline unsigned char type_basic_get_fc(const type_t *type) -{ - int sign; - type = type_get_real_type(type); - assert(type_get_type(type) == TYPE_BASIC); - sign = type->details.basic.sign; - switch (type->details.basic.type) - { - case TYPE_BASIC_INT8: return (sign <= 0 ? RPC_FC_SMALL : RPC_FC_USMALL); - case TYPE_BASIC_INT16: return (sign <= 0 ? RPC_FC_SHORT : RPC_FC_USHORT); - case TYPE_BASIC_INT32: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG); - case TYPE_BASIC_INT64: return RPC_FC_HYPER; - case TYPE_BASIC_INT: return (sign <= 0 ? RPC_FC_LONG : RPC_FC_ULONG); - case TYPE_BASIC_BYTE: return RPC_FC_BYTE; - case TYPE_BASIC_CHAR: return RPC_FC_CHAR; - case TYPE_BASIC_WCHAR: return RPC_FC_WCHAR; - case TYPE_BASIC_HYPER: return RPC_FC_HYPER; - case TYPE_BASIC_FLOAT: return RPC_FC_FLOAT; - case TYPE_BASIC_DOUBLE: return RPC_FC_DOUBLE; - case TYPE_BASIC_ERROR_STATUS_T: return RPC_FC_ERROR_STATUS_T; - case TYPE_BASIC_HANDLE: return RPC_FC_BIND_PRIMITIVE; - default: return 0; - } -} - static inline enum type_basic_type type_basic_get_type(const type_t *type) { type = type_get_real_type(type);