Commit 33c891e6 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Add support for string literals and wide-string literals in expressions.

parent 957dd4b1
...@@ -411,6 +411,16 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc ...@@ -411,6 +411,16 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
result.is_temporary = FALSE; result.is_temporary = FALSE;
result.type = find_type("int", 0); result.type = find_type("int", 0);
break; break;
case EXPR_STRLIT:
result.is_variable = FALSE;
result.is_temporary = TRUE;
result.type = make_type(RPC_FC_RP, find_type("char", 0));
break;
case EXPR_WSTRLIT:
result.is_variable = FALSE;
result.is_temporary = TRUE;
result.type = make_type(RPC_FC_RP, find_type("wchar_t", 0));
break;
case EXPR_DOUBLE: case EXPR_DOUBLE:
result.is_variable = FALSE; result.is_variable = FALSE;
result.is_temporary = FALSE; result.is_temporary = FALSE;
...@@ -596,6 +606,12 @@ void write_expr(FILE *h, const expr_t *e, int brackets, ...@@ -596,6 +606,12 @@ void write_expr(FILE *h, const expr_t *e, int brackets,
} }
fprintf(h, "%s", e->u.sval); fprintf(h, "%s", e->u.sval);
break; break;
case EXPR_STRLIT:
fprintf(h, "\"%s\"", e->u.sval);
break;
case EXPR_WSTRLIT:
fprintf(h, "L\"%s\"", e->u.sval);
break;
case EXPR_LOGNOT: case EXPR_LOGNOT:
fprintf(h, "!"); fprintf(h, "!");
write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type); write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type);
...@@ -743,6 +759,8 @@ int compare_expr(const expr_t *a, const expr_t *b) ...@@ -743,6 +759,8 @@ int compare_expr(const expr_t *a, const expr_t *b)
case EXPR_DOUBLE: case EXPR_DOUBLE:
return a->u.dval - b->u.dval; return a->u.dval - b->u.dval;
case EXPR_IDENTIFIER: case EXPR_IDENTIFIER:
case EXPR_STRLIT:
case EXPR_WSTRLIT:
return strcmp(a->u.sval, b->u.sval); return strcmp(a->u.sval, b->u.sval);
case EXPR_COND: case EXPR_COND:
ret = compare_expr(a->ref, b->ref); ret = compare_expr(a->ref, b->ref);
......
...@@ -32,6 +32,7 @@ uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12} ...@@ -32,6 +32,7 @@ uuid {hexd}{8}-{hexd}{4}-{hexd}{4}-{hexd}{4}-{hexd}{12}
double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)* double [0-9]+\.[0-9]+([eE][+-]?[0-9]+)*
%x QUOTE %x QUOTE
%x WSTRQUOTE
%x ATTR %x ATTR
%x PP_LINE %x PP_LINE
...@@ -133,10 +134,16 @@ UUID *parse_uuid(const char *u) ...@@ -133,10 +134,16 @@ UUID *parse_uuid(const char *u)
parser_lval.str = get_buffered_cstring(); parser_lval.str = get_buffered_cstring();
return aSTRING; return aSTRING;
} }
<QUOTE>\\\\ | <INITIAL,ATTR>L\" yy_push_state(WSTRQUOTE);
<QUOTE>\\\" addcchar(yytext[1]); <WSTRQUOTE>\" {
<QUOTE>\\. addcchar('\\'); addcchar(yytext[1]); yy_pop_state();
<QUOTE>. addcchar(yytext[0]); parser_lval.str = get_buffered_cstring();
return aWSTRING;
}
<QUOTE,WSTRQUOTE>\\\\ |
<QUOTE,WSTRQUOTE>\\\" addcchar(yytext[1]);
<QUOTE,WSTRQUOTE>\\. addcchar('\\'); addcchar(yytext[1]);
<QUOTE,WSTRQUOTE>. addcchar(yytext[0]);
<INITIAL,ATTR>\[ yy_push_state(ATTR); return '['; <INITIAL,ATTR>\[ yy_push_state(ATTR); return '[';
<ATTR>\] yy_pop_state(); return ']'; <ATTR>\] yy_pop_state(); return ']';
<ATTR>{cident} return attr_token(yytext); <ATTR>{cident} return attr_token(yytext);
......
...@@ -187,7 +187,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s ...@@ -187,7 +187,7 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%token <str> aKNOWNTYPE %token <str> aKNOWNTYPE
%token <num> aNUM aHEXNUM %token <num> aNUM aHEXNUM
%token <dbl> aDOUBLE %token <dbl> aDOUBLE
%token <str> aSTRING %token <str> aSTRING aWSTRING
%token <uuid> aUUID %token <uuid> aUUID
%token aEOF %token aEOF
%token SHL SHR %token SHL SHR
...@@ -278,8 +278,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s ...@@ -278,8 +278,8 @@ static statement_list_t *append_statement(statement_list_t *list, statement_t *s
%type <attr> attribute %type <attr> attribute
%type <attr_list> m_attributes attributes attrib_list %type <attr_list> m_attributes attributes attrib_list
%type <str_list> str_list %type <str_list> str_list
%type <expr> m_expr expr expr_const array %type <expr> m_expr expr expr_const expr_int_const array
%type <expr_list> m_exprs /* exprs expr_list */ expr_list_const %type <expr_list> m_exprs /* exprs expr_list */ expr_list_int_const
%type <ifinfo> interfacehdr %type <ifinfo> interfacehdr
%type <type> inherit interface interfacedef interfacedec %type <type> inherit interface interfacedef interfacedec
%type <type> dispinterface dispinterfacehdr dispinterfacedef %type <type> dispinterface dispinterfacehdr dispinterfacedef
...@@ -492,31 +492,29 @@ attribute: { $$ = NULL; } ...@@ -492,31 +492,29 @@ attribute: { $$ = NULL; }
| tBINDABLE { $$ = make_attr(ATTR_BINDABLE); } | tBINDABLE { $$ = make_attr(ATTR_BINDABLE); }
| tBROADCAST { $$ = make_attr(ATTR_BROADCAST); } | tBROADCAST { $$ = make_attr(ATTR_BROADCAST); }
| tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); } | tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); }
| tCASE '(' expr_list_const ')' { $$ = make_attrp(ATTR_CASE, $3); } | tCASE '(' expr_list_int_const ')' { $$ = make_attrp(ATTR_CASE, $3); }
| tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); } | tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); }
| tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ }
| tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } | tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ }
| tCONTROL { $$ = make_attr(ATTR_CONTROL); } | tCONTROL { $$ = make_attr(ATTR_CONTROL); }
| tDEFAULT { $$ = make_attr(ATTR_DEFAULT); } | tDEFAULT { $$ = make_attr(ATTR_DEFAULT); }
| tDEFAULTCOLLELEM { $$ = make_attr(ATTR_DEFAULTCOLLELEM); } | tDEFAULTCOLLELEM { $$ = make_attr(ATTR_DEFAULTCOLLELEM); }
| tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp(ATTR_DEFAULTVALUE_EXPR, $3); } | tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp(ATTR_DEFAULTVALUE, $3); }
| tDEFAULTVALUE '(' aSTRING ')' { $$ = make_attrp(ATTR_DEFAULTVALUE_STRING, $3); }
| tDEFAULTVTABLE { $$ = make_attr(ATTR_DEFAULTVTABLE); } | tDEFAULTVTABLE { $$ = make_attr(ATTR_DEFAULTVTABLE); }
| tDISPLAYBIND { $$ = make_attr(ATTR_DISPLAYBIND); } | tDISPLAYBIND { $$ = make_attr(ATTR_DISPLAYBIND); }
| tDLLNAME '(' aSTRING ')' { $$ = make_attrp(ATTR_DLLNAME, $3); } | tDLLNAME '(' aSTRING ')' { $$ = make_attrp(ATTR_DLLNAME, $3); }
| tDUAL { $$ = make_attr(ATTR_DUAL); } | tDUAL { $$ = make_attr(ATTR_DUAL); }
| tENDPOINT '(' str_list ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); } | tENDPOINT '(' str_list ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); }
| tENTRY '(' aSTRING ')' { $$ = make_attrp(ATTR_ENTRY_STRING, $3); } | tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY, $3); }
| tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY_ORDINAL, $3); }
| tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); }
| tHANDLE { $$ = make_attr(ATTR_HANDLE); } | tHANDLE { $$ = make_attr(ATTR_HANDLE); }
| tHELPCONTEXT '(' expr_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); } | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); }
| tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); } | tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); }
| tHELPSTRING '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRING, $3); } | tHELPSTRING '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRING, $3); }
| tHELPSTRINGCONTEXT '(' expr_const ')' { $$ = make_attrp(ATTR_HELPSTRINGCONTEXT, $3); } | tHELPSTRINGCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPSTRINGCONTEXT, $3); }
| tHELPSTRINGDLL '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRINGDLL, $3); } | tHELPSTRINGDLL '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRINGDLL, $3); }
| tHIDDEN { $$ = make_attr(ATTR_HIDDEN); } | tHIDDEN { $$ = make_attr(ATTR_HIDDEN); }
| tID '(' expr_const ')' { $$ = make_attrp(ATTR_ID, $3); } | tID '(' expr_int_const ')' { $$ = make_attrp(ATTR_ID, $3); }
| tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); } | tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); }
| tIIDIS '(' expr ')' { $$ = make_attrp(ATTR_IIDIS, $3); } | tIIDIS '(' expr ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
| tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); } | tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); }
...@@ -524,7 +522,7 @@ attribute: { $$ = NULL; } ...@@ -524,7 +522,7 @@ attribute: { $$ = NULL; }
| tIN { $$ = make_attr(ATTR_IN); } | tIN { $$ = make_attr(ATTR_IN); }
| tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); } | tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); }
| tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); } | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); }
| tLCID '(' expr_const ')' { $$ = make_attrp(ATTR_LIBLCID, $3); } | tLCID '(' expr_int_const ')' { $$ = make_attrp(ATTR_LIBLCID, $3); }
| tLOCAL { $$ = make_attr(ATTR_LOCAL); } | tLOCAL { $$ = make_attr(ATTR_LOCAL); }
| tNONBROWSABLE { $$ = make_attr(ATTR_NONBROWSABLE); } | tNONBROWSABLE { $$ = make_attr(ATTR_NONBROWSABLE); }
| tNONCREATABLE { $$ = make_attr(ATTR_NONCREATABLE); } | tNONCREATABLE { $$ = make_attr(ATTR_NONCREATABLE); }
...@@ -539,9 +537,10 @@ attribute: { $$ = NULL; } ...@@ -539,9 +537,10 @@ attribute: { $$ = NULL; }
| tPROPPUT { $$ = make_attr(ATTR_PROPPUT); } | tPROPPUT { $$ = make_attr(ATTR_PROPPUT); }
| tPROPPUTREF { $$ = make_attr(ATTR_PROPPUTREF); } | tPROPPUTREF { $$ = make_attr(ATTR_PROPPUTREF); }
| tPUBLIC { $$ = make_attr(ATTR_PUBLIC); } | tPUBLIC { $$ = make_attr(ATTR_PUBLIC); }
| tRANGE '(' expr_const ',' expr_const ')' { expr_list_t *list = append_expr( NULL, $3 ); | tRANGE '(' expr_int_const ',' expr_int_const ')'
list = append_expr( list, $5 ); { expr_list_t *list = append_expr( NULL, $3 );
$$ = make_attrp(ATTR_RANGE, list); } list = append_expr( list, $5 );
$$ = make_attrp(ATTR_RANGE, list); }
| tREADONLY { $$ = make_attr(ATTR_READONLY); } | tREADONLY { $$ = make_attr(ATTR_READONLY); }
| tREQUESTEDIT { $$ = make_attr(ATTR_REQUESTEDIT); } | tREQUESTEDIT { $$ = make_attr(ATTR_REQUESTEDIT); }
| tRESTRICTED { $$ = make_attr(ATTR_RESTRICTED); } | tRESTRICTED { $$ = make_attr(ATTR_RESTRICTED); }
...@@ -578,7 +577,7 @@ cases: { $$ = NULL; } ...@@ -578,7 +577,7 @@ cases: { $$ = NULL; }
| cases case { $$ = append_var( $1, $2 ); } | cases case { $$ = append_var( $1, $2 ); }
; ;
case: tCASE expr_const ':' union_field { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, $2 )); case: tCASE expr_int_const ':' union_field { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, $2 ));
$$ = $4; if (!$$) $$ = make_var(NULL); $$ = $4; if (!$$) $$ = make_var(NULL);
$$->attrs = append_attr( $$->attrs, a ); $$->attrs = append_attr( $$->attrs, a );
} }
...@@ -612,7 +611,7 @@ enum_list: enum { if (!$1->eval) ...@@ -612,7 +611,7 @@ enum_list: enum { if (!$1->eval)
} }
; ;
enum: ident '=' expr_const { $$ = reg_const($1); enum: ident '=' expr_int_const { $$ = reg_const($1);
$$->eval = $3; $$->eval = $3;
$$->type = make_int(0); $$->type = make_int(0);
} }
...@@ -654,6 +653,8 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } ...@@ -654,6 +653,8 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); } | tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
| tNULL { $$ = make_exprl(EXPR_NUM, 0); } | tNULL { $$ = make_exprl(EXPR_NUM, 0); }
| tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); } | tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); }
| aSTRING { $$ = make_exprs(EXPR_STRLIT, $1); }
| aWSTRING { $$ = make_exprs(EXPR_WSTRLIT, $1); }
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); } | aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); } | expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
| expr LOGICALOR expr { $$ = make_expr2(EXPR_LOGOR, $1, $3); } | expr LOGICALOR expr { $$ = make_expr2(EXPR_LOGOR, $1, $3); }
...@@ -688,12 +689,18 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } ...@@ -688,12 +689,18 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| '(' expr ')' { $$ = $2; } | '(' expr ')' { $$ = $2; }
; ;
expr_list_const: expr_const { $$ = append_expr( NULL, $1 ); } expr_list_int_const: expr_int_const { $$ = append_expr( NULL, $1 ); }
| expr_list_const ',' expr_const { $$ = append_expr( $1, $3 ); } | expr_list_int_const ',' expr_int_const { $$ = append_expr( $1, $3 ); }
; ;
expr_const: expr { $$ = $1; expr_int_const: expr { $$ = $1;
if (!$$->is_const) if (!$$->is_const)
error_loc("expression is not an integer constant\n");
}
;
expr_const: expr { $$ = $1;
if (!$$->is_const && $$->type != EXPR_STRLIT && $$->type != EXPR_WSTRLIT)
error_loc("expression is not constant\n"); error_loc("expression is not constant\n");
} }
; ;
...@@ -2047,16 +2054,14 @@ struct allowed_attr allowed_attr[] = ...@@ -2047,16 +2054,14 @@ struct allowed_attr allowed_attr[] =
/* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" }, /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "control" },
/* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "default" }, /* ATTR_DEFAULT */ { 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, "default" },
/* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" },
/* ATTR_DEFAULTVALUE_EXPR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" }, /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" },
/* ATTR_DEFAULTVALUE_STRING */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "defaultvalue" },
/* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" }, /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "defaultvtable" },
/* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL },
/* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, /* ATTR_DISPLAYBIND */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "displaybind" },
/* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" }, /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "dllname" },
/* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, /* ATTR_DUAL */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "dual" },
/* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, /* ATTR_ENDPOINT */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" },
/* ATTR_ENTRY_ORDINAL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" }, /* ATTR_ENTRY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" },
/* ATTR_ENTRY_STRING */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "entry" },
/* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" },
/* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "handle" }, /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "handle" },
/* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpcontext" }, /* ATTR_HELPCONTEXT */ { 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, "helpcontext" },
......
...@@ -82,16 +82,14 @@ enum attr_type ...@@ -82,16 +82,14 @@ enum attr_type
ATTR_CONTROL, ATTR_CONTROL,
ATTR_DEFAULT, ATTR_DEFAULT,
ATTR_DEFAULTCOLLELEM, ATTR_DEFAULTCOLLELEM,
ATTR_DEFAULTVALUE_EXPR, ATTR_DEFAULTVALUE,
ATTR_DEFAULTVALUE_STRING,
ATTR_DEFAULTVTABLE, ATTR_DEFAULTVTABLE,
ATTR_DISPINTERFACE, ATTR_DISPINTERFACE,
ATTR_DISPLAYBIND, ATTR_DISPLAYBIND,
ATTR_DLLNAME, ATTR_DLLNAME,
ATTR_DUAL, ATTR_DUAL,
ATTR_ENDPOINT, ATTR_ENDPOINT,
ATTR_ENTRY_ORDINAL, ATTR_ENTRY,
ATTR_ENTRY_STRING,
ATTR_EXPLICIT_HANDLE, ATTR_EXPLICIT_HANDLE,
ATTR_HANDLE, ATTR_HANDLE,
ATTR_HELPCONTEXT, ATTR_HELPCONTEXT,
...@@ -180,6 +178,8 @@ enum expr_type ...@@ -180,6 +178,8 @@ enum expr_type
EXPR_LESSEQL, EXPR_LESSEQL,
EXPR_LOGNOT, EXPR_LOGNOT,
EXPR_POS, EXPR_POS,
EXPR_STRLIT,
EXPR_WSTRLIT,
}; };
enum type_kind enum type_kind
......
...@@ -1183,7 +1183,7 @@ static unsigned long get_ulong_val(unsigned long val, int vt) ...@@ -1183,7 +1183,7 @@ static unsigned long get_ulong_val(unsigned long val, int vt)
return val; return val;
} }
static void write_value(msft_typelib_t* typelib, int *out, int vt, void *value) static void write_value(msft_typelib_t* typelib, int *out, int vt, const void *value)
{ {
switch(vt) { switch(vt) {
case VT_I2: case VT_I2:
...@@ -1199,7 +1199,7 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, void *value) ...@@ -1199,7 +1199,7 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, void *value)
case VT_HRESULT: case VT_HRESULT:
case VT_PTR: case VT_PTR:
{ {
const unsigned long lv = get_ulong_val(*(unsigned long*)value, vt); const unsigned long lv = get_ulong_val(*(const unsigned long*)value, vt);
if((lv & 0x3ffffff) == lv) { if((lv & 0x3ffffff) == lv) {
*out = 0x80000000; *out = 0x80000000;
*out |= vt << 26; *out |= vt << 26;
...@@ -1215,7 +1215,7 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, void *value) ...@@ -1215,7 +1215,7 @@ static void write_value(msft_typelib_t* typelib, int *out, int vt, void *value)
} }
case VT_BSTR: case VT_BSTR:
{ {
char *s = (char *) value; const char *s = (const char *) value;
int len = strlen(s), seg_len = (len + 6 + 3) & ~0x3; int len = strlen(s), seg_len = (len + 6 + 3) & ~0x3;
int offset = ctl2_alloc_segment(typelib, MSFT_SEG_CUSTDATA, seg_len, 0); int offset = ctl2_alloc_segment(typelib, MSFT_SEG_CUSTDATA, seg_len, 0);
*((unsigned short *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset]) = vt; *((unsigned short *)&typelib->typelib_segment_data[MSFT_SEG_CUSTDATA][offset]) = vt;
...@@ -1305,7 +1305,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int ...@@ -1305,7 +1305,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int
{ {
num_params++; num_params++;
if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) { if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) {
if(attr->type == ATTR_DEFAULTVALUE_EXPR || attr->type == ATTR_DEFAULTVALUE_STRING) if(attr->type == ATTR_DEFAULTVALUE)
num_defaults++; num_defaults++;
else if(attr->type == ATTR_OPTIONAL) else if(attr->type == ATTR_OPTIONAL)
num_optional++; num_optional++;
...@@ -1329,14 +1329,14 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int ...@@ -1329,14 +1329,14 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int
case ATTR_DISPLAYBIND: case ATTR_DISPLAYBIND:
funcflags |= 0x10; /* FUNCFLAG_FDISPLAYBIND */ funcflags |= 0x10; /* FUNCFLAG_FDISPLAYBIND */
break; break;
case ATTR_ENTRY_ORDINAL: case ATTR_ENTRY:
extra_attr = max(extra_attr, 3); extra_attr = max(extra_attr, 3);
entry = expr->cval; if (expr->type == EXPR_STRLIT || expr->type == EXPR_WSTRLIT)
entry_is_ord = 1; entry = ctl2_alloc_string(typeinfo->typelib, attr->u.pval);
break; else {
case ATTR_ENTRY_STRING: entry = expr->cval;
extra_attr = max(extra_attr, 3); entry_is_ord = 1;
entry = ctl2_alloc_string(typeinfo->typelib, attr->u.pval); }
break; break;
case ATTR_HELPCONTEXT: case ATTR_HELPCONTEXT:
extra_attr = max(extra_attr, 1); extra_attr = max(extra_attr, 1);
...@@ -1477,7 +1477,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int ...@@ -1477,7 +1477,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int
encode_var(typeinfo->typelib, arg->type, arg, paramdata, NULL, NULL, &decoded_size); encode_var(typeinfo->typelib, arg->type, arg, paramdata, NULL, NULL, &decoded_size);
if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) { if (arg->attrs) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) {
switch(attr->type) { switch(attr->type) {
case ATTR_DEFAULTVALUE_EXPR: case ATTR_DEFAULTVALUE:
{ {
int vt; int vt;
expr_t *expr = (expr_t *)attr->u.pval; expr_t *expr = (expr_t *)attr->u.pval;
...@@ -1486,21 +1486,17 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int ...@@ -1486,21 +1486,17 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int
else else
vt = get_type_vt(arg->type); vt = get_type_vt(arg->type);
paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */ paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */
chat("default value %ld\n", expr->cval); if (expr->type == EXPR_STRLIT || expr->type == EXPR_WSTRLIT)
write_value(typeinfo->typelib, defaultdata, vt, &expr->cval); {
break; if (vt != VT_BSTR) error("string default value applied to non-string type\n");
} chat("default value '%s'\n", expr->u.sval);
case ATTR_DEFAULTVALUE_STRING: write_value(typeinfo->typelib, defaultdata, vt, expr->u.sval);
{ }
char *s = (char *)attr->u.pval;
int vt;
if (arg->type->type == RPC_FC_ENUM16)
vt = VT_INT;
else else
vt = get_type_vt(arg->type); {
paramflags |= 0x30; /* PARAMFLAG_FHASDEFAULT | PARAMFLAG_FOPT */ chat("default value %ld\n", expr->cval);
chat("default value '%s'\n", s); write_value(typeinfo->typelib, defaultdata, vt, &expr->cval);
write_value(typeinfo->typelib, defaultdata, vt, s); }
break; break;
} }
case ATTR_IN: case ATTR_IN:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment