From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/parser.y | 273 ++++++++++++++++++++++---------------------- 1 file changed, 138 insertions(+), 135 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index e92bd277771..895b995d9fb 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -621,124 +621,127 @@ activatable_attr: ;
attribute - : %empty { $$ = NULL; } - | tACTIVATABLE '(' activatable_attr ')' { $$ = make_attrp(ATTR_ACTIVATABLE, $3); } - | tAGGREGATABLE { $$ = make_attr(ATTR_AGGREGATABLE); } - | tANNOTATION '(' aSTRING ')' { $$ = make_attrp(ATTR_ANNOTATION, $3); } - | tAPPOBJECT { $$ = make_attr(ATTR_APPOBJECT); } - | tASYNC { $$ = make_attr(ATTR_ASYNC); } - | tAUTOHANDLE { $$ = make_attr(ATTR_AUTO_HANDLE); } - | tBINDABLE { $$ = make_attr(ATTR_BINDABLE); } - | tBROADCAST { $$ = make_attr(ATTR_BROADCAST); } - | tCALLAS '(' ident ')' { $$ = make_attrp(ATTR_CALLAS, $3); } - | tCASE '(' expr_list_int_const ')' { $$ = make_attrp(ATTR_CASE, $3); } - | tCODE { $$ = make_attr(ATTR_CODE); } - | tCOMMSTATUS { $$ = make_attr(ATTR_COMMSTATUS); } - | tCONTEXTHANDLE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); } - | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } - | tCONTEXTHANDLESERIALIZE { $$ = make_attrv(ATTR_CONTEXTHANDLE, 0); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } - | tCONTRACT '(' contract_req ')' { $$ = make_attrp(ATTR_CONTRACT, $3); } - | tCONTRACTVERSION '(' contract_ver ')' { $$ = make_attrv(ATTR_CONTRACTVERSION, $3); } - | tCONTROL { $$ = make_attr(ATTR_CONTROL); } - | tCUSTOM '(' aUUID ',' expr_const ')' { $$ = make_custom_attr($3, $5); } - | tDECODE { $$ = make_attr(ATTR_DECODE); } - | tDEFAULT { $$ = make_attr(ATTR_DEFAULT); } - | tDEFAULTBIND { $$ = make_attr(ATTR_DEFAULTBIND); } - | tDEFAULTCOLLELEM { $$ = make_attr(ATTR_DEFAULTCOLLELEM); } - | tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp(ATTR_DEFAULTVALUE, $3); } - | tDEFAULTVTABLE { $$ = make_attr(ATTR_DEFAULTVTABLE); } - | tDISABLECONSISTENCYCHECK { $$ = make_attr(ATTR_DISABLECONSISTENCYCHECK); } - | tDISPLAYBIND { $$ = make_attr(ATTR_DISPLAYBIND); } - | tDLLNAME '(' aSTRING ')' { $$ = make_attrp(ATTR_DLLNAME, $3); } - | tDUAL { $$ = make_attr(ATTR_DUAL); } - | tENABLEALLOCATE { $$ = make_attr(ATTR_ENABLEALLOCATE); } - | tENCODE { $$ = make_attr(ATTR_ENCODE); } - | tENDPOINT '(' str_list ')' { $$ = make_attrp(ATTR_ENDPOINT, $3); } - | tENTRY '(' expr_const ')' { $$ = make_attrp(ATTR_ENTRY, $3); } - | tEVENTADD { $$ = make_attr(ATTR_EVENTADD); } - | tEVENTREMOVE { $$ = make_attr(ATTR_EVENTREMOVE); } - | tEXCLUSIVETO '(' decl_spec ')' { if ($3->type->type_type != TYPE_RUNTIMECLASS) - error_loc("type %s is not a runtimeclass\n", $3->type->name); - $$ = make_attrp(ATTR_EXCLUSIVETO, $3->type); } - | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } - | tFAULTSTATUS { $$ = make_attr(ATTR_FAULTSTATUS); } - | tFLAGS { $$ = make_attr(ATTR_FLAGS); } - | tFORCEALLOCATE { $$ = make_attr(ATTR_FORCEALLOCATE); } - | tHANDLE { $$ = make_attr(ATTR_HANDLE); } - | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPCONTEXT, $3); } - | tHELPFILE '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPFILE, $3); } - | tHELPSTRING '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRING, $3); } - | tHELPSTRINGCONTEXT '(' expr_int_const ')' { $$ = make_attrp(ATTR_HELPSTRINGCONTEXT, $3); } - | tHELPSTRINGDLL '(' aSTRING ')' { $$ = make_attrp(ATTR_HELPSTRINGDLL, $3); } - | tHIDDEN { $$ = make_attr(ATTR_HIDDEN); } - | tID '(' expr_int_const ')' { $$ = make_attrp(ATTR_ID, $3); } - | tIDEMPOTENT { $$ = make_attr(ATTR_IDEMPOTENT); } - | tIGNORE { $$ = make_attr(ATTR_IGNORE); } - | tIIDIS '(' expr ')' { $$ = make_attrp(ATTR_IIDIS, $3); } - | tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); } - | tIMPLICITHANDLE '(' arg ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $3); } - | tIN { $$ = make_attr(ATTR_IN); } - | tINPUTSYNC { $$ = make_attr(ATTR_INPUTSYNC); } - | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp(ATTR_LENGTHIS, $3); } - | tLCID '(' expr_int_const ')' { $$ = make_attrp(ATTR_LIBLCID, $3); } - | tLCID { $$ = make_attr(ATTR_PARAMLCID); } - | tLICENSED { $$ = make_attr(ATTR_LICENSED); } - | tLOCAL { $$ = make_attr(ATTR_LOCAL); } - | tMARSHALINGBEHAVIOR '(' marshaling_behavior ')' - { $$ = make_attrv(ATTR_MARSHALING_BEHAVIOR, $3); } - | tMAYBE { $$ = make_attr(ATTR_MAYBE); } - | tMESSAGE { $$ = make_attr(ATTR_MESSAGE); } - | tNOCODE { $$ = make_attr(ATTR_NOCODE); } - | tNONBROWSABLE { $$ = make_attr(ATTR_NONBROWSABLE); } - | tNONCREATABLE { $$ = make_attr(ATTR_NONCREATABLE); } - | tNONEXTENSIBLE { $$ = make_attr(ATTR_NONEXTENSIBLE); } - | tNOTIFY { $$ = make_attr(ATTR_NOTIFY); } - | tNOTIFYFLAG { $$ = make_attr(ATTR_NOTIFYFLAG); } - | tOBJECT { $$ = make_attr(ATTR_OBJECT); } - | tODL { $$ = make_attr(ATTR_ODL); } - | tOLEAUTOMATION { $$ = make_attr(ATTR_OLEAUTOMATION); } - | tOPTIMIZE '(' aSTRING ')' { $$ = make_attrp(ATTR_OPTIMIZE, $3); } - | tOPTIONAL { $$ = make_attr(ATTR_OPTIONAL); } - | tOUT { $$ = make_attr(ATTR_OUT); } - | tOVERLOAD '(' aSTRING ')' { $$ = make_attrp(ATTR_OVERLOAD, $3); } - | tPARTIALIGNORE { $$ = make_attr(ATTR_PARTIALIGNORE); } - | tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv(ATTR_POINTERDEFAULT, $3); } - | tPROGID '(' aSTRING ')' { $$ = make_attrp(ATTR_PROGID, $3); } - | tPROPGET { $$ = make_attr(ATTR_PROPGET); } - | tPROPPUT { $$ = make_attr(ATTR_PROPPUT); } - | tPROPPUTREF { $$ = make_attr(ATTR_PROPPUTREF); } - | tPROXY { $$ = make_attr(ATTR_PROXY); } - | tPUBLIC { $$ = make_attr(ATTR_PUBLIC); } - | tRANGE '(' expr_int_const ',' expr_int_const ')' - { expr_list_t *list = append_expr( NULL, $3 ); - list = append_expr( list, $5 ); - $$ = make_attrp(ATTR_RANGE, list); } - | tREADONLY { $$ = make_attr(ATTR_READONLY); } - | tREPRESENTAS '(' type ')' { $$ = make_attrp(ATTR_REPRESENTAS, $3); } - | tREQUESTEDIT { $$ = make_attr(ATTR_REQUESTEDIT); } - | tRESTRICTED { $$ = make_attr(ATTR_RESTRICTED); } - | tRETVAL { $$ = make_attr(ATTR_RETVAL); } - | tSIZEIS '(' m_exprs ')' { $$ = make_attrp(ATTR_SIZEIS, $3); } - | tSOURCE { $$ = make_attr(ATTR_SOURCE); } - | tSTATIC '(' static_attr ')' { $$ = make_attrp(ATTR_STATIC, $3); } - | tSTRICTCONTEXTHANDLE { $$ = make_attr(ATTR_STRICTCONTEXTHANDLE); } - | tSTRING { $$ = make_attr(ATTR_STRING); } - | tSWITCHIS '(' expr ')' { $$ = make_attrp(ATTR_SWITCHIS, $3); } - | tSWITCHTYPE '(' type ')' { $$ = make_attrp(ATTR_SWITCHTYPE, $3); } - | tTRANSMITAS '(' type ')' { $$ = make_attrp(ATTR_TRANSMITAS, $3); } - | tTHREADING '(' threading_type ')' { $$ = make_attrv(ATTR_THREADING, $3); } - | tUIDEFAULT { $$ = make_attr(ATTR_UIDEFAULT); } - | tUSESGETLASTERROR { $$ = make_attr(ATTR_USESGETLASTERROR); } - | tUSERMARSHAL '(' type ')' { $$ = make_attrp(ATTR_USERMARSHAL, $3); } - | tUUID '(' aUUID ')' { $$ = make_attrp(ATTR_UUID, $3); } - | tASYNCUUID '(' aUUID ')' { $$ = make_attrp(ATTR_ASYNCUUID, $3); } - | tV1ENUM { $$ = make_attr(ATTR_V1ENUM); } - | tVARARG { $$ = make_attr(ATTR_VARARG); } - | tVERSION '(' version ')' { $$ = make_attrv(ATTR_VERSION, $3); } - | tVIPROGID '(' aSTRING ')' { $$ = make_attrp(ATTR_VIPROGID, $3); } - | tWIREMARSHAL '(' type ')' { $$ = make_attrp(ATTR_WIREMARSHAL, $3); } - | pointer_type { $$ = make_attrv(ATTR_POINTERTYPE, $1); } - ; + : %empty { $$ = NULL; } + | tACTIVATABLE '(' activatable_attr ')' { $$ = make_attrp( ATTR_ACTIVATABLE, $3 ); } + | tAGGREGATABLE { $$ = make_attr( ATTR_AGGREGATABLE ); } + | tANNOTATION '(' aSTRING ')' { $$ = make_attrp( ATTR_ANNOTATION, $3 ); } + | tAPPOBJECT { $$ = make_attr( ATTR_APPOBJECT ); } + | tASYNC { $$ = make_attr( ATTR_ASYNC ); } + | tAUTOHANDLE { $$ = make_attr( ATTR_AUTO_HANDLE ); } + | tBINDABLE { $$ = make_attr( ATTR_BINDABLE ); } + | tBROADCAST { $$ = make_attr( ATTR_BROADCAST ); } + | tCALLAS '(' ident ')' { $$ = make_attrp( ATTR_CALLAS, $3 ); } + | tCASE '(' expr_list_int_const ')' { $$ = make_attrp( ATTR_CASE, $3 ); } + | tCODE { $$ = make_attr( ATTR_CODE ); } + | tCOMMSTATUS { $$ = make_attr( ATTR_COMMSTATUS ); } + | tCONTEXTHANDLE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); } + | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } + | tCONTEXTHANDLESERIALIZE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } + | tCONTRACT '(' contract_req ')' { $$ = make_attrp( ATTR_CONTRACT, $3 ); } + | tCONTRACTVERSION '(' contract_ver ')' { $$ = make_attrv( ATTR_CONTRACTVERSION, $3 ); } + | tCONTROL { $$ = make_attr( ATTR_CONTROL ); } + | tCUSTOM '(' aUUID ',' expr_const ')' { $$ = make_custom_attr( $3, $5 ); } + | tDECODE { $$ = make_attr( ATTR_DECODE ); } + | tDEFAULT { $$ = make_attr( ATTR_DEFAULT ); } + | tDEFAULTBIND { $$ = make_attr( ATTR_DEFAULTBIND ); } + | tDEFAULTCOLLELEM { $$ = make_attr( ATTR_DEFAULTCOLLELEM ); } + | tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp( ATTR_DEFAULTVALUE, $3 ); } + | tDEFAULTVTABLE { $$ = make_attr( ATTR_DEFAULTVTABLE ); } + | tDISABLECONSISTENCYCHECK { $$ = make_attr( ATTR_DISABLECONSISTENCYCHECK ); } + | tDISPLAYBIND { $$ = make_attr( ATTR_DISPLAYBIND ); } + | tDLLNAME '(' aSTRING ')' { $$ = make_attrp( ATTR_DLLNAME, $3 ); } + | tDUAL { $$ = make_attr( ATTR_DUAL ); } + | tENABLEALLOCATE { $$ = make_attr( ATTR_ENABLEALLOCATE ); } + | tENCODE { $$ = make_attr( ATTR_ENCODE ); } + | tENDPOINT '(' str_list ')' { $$ = make_attrp( ATTR_ENDPOINT, $3 ); } + | tENTRY '(' expr_const ')' { $$ = make_attrp( ATTR_ENTRY, $3 ); } + | tEVENTADD { $$ = make_attr( ATTR_EVENTADD ); } + | tEVENTREMOVE { $$ = make_attr( ATTR_EVENTREMOVE ); } + | tEXCLUSIVETO '(' decl_spec ')' { if ($3->type->type_type != TYPE_RUNTIMECLASS) + error_loc( "type %s is not a runtimeclass\n", $3->type->name ); + $$ = make_attrp( ATTR_EXCLUSIVETO, $3->type ); + } + | tEXPLICITHANDLE { $$ = make_attr( ATTR_EXPLICIT_HANDLE ); } + | tFAULTSTATUS { $$ = make_attr( ATTR_FAULTSTATUS ); } + | tFLAGS { $$ = make_attr( ATTR_FLAGS ); } + | tFORCEALLOCATE { $$ = make_attr( ATTR_FORCEALLOCATE ); } + | tHANDLE { $$ = make_attr( ATTR_HANDLE ); } + | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp( ATTR_HELPCONTEXT, $3 ); } + | tHELPFILE '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPFILE, $3 ); } + | tHELPSTRING '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPSTRING, $3 ); } + | tHELPSTRINGCONTEXT '(' expr_int_const ')' + { $$ = make_attrp( ATTR_HELPSTRINGCONTEXT, $3 ); } + | tHELPSTRINGDLL '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPSTRINGDLL, $3 ); } + | tHIDDEN { $$ = make_attr( ATTR_HIDDEN ); } + | tID '(' expr_int_const ')' { $$ = make_attrp( ATTR_ID, $3 ); } + | tIDEMPOTENT { $$ = make_attr( ATTR_IDEMPOTENT ); } + | tIGNORE { $$ = make_attr( ATTR_IGNORE ); } + | tIIDIS '(' expr ')' { $$ = make_attrp( ATTR_IIDIS, $3 ); } + | tIMMEDIATEBIND { $$ = make_attr( ATTR_IMMEDIATEBIND ); } + | tIMPLICITHANDLE '(' arg ')' { $$ = make_attrp( ATTR_IMPLICIT_HANDLE, $3 ); } + | tIN { $$ = make_attr( ATTR_IN ); } + | tINPUTSYNC { $$ = make_attr( ATTR_INPUTSYNC ); } + | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp( ATTR_LENGTHIS, $3 ); } + | tLCID '(' expr_int_const ')' { $$ = make_attrp( ATTR_LIBLCID, $3 ); } + | tLCID { $$ = make_attr( ATTR_PARAMLCID ); } + | tLICENSED { $$ = make_attr( ATTR_LICENSED ); } + | tLOCAL { $$ = make_attr( ATTR_LOCAL ); } + | tMARSHALINGBEHAVIOR '(' marshaling_behavior ')' + { $$ = make_attrv( ATTR_MARSHALING_BEHAVIOR, $3 ); } + | tMAYBE { $$ = make_attr( ATTR_MAYBE ); } + | tMESSAGE { $$ = make_attr( ATTR_MESSAGE ); } + | tNOCODE { $$ = make_attr( ATTR_NOCODE ); } + | tNONBROWSABLE { $$ = make_attr( ATTR_NONBROWSABLE ); } + | tNONCREATABLE { $$ = make_attr( ATTR_NONCREATABLE ); } + | tNONEXTENSIBLE { $$ = make_attr( ATTR_NONEXTENSIBLE ); } + | tNOTIFY { $$ = make_attr( ATTR_NOTIFY ); } + | tNOTIFYFLAG { $$ = make_attr( ATTR_NOTIFYFLAG ); } + | tOBJECT { $$ = make_attr( ATTR_OBJECT ); } + | tODL { $$ = make_attr( ATTR_ODL ); } + | tOLEAUTOMATION { $$ = make_attr( ATTR_OLEAUTOMATION ); } + | tOPTIMIZE '(' aSTRING ')' { $$ = make_attrp( ATTR_OPTIMIZE, $3 ); } + | tOPTIONAL { $$ = make_attr( ATTR_OPTIONAL ); } + | tOUT { $$ = make_attr( ATTR_OUT ); } + | tOVERLOAD '(' aSTRING ')' { $$ = make_attrp( ATTR_OVERLOAD, $3 ); } + | tPARTIALIGNORE { $$ = make_attr( ATTR_PARTIALIGNORE ); } + | tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv( ATTR_POINTERDEFAULT, $3 ); } + | tPROGID '(' aSTRING ')' { $$ = make_attrp( ATTR_PROGID, $3 ); } + | tPROPGET { $$ = make_attr( ATTR_PROPGET ); } + | tPROPPUT { $$ = make_attr( ATTR_PROPPUT ); } + | tPROPPUTREF { $$ = make_attr( ATTR_PROPPUTREF ); } + | tPROXY { $$ = make_attr( ATTR_PROXY ); } + | tPUBLIC { $$ = make_attr( ATTR_PUBLIC ); } + | tRANGE '(' expr_int_const ',' expr_int_const ')' + { expr_list_t *list = append_expr( NULL, $3 ); + list = append_expr( list, $5 ); + $$ = make_attrp( ATTR_RANGE, list ); + } + | tREADONLY { $$ = make_attr( ATTR_READONLY ); } + | tREPRESENTAS '(' type ')' { $$ = make_attrp( ATTR_REPRESENTAS, $3 ); } + | tREQUESTEDIT { $$ = make_attr( ATTR_REQUESTEDIT ); } + | tRESTRICTED { $$ = make_attr( ATTR_RESTRICTED ); } + | tRETVAL { $$ = make_attr( ATTR_RETVAL ); } + | tSIZEIS '(' m_exprs ')' { $$ = make_attrp( ATTR_SIZEIS, $3 ); } + | tSOURCE { $$ = make_attr( ATTR_SOURCE ); } + | tSTATIC '(' static_attr ')' { $$ = make_attrp( ATTR_STATIC, $3 ); } + | tSTRICTCONTEXTHANDLE { $$ = make_attr( ATTR_STRICTCONTEXTHANDLE ); } + | tSTRING { $$ = make_attr( ATTR_STRING ); } + | tSWITCHIS '(' expr ')' { $$ = make_attrp( ATTR_SWITCHIS, $3 ); } + | tSWITCHTYPE '(' type ')' { $$ = make_attrp( ATTR_SWITCHTYPE, $3 ); } + | tTRANSMITAS '(' type ')' { $$ = make_attrp( ATTR_TRANSMITAS, $3 ); } + | tTHREADING '(' threading_type ')' { $$ = make_attrv( ATTR_THREADING, $3 ); } + | tUIDEFAULT { $$ = make_attr( ATTR_UIDEFAULT ); } + | tUSESGETLASTERROR { $$ = make_attr( ATTR_USESGETLASTERROR ); } + | tUSERMARSHAL '(' type ')' { $$ = make_attrp( ATTR_USERMARSHAL, $3 ); } + | tUUID '(' aUUID ')' { $$ = make_attrp( ATTR_UUID, $3 ); } + | tASYNCUUID '(' aUUID ')' { $$ = make_attrp( ATTR_ASYNCUUID, $3 ); } + | tV1ENUM { $$ = make_attr( ATTR_V1ENUM ); } + | tVARARG { $$ = make_attr( ATTR_VARARG ); } + | tVERSION '(' version ')' { $$ = make_attrv( ATTR_VERSION, $3 ); } + | tVIPROGID '(' aSTRING ')' { $$ = make_attrp( ATTR_VIPROGID, $3 ); } + | tWIREMARSHAL '(' type ')' { $$ = make_attrp( ATTR_WIREMARSHAL, $3 ); } + | pointer_type { $$ = make_attrv( ATTR_POINTERTYPE, $1 ); } + ;
callconv: tCDECL | tFASTCALL @@ -751,15 +754,15 @@ cases | cases case { $$ = append_var( $1, $2 ); } ;
-case: tCASE expr_int_const ':' union_field { attr_t *a = make_attrp(ATTR_CASE, append_expr( NULL, $2 )); - $$ = $4; if (!$$) $$ = make_var(NULL); - $$->attrs = append_attr( $$->attrs, a ); - } - | tDEFAULT ':' union_field { attr_t *a = make_attr(ATTR_DEFAULT); - $$ = $3; if (!$$) $$ = make_var(NULL); - $$->attrs = append_attr( $$->attrs, a ); - } - ; +case : tCASE expr_int_const ':' union_field { attr_t *a = make_attrp( ATTR_CASE, append_expr( NULL, $2 ) ); + $$ = $4; if (!$$) $$ = make_var( NULL ); + $$->attrs = append_attr( $$->attrs, a ); + } + | tDEFAULT ':' union_field { attr_t *a = make_attr( ATTR_DEFAULT ); + $$ = $3; if (!$$) $$ = make_var( NULL ); + $$->attrs = append_attr( $$->attrs, a ); + } + ;
enums : %empty { $$ = NULL; } @@ -1040,8 +1043,8 @@ class_interface: dispinterface: tDISPINTERFACE typename { $$ = type_dispinterface_declare($2); } ;
-dispattributes: attributes { $$ = append_attr($1, make_attr(ATTR_DISPINTERFACE)); } - ; +dispattributes: attributes { $$ = append_attr( $1, make_attr( ATTR_DISPINTERFACE ) ); } + ;
dispint_props: tPROPERTIES ':' { $$ = NULL; } | dispint_props s_field ';' { $$ = append_var( $1, $2 ); } @@ -1386,12 +1389,12 @@ acf_attribute_list ;
acf_attribute - : tALLOCATE '(' allocate_option_list ')' - { $$ = make_attrv(ATTR_ALLOCATE, $3); } - | tENCODE { $$ = make_attr(ATTR_ENCODE); } - | tDECODE { $$ = make_attr(ATTR_DECODE); } - | tEXPLICITHANDLE { $$ = make_attr(ATTR_EXPLICIT_HANDLE); } - ; + : tALLOCATE '(' allocate_option_list ')' + { $$ = make_attrv( ATTR_ALLOCATE, $3 ); } + | tENCODE { $$ = make_attr( ATTR_ENCODE ); } + | tDECODE { $$ = make_attr( ATTR_DECODE ); } + | tEXPLICITHANDLE { $$ = make_attr( ATTR_EXPLICIT_HANDLE ); } + ;
allocate_option_list : allocate_option { $$ = $1; }
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/Makefile.in | 1 + tools/widl/attribute.c | 556 +++++++++++++++++++++++++++++++++++++++++ tools/widl/header.c | 57 ----- tools/widl/header.h | 4 - tools/widl/parser.y | 481 ----------------------------------- tools/widl/typegen.c | 13 - tools/widl/typetree.h | 15 +- tools/widl/widl.h | 38 +++ 8 files changed, 600 insertions(+), 565 deletions(-) create mode 100644 tools/widl/attribute.c
diff --git a/tools/widl/Makefile.in b/tools/widl/Makefile.in index 32d27060c22..d18c127adb0 100644 --- a/tools/widl/Makefile.in +++ b/tools/widl/Makefile.in @@ -2,6 +2,7 @@ PROGRAMS = widl PARENTSRC = ../wrc
C_SRCS = \ + attribute.c \ client.c \ expr.c \ hash.c \ diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c new file mode 100644 index 00000000000..35d4e8c90a1 --- /dev/null +++ b/tools/widl/attribute.c @@ -0,0 +1,556 @@ +/* + * Copyright 2002 Ove Kaaven + * Copyright 2006-2008 Robert Shearman + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "config.h" + +#include "widl.h" +#include "typetree.h" + +#include "parser.tab.h" + +attr_t *make_attr( enum attr_type attr_type ) +{ + attr_t *a = xmalloc( sizeof(attr_t) ); + a->type = attr_type; + a->u.ival = 0; + return a; +} + +attr_t *make_attrv( enum attr_type attr_type, unsigned int val ) +{ + attr_t *a = xmalloc( sizeof(attr_t) ); + a->type = attr_type; + a->u.ival = val; + return a; +} + +attr_t *make_attrp( enum attr_type attr_type, void *val ) +{ + attr_t *a = xmalloc( sizeof(attr_t) ); + a->type = attr_type; + a->u.pval = val; + return a; +} + +attr_t *make_custom_attr( struct uuid *id, expr_t *pval ) +{ + attr_t *a = xmalloc( sizeof(attr_t) ); + attr_custdata_t *cstdata = xmalloc( sizeof(attr_custdata_t) ); + a->type = ATTR_CUSTOM; + cstdata->id = *id; + cstdata->pval = pval; + a->u.pval = cstdata; + return a; +} + +int is_attr( const attr_list_t *list, enum attr_type attr_type ) +{ + const attr_t *attr; + if (!list) return 0; + LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) + if (attr->type == attr_type) return 1; + return 0; +} + +int is_ptrchain_attr( const var_t *var, enum attr_type attr_type ) +{ + type_t *type = var->declspec.type; + if (is_attr( var->attrs, attr_type )) return 1; + for (;;) + { + if (is_attr( type->attrs, attr_type )) return 1; + else if (type_is_alias( type )) type = type_alias_get_aliasee_type( type ); + else if (type_is_ptr( type )) type = type_pointer_get_ref_type( type ); + else return 0; + } +} + +int is_aliaschain_attr( const type_t *type, enum attr_type attr_type ) +{ + const type_t *t = type; + for (;;) + { + if (is_attr( t->attrs, attr_type )) return 1; + else if (type_is_alias( t )) t = type_alias_get_aliasee_type( t ); + else return 0; + } +} + +unsigned int get_attrv( const attr_list_t *list, enum attr_type attr_type ) +{ + const attr_t *attr; + if (!list) return 0; + LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) + if (attr->type == attr_type) return attr->u.ival; + return 0; +} + +void *get_attrp( const attr_list_t *list, enum attr_type attr_type ) +{ + const attr_t *attr; + if (!list) return NULL; + LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) + if (attr->type == attr_type) return attr->u.pval; + return NULL; +} + +void *get_aliaschain_attrp( const type_t *type, enum attr_type attr_type ) +{ + for (;;) + { + if (is_attr( type->attrs, attr_type )) return get_attrp( type->attrs, attr_type ); + if (!type_is_alias( type )) return NULL; + type = type_alias_get_aliasee_type( type ); + } +} + +struct allowed_attr +{ + unsigned int dce_compatible : 1; + unsigned int acf : 1; + unsigned int multiple : 1; + + unsigned int on_interface : 1; + unsigned int on_function : 1; + unsigned int on_arg : 1; + unsigned int on_type : 1; + unsigned int on_enum : 1; + unsigned int on_enum_member : 1; + unsigned int on_struct : 2; + unsigned int on_union : 1; + unsigned int on_field : 1; + unsigned int on_library : 1; + unsigned int on_dispinterface : 1; + unsigned int on_module : 1; + unsigned int on_coclass : 1; + unsigned int on_apicontract : 1; + unsigned int on_runtimeclass : 1; + const char *display_name; +}; + +struct allowed_attr allowed_attr[] = +{ + /* attr { D ACF M I Fn ARG T En Enm St Un Fi L DI M C AC R <display name> } */ + /* ATTR_ACTIVATABLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "activatable" }, + /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "aggregatable" }, + /* ATTR_ALLOCATE */ { 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "allocate" }, + /* ATTR_ANNOTATION */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" }, + /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "appobject" }, + /* ATTR_ASYNC */ { 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, + /* ATTR_ASYNCUUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "async_uuid" }, + /* ATTR_AUTO_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, + /* ATTR_BINDABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bindable" }, + /* ATTR_BROADCAST */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, + /* ATTR_CALLAS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, + /* ATTR_CALLCONV */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, + /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "case" }, + /* ATTR_CODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" }, + /* ATTR_COMMSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" }, + /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, + /* ATTR_CONTRACT */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, "contract" }, + /* ATTR_CONTRACTVERSION */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "contractversion" }, + /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, "control" }, + /* ATTR_CUSTOM */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, "custom" }, + /* ATTR_DECODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "decode" }, + /* ATTR_DEFAULT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "default" }, + /* ATTR_DEFAULTBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultbind" }, + /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, + /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, + /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "defaultvtable" }, + /* ATTR_DISABLECONSISTENCYCHECK */{ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "disable_consistency_check" }, + /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, NULL }, + /* ATTR_DISPLAYBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, + /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "dllname" }, + /* ATTR_DUAL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, + /* ATTR_ENABLEALLOCATE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "enable_allocate" }, + /* ATTR_ENCODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "encode" }, + /* ATTR_ENDPOINT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, + /* ATTR_ENTRY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, + /* ATTR_EVENTADD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventadd" }, + /* ATTR_EVENTREMOVE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventremove" }, + /* ATTR_EXCLUSIVETO */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "exclusive_to" }, + /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, + /* ATTR_FAULTSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, + /* ATTR_FLAGS */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "flags" }, + /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" }, + /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, + /* ATTR_HELPCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpcontext" }, + /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpfile" }, + /* ATTR_HELPSTRING */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstring" }, + /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstringcontext" }, + /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpstringdll" }, + /* ATTR_HIDDEN */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, "hidden" }, + /* ATTR_ID */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, "id" }, + /* ATTR_IDEMPOTENT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, + /* ATTR_IGNORE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ignore" }, + /* ATTR_IIDIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "iid_is" }, + /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, + /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, + /* ATTR_IN */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" }, + /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, + /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "length_is" }, + /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "lcid" }, + /* ATTR_LICENSED */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "licensed" }, + /* ATTR_LOCAL */ { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, + /* ATTR_MARSHALING_BEHAVIOR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "marshaling_behavior" }, + /* ATTR_MAYBE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" }, + /* ATTR_MESSAGE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" }, + /* ATTR_NOCODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" }, + /* ATTR_NONBROWSABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, + /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "noncreatable" }, + /* ATTR_NONEXTENSIBLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, + /* ATTR_NOTIFY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify" }, + /* ATTR_NOTIFYFLAG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify_flag" }, + /* ATTR_OBJECT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, + /* ATTR_ODL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "odl" }, + /* ATTR_OLEAUTOMATION */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, + /* ATTR_OPTIMIZE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optimize" }, + /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, + /* ATTR_OUT */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, + /* ATTR_OVERLOAD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "overload" }, + /* ATTR_PARAMLCID */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "lcid" }, + /* ATTR_PARTIALIGNORE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "partial_ignore" }, + /* ATTR_POINTERDEFAULT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, + /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ref, unique or ptr" }, + /* ATTR_PROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "progid" }, + /* ATTR_PROPGET */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, + /* ATTR_PROPPUT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, + /* ATTR_PROPPUTREF */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, + /* ATTR_PROXY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "proxy" }, + /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, + /* ATTR_RANGE */ { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "range" }, + /* ATTR_READONLY */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "readonly" }, + /* ATTR_REPRESENTAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "represent_as" }, + /* ATTR_REQUESTEDIT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, + /* ATTR_RESTRICTED */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, "restricted" }, + /* ATTR_RETVAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, + /* ATTR_SIZEIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "size_is" }, + /* ATTR_SOURCE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "source" }, + /* ATTR_STATIC */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "static" }, + /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, + /* ATTR_STRING */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "string" }, + /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_is" }, + /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_type" }, + /* ATTR_THREADING */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, "threading" }, + /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, + /* ATTR_UIDEFAULT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "uidefault" }, + /* ATTR_USESGETLASTERROR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "usesgetlasterror" }, + /* ATTR_USERMARSHAL */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "user_marshal" }, + /* ATTR_UUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, "uuid" }, + /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, + /* ATTR_VARARG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, + /* ATTR_VERSION */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0, 1, 0, 1, 1, 0, 1, "version" }, + /* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "vi_progid" }, + /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, +}; + +static const char *get_attr_display_name( enum attr_type attr_type ) +{ + return allowed_attr[attr_type].display_name; +} + +attr_list_t *append_attr( attr_list_t *list, attr_t *attr ) +{ + attr_t *attr_existing; + if (!attr) return list; + if (!list) + { + list = xmalloc( sizeof(*list) ); + list_init( list ); + } + if (!allowed_attr[attr->type].multiple) + { + LIST_FOR_EACH_ENTRY( attr_existing, list, attr_t, entry ) + if (attr_existing->type == attr->type) + { + char buffer[1024]; + snprintf( buffer, sizeof(buffer), "duplicate attribute %s\n", + get_attr_display_name( attr->type ) ); + parser_warning( NULL, buffer ); + /* use the last attribute, like MIDL does */ + list_remove( &attr_existing->entry ); + break; + } + } + list_add_tail( list, &attr->entry ); + return list; +} + +attr_list_t *append_attr_list( attr_list_t *new_list, attr_list_t *old_list ) +{ + struct list *entry; + + if (!old_list) return new_list; + + while ((entry = list_head( old_list ))) + { + attr_t *attr = LIST_ENTRY( entry, attr_t, entry ); + list_remove( entry ); + new_list = append_attr( new_list, attr ); + } + return new_list; +} + +attr_list_t *append_attribs( attr_list_t *l1, attr_list_t *l2 ) +{ + if (!l2) return l1; + if (!l1 || l1 == l2) return l2; + list_move_tail( l1, l2 ); + return l1; +} + +attr_list_t *map_attrs( const attr_list_t *list, map_attrs_filter_t filter ) +{ + attr_list_t *new_list; + const attr_t *attr; + attr_t *new_attr; + + if (!list) return NULL; + + new_list = xmalloc( sizeof(*list) ); + list_init( new_list ); + LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) + { + if (filter && !filter( new_list, attr )) continue; + new_attr = xmalloc( sizeof(*new_attr) ); + *new_attr = *attr; + list_add_tail( new_list, &new_attr->entry ); + } + return new_list; +} + +attr_list_t *move_attr( attr_list_t *dst, attr_list_t *src, enum attr_type type ) +{ + attr_t *attr; + if (!src) return dst; + LIST_FOR_EACH_ENTRY( attr, src, attr_t, entry ) + { + if (attr->type == type) + { + list_remove( &attr->entry ); + return append_attr( dst, attr ); + } + } + return dst; +} + +attr_list_t *check_apicontract_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_apicontract) + error_loc( "inapplicable attribute %s for apicontract %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_coclass_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_coclass) + error_loc( "inapplicable attribute %s for coclass %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_dispiface_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_dispinterface) + error_loc( "inapplicable attribute %s for dispinterface %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_enum_attrs( attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_enum) + error_loc( "inapplicable attribute %s for enum\n", + allowed_attr[attr->type].display_name ); + } + return attrs; +} + +attr_list_t *check_enum_member_attrs( attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_enum_member) + error_loc( "inapplicable attribute %s for enum member\n", + allowed_attr[attr->type].display_name ); + } + return attrs; +} + +attr_list_t *check_field_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_field) + error_loc( "inapplicable attribute %s for field %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_function_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_function) + error_loc( "inapplicable attribute %s for function %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_interface_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_interface) + error_loc( "inapplicable attribute %s for interface %s\n", + allowed_attr[attr->type].display_name, name ); + if (attr->type == ATTR_IMPLICIT_HANDLE) + { + const var_t *var = attr->u.pval; + if (type_get_type( var->declspec.type ) == TYPE_BASIC && + type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE) + continue; + if (is_aliaschain_attr( var->declspec.type, ATTR_HANDLE )) continue; + error_loc( "attribute %s requires a handle type in interface %s\n", + allowed_attr[attr->type].display_name, name ); + } + } + return attrs; +} + +attr_list_t *check_library_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_library) + error_loc( "inapplicable attribute %s for library %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_module_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_module) + error_loc( "inapplicable attribute %s for module %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_runtimeclass_attrs( const char *name, attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_runtimeclass) + error_loc( "inapplicable attribute %s for runtimeclass %s\n", + allowed_attr[attr->type].display_name, name ); + } + return attrs; +} + +attr_list_t *check_struct_attrs( attr_list_t *attrs ) +{ + int mask = winrt_mode ? 3 : 1; + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!(allowed_attr[attr->type].on_struct & mask)) + error_loc( "inapplicable attribute %s for struct\n", + allowed_attr[attr->type].display_name ); + } + return attrs; +} + +attr_list_t *check_typedef_attrs( attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_type) + error_loc( "inapplicable attribute %s for typedef\n", + allowed_attr[attr->type].display_name ); + } + return attrs; +} + +attr_list_t *check_union_attrs( attr_list_t *attrs ) +{ + const attr_t *attr; + if (!attrs) return NULL; + LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_union) + error_loc( "inapplicable attribute %s for union\n", + allowed_attr[attr->type].display_name ); + } + return attrs; +} + +void check_arg_attrs( const var_t *arg ) +{ + const attr_t *attr; + if (!arg->attrs) return; + LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) + { + if (!allowed_attr[attr->type].on_arg) + error_loc( "inapplicable attribute %s for argument %s\n", + allowed_attr[attr->type].display_name, arg->name ); + } +} diff --git a/tools/widl/header.c b/tools/widl/header.c index 35163bfa86b..b7497e215d5 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -65,63 +65,6 @@ static void write_line(FILE *f, int delta, const char *fmt, ...) fprintf(f, "\n"); }
-int is_ptrchain_attr(const var_t *var, enum attr_type t) -{ - if (is_attr(var->attrs, t)) - return 1; - else - { - type_t *type = var->declspec.type; - for (;;) - { - if (is_attr(type->attrs, t)) - return 1; - else if (type_is_alias(type)) - type = type_alias_get_aliasee_type(type); - else if (is_ptr(type)) - type = type_pointer_get_ref_type(type); - else return 0; - } - } -} - -int is_aliaschain_attr(const type_t *type, enum attr_type attr) -{ - const type_t *t = type; - for (;;) - { - if (is_attr(t->attrs, attr)) - return 1; - else if (type_is_alias(t)) - t = type_alias_get_aliasee_type(t); - else return 0; - } -} - -int is_attr(const attr_list_t *list, enum attr_type t) -{ - const attr_t *attr; - if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) - if (attr->type == t) return 1; - return 0; -} - -void *get_attrp(const attr_list_t *list, enum attr_type t) -{ - const attr_t *attr; - if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) - if (attr->type == t) return attr->u.pval; - return NULL; -} - -unsigned int get_attrv(const attr_list_t *list, enum attr_type t) -{ - const attr_t *attr; - if (list) LIST_FOR_EACH_ENTRY( attr, list, const attr_t, entry ) - if (attr->type == t) return attr->u.ival; - return 0; -} - static char *format_parameterized_type_args(const type_t *type, const char *prefix, const char *suffix) { typeref_list_t *params; diff --git a/tools/widl/header.h b/tools/widl/header.h index f949d1e6d0d..045eb59b000 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -23,10 +23,6 @@
#include "typetree.h"
-extern int is_ptrchain_attr(const var_t *var, enum attr_type t); -extern int is_aliaschain_attr(const type_t *var, enum attr_type t); -extern void *get_attrp(const attr_list_t *list, enum attr_type t); -extern unsigned int get_attrv(const attr_list_t *list, enum attr_type t); extern const char* get_name(const var_t *v); extern void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly, int write_callconv); extern void write_type_right(FILE *h, type_t *t, int is_field); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 895b995d9fb..0cc74634618 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -45,12 +45,8 @@ struct _import_t };
static str_list_t *append_str(str_list_t *list, char *str); -static attr_list_t *append_attr_list(attr_list_t *new_list, attr_list_t *old_list); static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, enum storage_class stgclass, enum type_qualifier qual, enum function_specifier func_specifier); -static attr_t *make_attr(enum attr_type type); -static attr_t *make_attrv(enum attr_type type, unsigned int val); -static attr_t *make_custom_attr(struct uuid *id, expr_t *pval); static expr_list_t *append_expr(expr_list_t *list, expr_t *expr); static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_t *decl, int top); static var_list_t *set_var_types(attr_list_t *attrs, decl_spec_t *decl_spec, declarator_list_t *decls); @@ -76,18 +72,8 @@ static void push_parameters_namespace(const char *name); static void pop_parameters_namespace(const char *name);
static statement_list_t *append_parameterized_type_stmts(statement_list_t *stmts); -static void check_arg_attrs(const var_t *arg); static void check_statements(const statement_list_t *stmts, int is_inside_library); static void check_all_user_types(const statement_list_t *stmts); -static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs); -static attr_list_t *check_typedef_attrs(attr_list_t *attrs); -static attr_list_t *check_enum_attrs(attr_list_t *attrs); -static attr_list_t *check_enum_member_attrs(attr_list_t *attrs); -static attr_list_t *check_struct_attrs(attr_list_t *attrs); -static attr_list_t *check_union_attrs(attr_list_t *attrs); -static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs); -static attr_list_t *check_library_attrs(const char *name, attr_list_t *attrs); -const char *get_attr_display_name(enum attr_type type); static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func);
static void check_async_uuid(type_t *iface); @@ -107,7 +93,6 @@ static statement_t *make_statement_parameterized_type(type_t *type, typeref_list static statement_t *make_statement_delegate(type_t *ret, var_list_t *args); static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt); static statement_list_t *append_statements(statement_list_t *, statement_list_t *); -static attr_list_t *append_attribs(attr_list_t *, attr_list_t *);
static struct namespace global_namespace = { NULL, NULL, LIST_INIT(global_namespace.entry), LIST_INIT(global_namespace.children) @@ -1450,55 +1435,6 @@ static str_list_t *append_str(str_list_t *list, char *str) return list; }
-static attr_list_t *move_attr(attr_list_t *dst, attr_list_t *src, enum attr_type type) -{ - attr_t *attr; - if (!src) return dst; - LIST_FOR_EACH_ENTRY(attr, src, attr_t, entry) - if (attr->type == type) - { - list_remove(&attr->entry); - return append_attr(dst, attr); - } - return dst; -} - -static attr_list_t *append_attr_list(attr_list_t *new_list, attr_list_t *old_list) -{ - struct list *entry; - - if (!old_list) return new_list; - - while ((entry = list_head(old_list))) - { - attr_t *attr = LIST_ENTRY(entry, attr_t, entry); - list_remove(entry); - new_list = append_attr(new_list, attr); - } - return new_list; -} - -typedef int (*map_attrs_filter_t)(attr_list_t*,const attr_t*); - -static attr_list_t *map_attrs(const attr_list_t *list, map_attrs_filter_t filter) -{ - attr_list_t *new_list; - const attr_t *attr; - attr_t *new_attr; - - if (!list) return NULL; - - new_list = xmalloc( sizeof(*list) ); - list_init( new_list ); - LIST_FOR_EACH_ENTRY(attr, list, const attr_t, entry) - { - if (filter && !filter(new_list, attr)) continue; - new_attr = xmalloc(sizeof(*new_attr)); - *new_attr = *attr; - list_add_tail(new_list, &new_attr->entry); - } - return new_list; -}
static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t *right, enum storage_class stgclass, enum type_qualifier qual, enum function_specifier func_specifier) @@ -1546,41 +1482,6 @@ static decl_spec_t *make_decl_spec(type_t *type, decl_spec_t *left, decl_spec_t return declspec; }
-static attr_t *make_attr(enum attr_type type) -{ - attr_t *a = xmalloc(sizeof(attr_t)); - a->type = type; - a->u.ival = 0; - return a; -} - -static attr_t *make_attrv(enum attr_type type, unsigned int val) -{ - attr_t *a = xmalloc(sizeof(attr_t)); - a->type = type; - a->u.ival = val; - return a; -} - -attr_t *make_attrp(enum attr_type type, void *val) -{ - attr_t *a = xmalloc(sizeof(attr_t)); - a->type = type; - a->u.pval = val; - return a; -} - -static attr_t *make_custom_attr(struct uuid *id, expr_t *pval) -{ - attr_t *a = xmalloc(sizeof(attr_t)); - attr_custdata_t *cstdata = xmalloc(sizeof(attr_custdata_t)); - a->type = ATTR_CUSTOM; - cstdata->id = *id; - cstdata->pval = pval; - a->u.pval = cstdata; - return a; -} - static expr_list_t *append_expr(expr_list_t *list, expr_t *expr) { if (!expr) return list; @@ -2340,380 +2241,6 @@ char *gen_name(void) return strmake("__WIDL_%s_generated_name_%08lX", file_id, n++); }
-struct allowed_attr -{ - unsigned int dce_compatible : 1; - unsigned int acf : 1; - unsigned int multiple : 1; - - unsigned int on_interface : 1; - unsigned int on_function : 1; - unsigned int on_arg : 1; - unsigned int on_type : 1; - unsigned int on_enum : 1; - unsigned int on_enum_member : 1; - unsigned int on_struct : 2; - unsigned int on_union : 1; - unsigned int on_field : 1; - unsigned int on_library : 1; - unsigned int on_dispinterface : 1; - unsigned int on_module : 1; - unsigned int on_coclass : 1; - unsigned int on_apicontract : 1; - unsigned int on_runtimeclass : 1; - const char *display_name; -}; - -struct allowed_attr allowed_attr[] = -{ - /* attr { D ACF M I Fn ARG T En Enm St Un Fi L DI M C AC R <display name> } */ - /* ATTR_ACTIVATABLE */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "activatable" }, - /* ATTR_AGGREGATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "aggregatable" }, - /* ATTR_ALLOCATE */ { 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "allocate" }, - /* ATTR_ANNOTATION */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "annotation" }, - /* ATTR_APPOBJECT */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "appobject" }, - /* ATTR_ASYNC */ { 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "async" }, - /* ATTR_ASYNCUUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "async_uuid" }, - /* ATTR_AUTO_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "auto_handle" }, - /* ATTR_BINDABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "bindable" }, - /* ATTR_BROADCAST */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "broadcast" }, - /* ATTR_CALLAS */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "call_as" }, - /* ATTR_CALLCONV */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, - /* ATTR_CASE */ { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "case" }, - /* ATTR_CODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "code" }, - /* ATTR_COMMSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "comm_status" }, - /* ATTR_CONTEXTHANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "context_handle" }, - /* ATTR_CONTRACT */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, "contract" }, - /* ATTR_CONTRACTVERSION */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, "contractversion" }, - /* ATTR_CONTROL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, "control" }, - /* ATTR_CUSTOM */ { 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, "custom" }, - /* ATTR_DECODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "decode" }, - /* ATTR_DEFAULT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, "default" }, - /* ATTR_DEFAULTBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultbind" }, - /* ATTR_DEFAULTCOLLELEM */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultcollelem" }, - /* ATTR_DEFAULTVALUE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "defaultvalue" }, - /* ATTR_DEFAULTVTABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "defaultvtable" }, - /* ATTR_DISABLECONSISTENCYCHECK */{ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "disable_consistency_check" }, - /* ATTR_DISPINTERFACE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, NULL }, - /* ATTR_DISPLAYBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "displaybind" }, - /* ATTR_DLLNAME */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "dllname" }, - /* ATTR_DUAL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "dual" }, - /* ATTR_ENABLEALLOCATE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "enable_allocate" }, - /* ATTR_ENCODE */ { 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "encode" }, - /* ATTR_ENDPOINT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "endpoint" }, - /* ATTR_ENTRY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "entry" }, - /* ATTR_EVENTADD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventadd" }, - /* ATTR_EVENTREMOVE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "eventremove" }, - /* ATTR_EXCLUSIVETO */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "exclusive_to" }, - /* ATTR_EXPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "explicit_handle" }, - /* ATTR_FAULTSTATUS */ { 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "fault_status" }, - /* ATTR_FLAGS */ { 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "flags" }, - /* ATTR_FORCEALLOCATE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "force_allocate" }, - /* ATTR_HANDLE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "handle" }, - /* ATTR_HELPCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpcontext" }, - /* ATTR_HELPFILE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpfile" }, - /* ATTR_HELPSTRING */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstring" }, - /* ATTR_HELPSTRINGCONTEXT */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, "helpstringcontext" }, - /* ATTR_HELPSTRINGDLL */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "helpstringdll" }, - /* ATTR_HIDDEN */ { 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, "hidden" }, - /* ATTR_ID */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, "id" }, - /* ATTR_IDEMPOTENT */ { 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "idempotent" }, - /* ATTR_IGNORE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ignore" }, - /* ATTR_IIDIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "iid_is" }, - /* ATTR_IMMEDIATEBIND */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "immediatebind" }, - /* ATTR_IMPLICIT_HANDLE */ { 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "implicit_handle" }, - /* ATTR_IN */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "in" }, - /* ATTR_INPUTSYNC */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "inputsync" }, - /* ATTR_LENGTHIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "length_is" }, - /* ATTR_LIBLCID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, "lcid" }, - /* ATTR_LICENSED */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "licensed" }, - /* ATTR_LOCAL */ { 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "local" }, - /* ATTR_MARSHALING_BEHAVIOR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "marshaling_behavior" }, - /* ATTR_MAYBE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "maybe" }, - /* ATTR_MESSAGE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "message" }, - /* ATTR_NOCODE */ { 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nocode" }, - /* ATTR_NONBROWSABLE */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonbrowsable" }, - /* ATTR_NONCREATABLE */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "noncreatable" }, - /* ATTR_NONEXTENSIBLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "nonextensible" }, - /* ATTR_NOTIFY */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify" }, - /* ATTR_NOTIFYFLAG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "notify_flag" }, - /* ATTR_OBJECT */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "object" }, - /* ATTR_ODL */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "odl" }, - /* ATTR_OLEAUTOMATION */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "oleautomation" }, - /* ATTR_OPTIMIZE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optimize" }, - /* ATTR_OPTIONAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "optional" }, - /* ATTR_OUT */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "out" }, - /* ATTR_OVERLOAD */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "overload" }, - /* ATTR_PARAMLCID */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "lcid" }, - /* ATTR_PARTIALIGNORE */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "partial_ignore" }, - /* ATTR_POINTERDEFAULT */ { 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "pointer_default" }, - /* ATTR_POINTERTYPE */ { 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "ref, unique or ptr" }, - /* ATTR_PROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "progid" }, - /* ATTR_PROPGET */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propget" }, - /* ATTR_PROPPUT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propput" }, - /* ATTR_PROPPUTREF */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "propputref" }, - /* ATTR_PROXY */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "proxy" }, - /* ATTR_PUBLIC */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "public" }, - /* ATTR_RANGE */ { 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "range" }, - /* ATTR_READONLY */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "readonly" }, - /* ATTR_REPRESENTAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "represent_as" }, - /* ATTR_REQUESTEDIT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "requestedit" }, - /* ATTR_RESTRICTED */ { 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, "restricted" }, - /* ATTR_RETVAL */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "retval" }, - /* ATTR_SIZEIS */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "size_is" }, - /* ATTR_SOURCE */ { 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, "source" }, - /* ATTR_STATIC */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "static" }, - /* ATTR_STRICTCONTEXTHANDLE */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "strict_context_handle" }, - /* ATTR_STRING */ { 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "string" }, - /* ATTR_SWITCHIS */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_is" }, - /* ATTR_SWITCHTYPE */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "switch_type" }, - /* ATTR_THREADING */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, "threading" }, - /* ATTR_TRANSMITAS */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "transmit_as" }, - /* ATTR_UIDEFAULT */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "uidefault" }, - /* ATTR_USESGETLASTERROR */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "usesgetlasterror" }, - /* ATTR_USERMARSHAL */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "user_marshal" }, - /* ATTR_UUID */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, "uuid" }, - /* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "v1_enum" }, - /* ATTR_VARARG */ { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" }, - /* ATTR_VERSION */ { 1, 0, 0, 1, 0, 0, 1, 1, 0, 2, 0, 0, 1, 0, 1, 1, 0, 1, "version" }, - /* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, "vi_progid" }, - /* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" }, -}; - -attr_list_t *append_attr(attr_list_t *list, attr_t *attr) -{ - attr_t *attr_existing; - if (!attr) return list; - if (!list) - { - list = xmalloc( sizeof(*list) ); - list_init( list ); - } - if (!allowed_attr[attr->type].multiple) - { - LIST_FOR_EACH_ENTRY(attr_existing, list, attr_t, entry) - if (attr_existing->type == attr->type) - { - warning_loc( "duplicate attribute %s\n", get_attr_display_name(attr->type) ); - /* use the last attribute, like MIDL does */ - list_remove(&attr_existing->entry); - break; - } - } - list_add_tail( list, &attr->entry ); - return list; -} - -const char *get_attr_display_name(enum attr_type type) -{ - return allowed_attr[type].display_name; -} - -attr_list_t *check_interface_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_interface) - error_loc("inapplicable attribute %s for interface %s\n", - allowed_attr[attr->type].display_name, name); - if (attr->type == ATTR_IMPLICIT_HANDLE) - { - const var_t *var = attr->u.pval; - if (type_get_type( var->declspec.type) == TYPE_BASIC && - type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE) - continue; - if (is_aliaschain_attr( var->declspec.type, ATTR_HANDLE )) - continue; - error_loc("attribute %s requires a handle type in interface %s\n", - allowed_attr[attr->type].display_name, name); - } - } - return attrs; -} - -static attr_list_t *check_function_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_function) - error_loc("inapplicable attribute %s for function %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -static void check_arg_attrs(const var_t *arg) -{ - const attr_t *attr; - - if (arg->attrs) - { - LIST_FOR_EACH_ENTRY(attr, arg->attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_arg) - error_loc("inapplicable attribute %s for argument %s\n", - allowed_attr[attr->type].display_name, arg->name); - } - } -} - -static attr_list_t *check_typedef_attrs(attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_type) - error_loc("inapplicable attribute %s for typedef\n", - allowed_attr[attr->type].display_name); - } - return attrs; -} - -static attr_list_t *check_enum_attrs(attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_enum) - error_loc("inapplicable attribute %s for enum\n", - allowed_attr[attr->type].display_name); - } - return attrs; -} - -static attr_list_t *check_enum_member_attrs(attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_enum_member) - error_loc("inapplicable attribute %s for enum member\n", - allowed_attr[attr->type].display_name); - } - return attrs; -} - -static attr_list_t *check_struct_attrs(attr_list_t *attrs) -{ - int mask = winrt_mode ? 3 : 1; - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!(allowed_attr[attr->type].on_struct & mask)) - error_loc("inapplicable attribute %s for struct\n", - allowed_attr[attr->type].display_name); - } - return attrs; -} - -static attr_list_t *check_union_attrs(attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_union) - error_loc("inapplicable attribute %s for union\n", - allowed_attr[attr->type].display_name); - } - return attrs; -} - -static attr_list_t *check_field_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_field) - error_loc("inapplicable attribute %s for field %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -static attr_list_t *check_library_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_library) - error_loc("inapplicable attribute %s for library %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_dispinterface) - error_loc("inapplicable attribute %s for dispinterface %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -attr_list_t *check_module_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_module) - error_loc("inapplicable attribute %s for module %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -attr_list_t *check_coclass_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - { - if (!allowed_attr[attr->type].on_coclass) - error_loc("inapplicable attribute %s for coclass %s\n", - allowed_attr[attr->type].display_name, name); - } - return attrs; -} - -attr_list_t *check_runtimeclass_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - if (!allowed_attr[attr->type].on_runtimeclass) - error_loc("inapplicable attribute %s for runtimeclass %s\n", - allowed_attr[attr->type].display_name, name); - return attrs; -} - -attr_list_t *check_apicontract_attrs(const char *name, attr_list_t *attrs) -{ - const attr_t *attr; - if (!attrs) return attrs; - LIST_FOR_EACH_ENTRY(attr, attrs, const attr_t, entry) - if (!allowed_attr[attr->type].on_apicontract) - error_loc("inapplicable attribute %s for apicontract %s\n", - allowed_attr[attr->type].display_name, name); - return attrs; -} - static int is_allowed_conf_type(const type_t *type) { switch (type_get_type(type)) @@ -3380,14 +2907,6 @@ static statement_list_t *append_statements(statement_list_t *l1, statement_list_ return l1; }
-static attr_list_t *append_attribs(attr_list_t *l1, attr_list_t *l2) -{ - if (!l2) return l1; - if (!l1 || l1 == l2) return l2; - list_move_tail (l1, l2); - return l1; -} - static statement_list_t *append_statement(statement_list_t *list, statement_t *stmt) { if (!stmt) return list; diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index b2d9ab5d100..b3373ded11d 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -185,19 +185,6 @@ static const char *string_of_type(unsigned char type) } }
-static void *get_aliaschain_attrp(const type_t *type, enum attr_type attr) -{ - const type_t *t = type; - for (;;) - { - if (is_attr(t->attrs, attr)) - return get_attrp(t->attrs, attr); - else if (type_is_alias(t)) - t = type_alias_get_aliasee_type(t); - else return NULL; - } -} - unsigned char get_basic_fc(const type_t *type) { int sign = type_basic_get_sign(type); diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 7cb7f521167..8942454ceda 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -32,13 +32,6 @@ enum name_type { NAME_C };
-attr_list_t *check_apicontract_attrs(const char *name, attr_list_t *attrs); -attr_list_t *check_coclass_attrs(const char *name, attr_list_t *attrs); -attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs); -attr_list_t *check_interface_attrs(const char *name, attr_list_t *attrs); -attr_list_t *check_module_attrs(const char *name, attr_list_t *attrs); -attr_list_t *check_runtimeclass_attrs(const char *name, attr_list_t *attrs); - type_t *find_parameterized_type(type_t *type, typeref_list_t *params);
type_t *type_new_function(var_list_t *args); @@ -80,12 +73,9 @@ int type_is_equal(const type_t *type1, const type_t *type2); const char *type_get_decl_name(const type_t *type, enum name_type name_type); const char *type_get_name(const type_t *type, enum name_type name_type); char *gen_name(void); -extern int is_attr(const attr_list_t *list, enum attr_type t);
typeref_t *make_typeref(type_t *type); typeref_list_t *append_typeref(typeref_list_t *list, typeref_t *ref); -attr_t *make_attrp(enum attr_type type, void *val); -attr_list_t *append_attr(attr_list_t *list, attr_t *attr);
/* FIXME: shouldn't need to export this */ type_t *duptype(type_t *t, int dupname); @@ -356,6 +346,11 @@ static inline int type_is_alias(const type_t *type) return type->type_type == TYPE_ALIAS; }
+static inline int type_is_ptr( const type_t *type ) +{ + return type->type_type == TYPE_POINTER; +} + static inline const decl_spec_t *type_alias_get_aliasee(const type_t *type) { assert(type_is_alias(type)); diff --git a/tools/widl/widl.h b/tools/widl/widl.h index a816ec2bb46..04daeaa76c4 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -95,4 +95,42 @@ extern void write_dlldata(const statement_list_t *stmts); extern void start_cplusplus_guard(FILE *fp); extern void end_cplusplus_guard(FILE *fp);
+/* attribute.c */ + +extern attr_t *make_attr( enum attr_type attr_type ); +extern attr_t *make_attrv( enum attr_type attr_type, unsigned int val ); +extern attr_t *make_attrp( enum attr_type attr_type, void *val ); +extern attr_t *make_custom_attr( struct uuid *id, expr_t *pval ); + +extern int is_attr( const attr_list_t *list, enum attr_type attr_type ); +extern int is_ptrchain_attr( const var_t *var, enum attr_type attr_type ); +extern int is_aliaschain_attr( const type_t *type, enum attr_type attr_type ); + +extern unsigned int get_attrv( const attr_list_t *list, enum attr_type attr_type ); +extern void *get_attrp( const attr_list_t *list, enum attr_type attr_type ); +extern void *get_aliaschain_attrp( const type_t *type, enum attr_type attr_type ); + +typedef int (*map_attrs_filter_t)( attr_list_t *, const attr_t * ); +extern attr_list_t *append_attr( attr_list_t *list, attr_t *attr ); +extern attr_list_t *append_attr_list( attr_list_t *new_list, attr_list_t *old_list ); +extern attr_list_t *append_attribs( attr_list_t *, attr_list_t * ); +extern attr_list_t *map_attrs( const attr_list_t *list, map_attrs_filter_t filter ); +extern attr_list_t *move_attr( attr_list_t *dst, attr_list_t *src, enum attr_type type ); + +extern attr_list_t *check_apicontract_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_coclass_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_dispiface_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_enum_attrs( attr_list_t *attrs ); +extern attr_list_t *check_enum_member_attrs( attr_list_t *attrs ); +extern attr_list_t *check_field_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_function_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_interface_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_library_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_module_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_runtimeclass_attrs( const char *name, attr_list_t *attrs ); +extern attr_list_t *check_struct_attrs( attr_list_t *attrs ); +extern attr_list_t *check_typedef_attrs( attr_list_t *attrs ); +extern attr_list_t *check_union_attrs( attr_list_t *attrs ); +extern void check_arg_attrs( const var_t *arg ); + #endif
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/attribute.c | 12 +- tools/widl/parser.y | 242 ++++++++++++++++++++--------------------- tools/widl/typetree.c | 2 +- tools/widl/widl.h | 5 +- 4 files changed, 126 insertions(+), 135 deletions(-)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index 35d4e8c90a1..46fb05d09e0 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -24,15 +24,7 @@
#include "parser.tab.h"
-attr_t *make_attr( enum attr_type attr_type ) -{ - attr_t *a = xmalloc( sizeof(attr_t) ); - a->type = attr_type; - a->u.ival = 0; - return a; -} - -attr_t *make_attrv( enum attr_type attr_type, unsigned int val ) +attr_t *attr_int( enum attr_type attr_type, unsigned int val ) { attr_t *a = xmalloc( sizeof(attr_t) ); a->type = attr_type; @@ -40,7 +32,7 @@ attr_t *make_attrv( enum attr_type attr_type, unsigned int val ) return a; }
-attr_t *make_attrp( enum attr_type attr_type, void *val ) +attr_t *attr_ptr( enum attr_type attr_type, void *val ) { attr_t *a = xmalloc( sizeof(attr_t) ); a->type = attr_type; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 0cc74634618..86a07b175f4 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -607,125 +607,125 @@ activatable_attr:
attribute : %empty { $$ = NULL; } - | tACTIVATABLE '(' activatable_attr ')' { $$ = make_attrp( ATTR_ACTIVATABLE, $3 ); } - | tAGGREGATABLE { $$ = make_attr( ATTR_AGGREGATABLE ); } - | tANNOTATION '(' aSTRING ')' { $$ = make_attrp( ATTR_ANNOTATION, $3 ); } - | tAPPOBJECT { $$ = make_attr( ATTR_APPOBJECT ); } - | tASYNC { $$ = make_attr( ATTR_ASYNC ); } - | tAUTOHANDLE { $$ = make_attr( ATTR_AUTO_HANDLE ); } - | tBINDABLE { $$ = make_attr( ATTR_BINDABLE ); } - | tBROADCAST { $$ = make_attr( ATTR_BROADCAST ); } - | tCALLAS '(' ident ')' { $$ = make_attrp( ATTR_CALLAS, $3 ); } - | tCASE '(' expr_list_int_const ')' { $$ = make_attrp( ATTR_CASE, $3 ); } - | tCODE { $$ = make_attr( ATTR_CODE ); } - | tCOMMSTATUS { $$ = make_attr( ATTR_COMMSTATUS ); } - | tCONTEXTHANDLE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); } - | tCONTEXTHANDLENOSERIALIZE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } - | tCONTEXTHANDLESERIALIZE { $$ = make_attrv( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } - | tCONTRACT '(' contract_req ')' { $$ = make_attrp( ATTR_CONTRACT, $3 ); } - | tCONTRACTVERSION '(' contract_ver ')' { $$ = make_attrv( ATTR_CONTRACTVERSION, $3 ); } - | tCONTROL { $$ = make_attr( ATTR_CONTROL ); } + | tACTIVATABLE '(' activatable_attr ')' { $$ = attr_ptr( ATTR_ACTIVATABLE, $3 ); } + | tAGGREGATABLE { $$ = attr_int( ATTR_AGGREGATABLE, 0 ); } + | tANNOTATION '(' aSTRING ')' { $$ = attr_ptr( ATTR_ANNOTATION, $3 ); } + | tAPPOBJECT { $$ = attr_int( ATTR_APPOBJECT, 0 ); } + | tASYNC { $$ = attr_int( ATTR_ASYNC, 0 ); } + | tAUTOHANDLE { $$ = attr_int( ATTR_AUTO_HANDLE, 0 ); } + | tBINDABLE { $$ = attr_int( ATTR_BINDABLE, 0 ); } + | tBROADCAST { $$ = attr_int( ATTR_BROADCAST, 0 ); } + | tCALLAS '(' ident ')' { $$ = attr_ptr( ATTR_CALLAS, $3 ); } + | tCASE '(' expr_list_int_const ')' { $$ = attr_ptr( ATTR_CASE, $3 ); } + | tCODE { $$ = attr_int( ATTR_CODE, 0 ); } + | tCOMMSTATUS { $$ = attr_int( ATTR_COMMSTATUS, 0 ); } + | tCONTEXTHANDLE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); } + | tCONTEXTHANDLENOSERIALIZE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } + | tCONTEXTHANDLESERIALIZE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } + | tCONTRACT '(' contract_req ')' { $$ = attr_ptr( ATTR_CONTRACT, $3 ); } + | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_int( ATTR_CONTRACTVERSION, $3 ); } + | tCONTROL { $$ = attr_int( ATTR_CONTROL, 0 ); } | tCUSTOM '(' aUUID ',' expr_const ')' { $$ = make_custom_attr( $3, $5 ); } - | tDECODE { $$ = make_attr( ATTR_DECODE ); } - | tDEFAULT { $$ = make_attr( ATTR_DEFAULT ); } - | tDEFAULTBIND { $$ = make_attr( ATTR_DEFAULTBIND ); } - | tDEFAULTCOLLELEM { $$ = make_attr( ATTR_DEFAULTCOLLELEM ); } - | tDEFAULTVALUE '(' expr_const ')' { $$ = make_attrp( ATTR_DEFAULTVALUE, $3 ); } - | tDEFAULTVTABLE { $$ = make_attr( ATTR_DEFAULTVTABLE ); } - | tDISABLECONSISTENCYCHECK { $$ = make_attr( ATTR_DISABLECONSISTENCYCHECK ); } - | tDISPLAYBIND { $$ = make_attr( ATTR_DISPLAYBIND ); } - | tDLLNAME '(' aSTRING ')' { $$ = make_attrp( ATTR_DLLNAME, $3 ); } - | tDUAL { $$ = make_attr( ATTR_DUAL ); } - | tENABLEALLOCATE { $$ = make_attr( ATTR_ENABLEALLOCATE ); } - | tENCODE { $$ = make_attr( ATTR_ENCODE ); } - | tENDPOINT '(' str_list ')' { $$ = make_attrp( ATTR_ENDPOINT, $3 ); } - | tENTRY '(' expr_const ')' { $$ = make_attrp( ATTR_ENTRY, $3 ); } - | tEVENTADD { $$ = make_attr( ATTR_EVENTADD ); } - | tEVENTREMOVE { $$ = make_attr( ATTR_EVENTREMOVE ); } + | tDECODE { $$ = attr_int( ATTR_DECODE, 0 ); } + | tDEFAULT { $$ = attr_int( ATTR_DEFAULT, 0 ); } + | tDEFAULTBIND { $$ = attr_int( ATTR_DEFAULTBIND, 0 ); } + | tDEFAULTCOLLELEM { $$ = attr_int( ATTR_DEFAULTCOLLELEM, 0 ); } + | tDEFAULTVALUE '(' expr_const ')' { $$ = attr_ptr( ATTR_DEFAULTVALUE, $3 ); } + | tDEFAULTVTABLE { $$ = attr_int( ATTR_DEFAULTVTABLE, 0 ); } + | tDISABLECONSISTENCYCHECK { $$ = attr_int( ATTR_DISABLECONSISTENCYCHECK, 0 ); } + | tDISPLAYBIND { $$ = attr_int( ATTR_DISPLAYBIND, 0 ); } + | tDLLNAME '(' aSTRING ')' { $$ = attr_ptr( ATTR_DLLNAME, $3 ); } + | tDUAL { $$ = attr_int( ATTR_DUAL, 0 ); } + | tENABLEALLOCATE { $$ = attr_int( ATTR_ENABLEALLOCATE, 0 ); } + | tENCODE { $$ = attr_int( ATTR_ENCODE, 0 ); } + | tENDPOINT '(' str_list ')' { $$ = attr_ptr( ATTR_ENDPOINT, $3 ); } + | tENTRY '(' expr_const ')' { $$ = attr_ptr( ATTR_ENTRY, $3 ); } + | tEVENTADD { $$ = attr_int( ATTR_EVENTADD, 0 ); } + | tEVENTREMOVE { $$ = attr_int( ATTR_EVENTREMOVE, 0 ); } | tEXCLUSIVETO '(' decl_spec ')' { if ($3->type->type_type != TYPE_RUNTIMECLASS) error_loc( "type %s is not a runtimeclass\n", $3->type->name ); - $$ = make_attrp( ATTR_EXCLUSIVETO, $3->type ); + $$ = attr_ptr( ATTR_EXCLUSIVETO, $3->type ); } - | tEXPLICITHANDLE { $$ = make_attr( ATTR_EXPLICIT_HANDLE ); } - | tFAULTSTATUS { $$ = make_attr( ATTR_FAULTSTATUS ); } - | tFLAGS { $$ = make_attr( ATTR_FLAGS ); } - | tFORCEALLOCATE { $$ = make_attr( ATTR_FORCEALLOCATE ); } - | tHANDLE { $$ = make_attr( ATTR_HANDLE ); } - | tHELPCONTEXT '(' expr_int_const ')' { $$ = make_attrp( ATTR_HELPCONTEXT, $3 ); } - | tHELPFILE '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPFILE, $3 ); } - | tHELPSTRING '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPSTRING, $3 ); } + | tEXPLICITHANDLE { $$ = attr_int( ATTR_EXPLICIT_HANDLE, 0 ); } + | tFAULTSTATUS { $$ = attr_int( ATTR_FAULTSTATUS, 0 ); } + | tFLAGS { $$ = attr_int( ATTR_FLAGS, 0 ); } + | tFORCEALLOCATE { $$ = attr_int( ATTR_FORCEALLOCATE, 0 ); } + | tHANDLE { $$ = attr_int( ATTR_HANDLE, 0 ); } + | tHELPCONTEXT '(' expr_int_const ')' { $$ = attr_ptr( ATTR_HELPCONTEXT, $3 ); } + | tHELPFILE '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPFILE, $3 ); } + | tHELPSTRING '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPSTRING, $3 ); } | tHELPSTRINGCONTEXT '(' expr_int_const ')' - { $$ = make_attrp( ATTR_HELPSTRINGCONTEXT, $3 ); } - | tHELPSTRINGDLL '(' aSTRING ')' { $$ = make_attrp( ATTR_HELPSTRINGDLL, $3 ); } - | tHIDDEN { $$ = make_attr( ATTR_HIDDEN ); } - | tID '(' expr_int_const ')' { $$ = make_attrp( ATTR_ID, $3 ); } - | tIDEMPOTENT { $$ = make_attr( ATTR_IDEMPOTENT ); } - | tIGNORE { $$ = make_attr( ATTR_IGNORE ); } - | tIIDIS '(' expr ')' { $$ = make_attrp( ATTR_IIDIS, $3 ); } - | tIMMEDIATEBIND { $$ = make_attr( ATTR_IMMEDIATEBIND ); } - | tIMPLICITHANDLE '(' arg ')' { $$ = make_attrp( ATTR_IMPLICIT_HANDLE, $3 ); } - | tIN { $$ = make_attr( ATTR_IN ); } - | tINPUTSYNC { $$ = make_attr( ATTR_INPUTSYNC ); } - | tLENGTHIS '(' m_exprs ')' { $$ = make_attrp( ATTR_LENGTHIS, $3 ); } - | tLCID '(' expr_int_const ')' { $$ = make_attrp( ATTR_LIBLCID, $3 ); } - | tLCID { $$ = make_attr( ATTR_PARAMLCID ); } - | tLICENSED { $$ = make_attr( ATTR_LICENSED ); } - | tLOCAL { $$ = make_attr( ATTR_LOCAL ); } + { $$ = attr_ptr( ATTR_HELPSTRINGCONTEXT, $3 ); } + | tHELPSTRINGDLL '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPSTRINGDLL, $3 ); } + | tHIDDEN { $$ = attr_int( ATTR_HIDDEN, 0 ); } + | tID '(' expr_int_const ')' { $$ = attr_ptr( ATTR_ID, $3 ); } + | tIDEMPOTENT { $$ = attr_int( ATTR_IDEMPOTENT, 0 ); } + | tIGNORE { $$ = attr_int( ATTR_IGNORE, 0 ); } + | tIIDIS '(' expr ')' { $$ = attr_ptr( ATTR_IIDIS, $3 ); } + | tIMMEDIATEBIND { $$ = attr_int( ATTR_IMMEDIATEBIND, 0 ); } + | tIMPLICITHANDLE '(' arg ')' { $$ = attr_ptr( ATTR_IMPLICIT_HANDLE, $3 ); } + | tIN { $$ = attr_int( ATTR_IN, 0 ); } + | tINPUTSYNC { $$ = attr_int( ATTR_INPUTSYNC, 0 ); } + | tLENGTHIS '(' m_exprs ')' { $$ = attr_ptr( ATTR_LENGTHIS, $3 ); } + | tLCID '(' expr_int_const ')' { $$ = attr_ptr( ATTR_LIBLCID, $3 ); } + | tLCID { $$ = attr_int( ATTR_PARAMLCID, 0 ); } + | tLICENSED { $$ = attr_int( ATTR_LICENSED, 0 ); } + | tLOCAL { $$ = attr_int( ATTR_LOCAL, 0 ); } | tMARSHALINGBEHAVIOR '(' marshaling_behavior ')' - { $$ = make_attrv( ATTR_MARSHALING_BEHAVIOR, $3 ); } - | tMAYBE { $$ = make_attr( ATTR_MAYBE ); } - | tMESSAGE { $$ = make_attr( ATTR_MESSAGE ); } - | tNOCODE { $$ = make_attr( ATTR_NOCODE ); } - | tNONBROWSABLE { $$ = make_attr( ATTR_NONBROWSABLE ); } - | tNONCREATABLE { $$ = make_attr( ATTR_NONCREATABLE ); } - | tNONEXTENSIBLE { $$ = make_attr( ATTR_NONEXTENSIBLE ); } - | tNOTIFY { $$ = make_attr( ATTR_NOTIFY ); } - | tNOTIFYFLAG { $$ = make_attr( ATTR_NOTIFYFLAG ); } - | tOBJECT { $$ = make_attr( ATTR_OBJECT ); } - | tODL { $$ = make_attr( ATTR_ODL ); } - | tOLEAUTOMATION { $$ = make_attr( ATTR_OLEAUTOMATION ); } - | tOPTIMIZE '(' aSTRING ')' { $$ = make_attrp( ATTR_OPTIMIZE, $3 ); } - | tOPTIONAL { $$ = make_attr( ATTR_OPTIONAL ); } - | tOUT { $$ = make_attr( ATTR_OUT ); } - | tOVERLOAD '(' aSTRING ')' { $$ = make_attrp( ATTR_OVERLOAD, $3 ); } - | tPARTIALIGNORE { $$ = make_attr( ATTR_PARTIALIGNORE ); } - | tPOINTERDEFAULT '(' pointer_type ')' { $$ = make_attrv( ATTR_POINTERDEFAULT, $3 ); } - | tPROGID '(' aSTRING ')' { $$ = make_attrp( ATTR_PROGID, $3 ); } - | tPROPGET { $$ = make_attr( ATTR_PROPGET ); } - | tPROPPUT { $$ = make_attr( ATTR_PROPPUT ); } - | tPROPPUTREF { $$ = make_attr( ATTR_PROPPUTREF ); } - | tPROXY { $$ = make_attr( ATTR_PROXY ); } - | tPUBLIC { $$ = make_attr( ATTR_PUBLIC ); } + { $$ = attr_int( ATTR_MARSHALING_BEHAVIOR, $3 ); } + | tMAYBE { $$ = attr_int( ATTR_MAYBE, 0 ); } + | tMESSAGE { $$ = attr_int( ATTR_MESSAGE, 0 ); } + | tNOCODE { $$ = attr_int( ATTR_NOCODE, 0 ); } + | tNONBROWSABLE { $$ = attr_int( ATTR_NONBROWSABLE, 0 ); } + | tNONCREATABLE { $$ = attr_int( ATTR_NONCREATABLE, 0 ); } + | tNONEXTENSIBLE { $$ = attr_int( ATTR_NONEXTENSIBLE, 0 ); } + | tNOTIFY { $$ = attr_int( ATTR_NOTIFY, 0 ); } + | tNOTIFYFLAG { $$ = attr_int( ATTR_NOTIFYFLAG, 0 ); } + | tOBJECT { $$ = attr_int( ATTR_OBJECT, 0 ); } + | tODL { $$ = attr_int( ATTR_ODL, 0 ); } + | tOLEAUTOMATION { $$ = attr_int( ATTR_OLEAUTOMATION, 0 ); } + | tOPTIMIZE '(' aSTRING ')' { $$ = attr_ptr( ATTR_OPTIMIZE, $3 ); } + | tOPTIONAL { $$ = attr_int( ATTR_OPTIONAL, 0 ); } + | tOUT { $$ = attr_int( ATTR_OUT, 0 ); } + | tOVERLOAD '(' aSTRING ')' { $$ = attr_ptr( ATTR_OVERLOAD, $3 ); } + | tPARTIALIGNORE { $$ = attr_int( ATTR_PARTIALIGNORE, 0 ); } + | tPOINTERDEFAULT '(' pointer_type ')' { $$ = attr_int( ATTR_POINTERDEFAULT, $3 ); } + | tPROGID '(' aSTRING ')' { $$ = attr_ptr( ATTR_PROGID, $3 ); } + | tPROPGET { $$ = attr_int( ATTR_PROPGET, 0 ); } + | tPROPPUT { $$ = attr_int( ATTR_PROPPUT, 0 ); } + | tPROPPUTREF { $$ = attr_int( ATTR_PROPPUTREF, 0 ); } + | tPROXY { $$ = attr_int( ATTR_PROXY, 0 ); } + | tPUBLIC { $$ = attr_int( ATTR_PUBLIC, 0 ); } | tRANGE '(' expr_int_const ',' expr_int_const ')' { expr_list_t *list = append_expr( NULL, $3 ); list = append_expr( list, $5 ); - $$ = make_attrp( ATTR_RANGE, list ); + $$ = attr_ptr( ATTR_RANGE, list ); } - | tREADONLY { $$ = make_attr( ATTR_READONLY ); } - | tREPRESENTAS '(' type ')' { $$ = make_attrp( ATTR_REPRESENTAS, $3 ); } - | tREQUESTEDIT { $$ = make_attr( ATTR_REQUESTEDIT ); } - | tRESTRICTED { $$ = make_attr( ATTR_RESTRICTED ); } - | tRETVAL { $$ = make_attr( ATTR_RETVAL ); } - | tSIZEIS '(' m_exprs ')' { $$ = make_attrp( ATTR_SIZEIS, $3 ); } - | tSOURCE { $$ = make_attr( ATTR_SOURCE ); } - | tSTATIC '(' static_attr ')' { $$ = make_attrp( ATTR_STATIC, $3 ); } - | tSTRICTCONTEXTHANDLE { $$ = make_attr( ATTR_STRICTCONTEXTHANDLE ); } - | tSTRING { $$ = make_attr( ATTR_STRING ); } - | tSWITCHIS '(' expr ')' { $$ = make_attrp( ATTR_SWITCHIS, $3 ); } - | tSWITCHTYPE '(' type ')' { $$ = make_attrp( ATTR_SWITCHTYPE, $3 ); } - | tTRANSMITAS '(' type ')' { $$ = make_attrp( ATTR_TRANSMITAS, $3 ); } - | tTHREADING '(' threading_type ')' { $$ = make_attrv( ATTR_THREADING, $3 ); } - | tUIDEFAULT { $$ = make_attr( ATTR_UIDEFAULT ); } - | tUSESGETLASTERROR { $$ = make_attr( ATTR_USESGETLASTERROR ); } - | tUSERMARSHAL '(' type ')' { $$ = make_attrp( ATTR_USERMARSHAL, $3 ); } - | tUUID '(' aUUID ')' { $$ = make_attrp( ATTR_UUID, $3 ); } - | tASYNCUUID '(' aUUID ')' { $$ = make_attrp( ATTR_ASYNCUUID, $3 ); } - | tV1ENUM { $$ = make_attr( ATTR_V1ENUM ); } - | tVARARG { $$ = make_attr( ATTR_VARARG ); } - | tVERSION '(' version ')' { $$ = make_attrv( ATTR_VERSION, $3 ); } - | tVIPROGID '(' aSTRING ')' { $$ = make_attrp( ATTR_VIPROGID, $3 ); } - | tWIREMARSHAL '(' type ')' { $$ = make_attrp( ATTR_WIREMARSHAL, $3 ); } - | pointer_type { $$ = make_attrv( ATTR_POINTERTYPE, $1 ); } + | tREADONLY { $$ = attr_int( ATTR_READONLY, 0 ); } + | tREPRESENTAS '(' type ')' { $$ = attr_ptr( ATTR_REPRESENTAS, $3 ); } + | tREQUESTEDIT { $$ = attr_int( ATTR_REQUESTEDIT, 0 ); } + | tRESTRICTED { $$ = attr_int( ATTR_RESTRICTED, 0 ); } + | tRETVAL { $$ = attr_int( ATTR_RETVAL, 0 ); } + | tSIZEIS '(' m_exprs ')' { $$ = attr_ptr( ATTR_SIZEIS, $3 ); } + | tSOURCE { $$ = attr_int( ATTR_SOURCE, 0 ); } + | tSTATIC '(' static_attr ')' { $$ = attr_ptr( ATTR_STATIC, $3 ); } + | tSTRICTCONTEXTHANDLE { $$ = attr_int( ATTR_STRICTCONTEXTHANDLE, 0 ); } + | tSTRING { $$ = attr_int( ATTR_STRING, 0 ); } + | tSWITCHIS '(' expr ')' { $$ = attr_ptr( ATTR_SWITCHIS, $3 ); } + | tSWITCHTYPE '(' type ')' { $$ = attr_ptr( ATTR_SWITCHTYPE, $3 ); } + | tTRANSMITAS '(' type ')' { $$ = attr_ptr( ATTR_TRANSMITAS, $3 ); } + | tTHREADING '(' threading_type ')' { $$ = attr_int( ATTR_THREADING, $3 ); } + | tUIDEFAULT { $$ = attr_int( ATTR_UIDEFAULT, 0 ); } + | tUSESGETLASTERROR { $$ = attr_int( ATTR_USESGETLASTERROR, 0 ); } + | tUSERMARSHAL '(' type ')' { $$ = attr_ptr( ATTR_USERMARSHAL, $3 ); } + | tUUID '(' aUUID ')' { $$ = attr_ptr( ATTR_UUID, $3 ); } + | tASYNCUUID '(' aUUID ')' { $$ = attr_ptr( ATTR_ASYNCUUID, $3 ); } + | tV1ENUM { $$ = attr_int( ATTR_V1ENUM, 0 ); } + | tVARARG { $$ = attr_int( ATTR_VARARG, 0 ); } + | tVERSION '(' version ')' { $$ = attr_int( ATTR_VERSION, $3 ); } + | tVIPROGID '(' aSTRING ')' { $$ = attr_ptr( ATTR_VIPROGID, $3 ); } + | tWIREMARSHAL '(' type ')' { $$ = attr_ptr( ATTR_WIREMARSHAL, $3 ); } + | pointer_type { $$ = attr_int( ATTR_POINTERTYPE, $1 ); } ;
callconv: tCDECL @@ -739,11 +739,11 @@ cases | cases case { $$ = append_var( $1, $2 ); } ;
-case : tCASE expr_int_const ':' union_field { attr_t *a = make_attrp( ATTR_CASE, append_expr( NULL, $2 ) ); +case : tCASE expr_int_const ':' union_field { attr_t *a = attr_ptr( ATTR_CASE, append_expr( NULL, $2 ) ); $$ = $4; if (!$$) $$ = make_var( NULL ); $$->attrs = append_attr( $$->attrs, a ); } - | tDEFAULT ':' union_field { attr_t *a = make_attr( ATTR_DEFAULT ); + | tDEFAULT ':' union_field { attr_t *a = attr_int( ATTR_DEFAULT, 0 ); $$ = $3; if (!$$) $$ = make_var( NULL ); $$->attrs = append_attr( $$->attrs, a ); } @@ -1028,7 +1028,7 @@ class_interface: dispinterface: tDISPINTERFACE typename { $$ = type_dispinterface_declare($2); } ;
-dispattributes: attributes { $$ = append_attr( $1, make_attr( ATTR_DISPINTERFACE ) ); } +dispattributes: attributes { $$ = append_attr( $1, attr_int( ATTR_DISPINTERFACE, 0 ) ); } ;
dispint_props: tPROPERTIES ':' { $$ = NULL; } @@ -1375,10 +1375,10 @@ acf_attribute_list
acf_attribute : tALLOCATE '(' allocate_option_list ')' - { $$ = make_attrv( ATTR_ALLOCATE, $3 ); } - | tENCODE { $$ = make_attr( ATTR_ENCODE ); } - | tDECODE { $$ = make_attr( ATTR_DECODE ); } - | tEXPLICITHANDLE { $$ = make_attr( ATTR_EXPLICIT_HANDLE ); } + { $$ = attr_int( ATTR_ALLOCATE, $3 ); } + | tENCODE { $$ = attr_int( ATTR_ENCODE, 0 ); } + | tDECODE { $$ = attr_int( ATTR_DECODE, 0 ); } + | tEXPLICITHANDLE { $$ = attr_int( ATTR_EXPLICIT_HANDLE, 0 ); } ;
allocate_option_list @@ -1638,7 +1638,7 @@ static void append_chain_callconv(type_t *chain, char *callconv) type_t *chain_end;
if (chain && (chain_end = get_chain_end(chain))) - chain_end->attrs = append_attr(chain_end->attrs, make_attrp(ATTR_CALLCONV, callconv)); + chain_end->attrs = append_attr( chain_end->attrs, attr_ptr( ATTR_CALLCONV, callconv ) ); else error_loc("calling convention applied to non-function type\n"); } @@ -2065,7 +2065,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at type_t *type = decl_spec->type;
if (is_attr(attrs, ATTR_UUID) && !is_attr(attrs, ATTR_PUBLIC)) - attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) ); + attrs = append_attr( attrs, attr_int( ATTR_PUBLIC, 0 ) );
/* We must generate names for tagless enum, struct or union. Typedef-ing a tagless enum, struct or union means we want the typedef @@ -2079,7 +2079,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at { type->name = gen_name(); if (!is_attr(attrs, ATTR_PUBLIC)) - attrs = append_attr(attrs, make_attr(ATTR_PUBLIC)); + attrs = append_attr( attrs, attr_int( ATTR_PUBLIC, 0 ) ); }
/* replace existing attributes when generating a typelib */ @@ -2580,7 +2580,7 @@ static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func) * "[in] handle_t IDL_handle" as the first parameter to the * function */ var_t *idl_handle = make_var(xstrdup("IDL_handle")); - idl_handle->attrs = append_attr(NULL, make_attr(ATTR_IN)); + idl_handle->attrs = append_attr( NULL, attr_int( ATTR_IN, 0 ) ); idl_handle->declspec.type = find_type_or_error(NULL, "handle_t"); type_function_add_head_arg(func->declspec.type, idl_handle); } @@ -2636,7 +2636,7 @@ static int async_iface_attrs(attr_list_t *attrs, const attr_t *attr) case ATTR_UUID: return 0; case ATTR_ASYNCUUID: - append_attr(attrs, make_attrp(ATTR_UUID, attr->u.pval)); + append_attr( attrs, attr_ptr( ATTR_UUID, attr->u.pval ) ); return 0; default: return 1; diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index b9173a33019..bad9ece185c 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -1268,7 +1268,7 @@ static void compute_interface_signature_uuid(type_t *iface) if (!(uuid = get_attrp(iface->attrs, ATTR_UUID))) { uuid = xmalloc(sizeof(*uuid)); - iface->attrs = append_attr(iface->attrs, make_attrp(ATTR_UUID, uuid)); + iface->attrs = append_attr( iface->attrs, attr_ptr( ATTR_UUID, uuid ) ); }
sha1_init(&ctx); diff --git a/tools/widl/widl.h b/tools/widl/widl.h index 04daeaa76c4..c22f619349e 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -97,9 +97,8 @@ extern void end_cplusplus_guard(FILE *fp);
/* attribute.c */
-extern attr_t *make_attr( enum attr_type attr_type ); -extern attr_t *make_attrv( enum attr_type attr_type, unsigned int val ); -extern attr_t *make_attrp( enum attr_type attr_type, void *val ); +extern attr_t *attr_int( enum attr_type attr_type, unsigned int val ); +extern attr_t *attr_ptr( enum attr_type attr_type, void *val ); extern attr_t *make_custom_attr( struct uuid *id, expr_t *pval );
extern int is_attr( const attr_list_t *list, enum attr_type attr_type );
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/attribute.c | 11 ----------- tools/widl/parser.y | 5 ++++- tools/widl/widl.h | 1 - 3 files changed, 4 insertions(+), 13 deletions(-)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index 46fb05d09e0..1234f0a1e40 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -40,17 +40,6 @@ attr_t *attr_ptr( enum attr_type attr_type, void *val ) return a; }
-attr_t *make_custom_attr( struct uuid *id, expr_t *pval ) -{ - attr_t *a = xmalloc( sizeof(attr_t) ); - attr_custdata_t *cstdata = xmalloc( sizeof(attr_custdata_t) ); - a->type = ATTR_CUSTOM; - cstdata->id = *id; - cstdata->pval = pval; - a->u.pval = cstdata; - return a; -} - int is_attr( const attr_list_t *list, enum attr_type attr_type ) { const attr_t *attr; diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 86a07b175f4..77e9fadff6f 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -625,7 +625,10 @@ attribute | tCONTRACT '(' contract_req ')' { $$ = attr_ptr( ATTR_CONTRACT, $3 ); } | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_int( ATTR_CONTRACTVERSION, $3 ); } | tCONTROL { $$ = attr_int( ATTR_CONTROL, 0 ); } - | tCUSTOM '(' aUUID ',' expr_const ')' { $$ = make_custom_attr( $3, $5 ); } + | tCUSTOM '(' aUUID ',' expr_const ')' { attr_custdata_t *data = xmalloc( sizeof(*data) ); + data->id = *$3; data->pval = $5; + $$ = attr_ptr( ATTR_CUSTOM, data ); + } | tDECODE { $$ = attr_int( ATTR_DECODE, 0 ); } | tDEFAULT { $$ = attr_int( ATTR_DEFAULT, 0 ); } | tDEFAULTBIND { $$ = attr_int( ATTR_DEFAULTBIND, 0 ); } diff --git a/tools/widl/widl.h b/tools/widl/widl.h index c22f619349e..b8f1eb8d4c0 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -99,7 +99,6 @@ extern void end_cplusplus_guard(FILE *fp);
extern attr_t *attr_int( enum attr_type attr_type, unsigned int val ); extern attr_t *attr_ptr( enum attr_type attr_type, void *val ); -extern attr_t *make_custom_attr( struct uuid *id, expr_t *pval );
extern int is_attr( const attr_list_t *list, enum attr_type attr_type ); extern int is_ptrchain_attr( const var_t *var, enum attr_type attr_type );
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/attribute.c | 70 +++++------ tools/widl/parser.y | 264 ++++++++++++++++++++--------------------- tools/widl/typetree.c | 2 +- tools/widl/widl.h | 4 +- tools/widl/widltypes.h | 1 + 5 files changed, 172 insertions(+), 169 deletions(-)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index 1234f0a1e40..bceca3da46a 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -24,17 +24,19 @@
#include "parser.tab.h"
-attr_t *attr_int( enum attr_type attr_type, unsigned int val ) +attr_t *attr_int( struct location where, enum attr_type attr_type, unsigned int val ) { attr_t *a = xmalloc( sizeof(attr_t) ); + a->where = where; a->type = attr_type; a->u.ival = val; return a; }
-attr_t *attr_ptr( enum attr_type attr_type, void *val ) +attr_t *attr_ptr( struct location where, enum attr_type attr_type, void *val ) { attr_t *a = xmalloc( sizeof(attr_t) ); + a->where = where; a->type = attr_type; a->u.pval = val; return a; @@ -338,8 +340,8 @@ attr_list_t *check_apicontract_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_apicontract) - error_loc( "inapplicable attribute %s for apicontract %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for apicontract %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -351,8 +353,8 @@ attr_list_t *check_coclass_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_coclass) - error_loc( "inapplicable attribute %s for coclass %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for coclass %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -364,8 +366,8 @@ attr_list_t *check_dispiface_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_dispinterface) - error_loc( "inapplicable attribute %s for dispinterface %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for dispinterface %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -377,8 +379,8 @@ attr_list_t *check_enum_attrs( attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_enum) - error_loc( "inapplicable attribute %s for enum\n", - allowed_attr[attr->type].display_name ); + error_at( &attr->where, "inapplicable attribute %s for enum\n", + allowed_attr[attr->type].display_name ); } return attrs; } @@ -390,8 +392,8 @@ attr_list_t *check_enum_member_attrs( attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_enum_member) - error_loc( "inapplicable attribute %s for enum member\n", - allowed_attr[attr->type].display_name ); + error_at( &attr->where, "inapplicable attribute %s for enum member\n", + allowed_attr[attr->type].display_name ); } return attrs; } @@ -403,8 +405,8 @@ attr_list_t *check_field_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_field) - error_loc( "inapplicable attribute %s for field %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for field %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -416,8 +418,8 @@ attr_list_t *check_function_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_function) - error_loc( "inapplicable attribute %s for function %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for function %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -429,8 +431,8 @@ attr_list_t *check_interface_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_interface) - error_loc( "inapplicable attribute %s for interface %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for interface %s\n", + allowed_attr[attr->type].display_name, name ); if (attr->type == ATTR_IMPLICIT_HANDLE) { const var_t *var = attr->u.pval; @@ -438,8 +440,8 @@ attr_list_t *check_interface_attrs( const char *name, attr_list_t *attrs ) type_basic_get_type( var->declspec.type ) == TYPE_BASIC_HANDLE) continue; if (is_aliaschain_attr( var->declspec.type, ATTR_HANDLE )) continue; - error_loc( "attribute %s requires a handle type in interface %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "attribute %s requires a handle type in interface %s\n", + allowed_attr[attr->type].display_name, name ); } } return attrs; @@ -452,8 +454,8 @@ attr_list_t *check_library_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_library) - error_loc( "inapplicable attribute %s for library %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for library %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -465,8 +467,8 @@ attr_list_t *check_module_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_module) - error_loc( "inapplicable attribute %s for module %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for module %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -478,8 +480,8 @@ attr_list_t *check_runtimeclass_attrs( const char *name, attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_runtimeclass) - error_loc( "inapplicable attribute %s for runtimeclass %s\n", - allowed_attr[attr->type].display_name, name ); + error_at( &attr->where, "inapplicable attribute %s for runtimeclass %s\n", + allowed_attr[attr->type].display_name, name ); } return attrs; } @@ -492,8 +494,8 @@ attr_list_t *check_struct_attrs( attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!(allowed_attr[attr->type].on_struct & mask)) - error_loc( "inapplicable attribute %s for struct\n", - allowed_attr[attr->type].display_name ); + error_at( &attr->where, "inapplicable attribute %s for struct\n", + allowed_attr[attr->type].display_name ); } return attrs; } @@ -505,8 +507,8 @@ attr_list_t *check_typedef_attrs( attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_type) - error_loc( "inapplicable attribute %s for typedef\n", - allowed_attr[attr->type].display_name ); + error_at( &attr->where, "inapplicable attribute %s for typedef\n", + allowed_attr[attr->type].display_name ); } return attrs; } @@ -518,8 +520,8 @@ attr_list_t *check_union_attrs( attr_list_t *attrs ) LIST_FOR_EACH_ENTRY( attr, attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_union) - error_loc( "inapplicable attribute %s for union\n", - allowed_attr[attr->type].display_name ); + error_at( &attr->where, "inapplicable attribute %s for union\n", + allowed_attr[attr->type].display_name ); } return attrs; } @@ -531,7 +533,7 @@ void check_arg_attrs( const var_t *arg ) LIST_FOR_EACH_ENTRY( attr, arg->attrs, const attr_t, entry ) { if (!allowed_attr[attr->type].on_arg) - error_loc( "inapplicable attribute %s for argument %s\n", - allowed_attr[attr->type].display_name, arg->name ); + error_at( &attr->where, "inapplicable attribute %s for argument %s\n", + allowed_attr[attr->type].display_name, arg->name ); } } diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 77e9fadff6f..e3476f6ded8 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -57,10 +57,10 @@ static type_t *make_safearray(type_t *type); static typelib_t *make_library(const char *name, const attr_list_t *attrs); static void append_array(declarator_t *decl, expr_t *expr); static void append_chain_type(declarator_t *decl, type_t *type, enum type_qualifier qual); -static void append_chain_callconv(type_t *chain, char *callconv); +static void append_chain_callconv( struct location where, type_t *chain, char *callconv ); static warning_list_t *append_warning(warning_list_t *, int);
-static type_t *reg_typedefs(decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs); +static type_t *reg_typedefs( struct location where, decl_spec_t *decl_spec, var_list_t *names, attr_list_t *attrs ); static type_t *find_type_or_error(struct namespace *parent, const char *name); static struct namespace *find_namespace_or_error(struct namespace *namespace, const char *name);
@@ -607,128 +607,128 @@ activatable_attr:
attribute : %empty { $$ = NULL; } - | tACTIVATABLE '(' activatable_attr ')' { $$ = attr_ptr( ATTR_ACTIVATABLE, $3 ); } - | tAGGREGATABLE { $$ = attr_int( ATTR_AGGREGATABLE, 0 ); } - | tANNOTATION '(' aSTRING ')' { $$ = attr_ptr( ATTR_ANNOTATION, $3 ); } - | tAPPOBJECT { $$ = attr_int( ATTR_APPOBJECT, 0 ); } - | tASYNC { $$ = attr_int( ATTR_ASYNC, 0 ); } - | tAUTOHANDLE { $$ = attr_int( ATTR_AUTO_HANDLE, 0 ); } - | tBINDABLE { $$ = attr_int( ATTR_BINDABLE, 0 ); } - | tBROADCAST { $$ = attr_int( ATTR_BROADCAST, 0 ); } - | tCALLAS '(' ident ')' { $$ = attr_ptr( ATTR_CALLAS, $3 ); } - | tCASE '(' expr_list_int_const ')' { $$ = attr_ptr( ATTR_CASE, $3 ); } - | tCODE { $$ = attr_int( ATTR_CODE, 0 ); } - | tCOMMSTATUS { $$ = attr_int( ATTR_COMMSTATUS, 0 ); } - | tCONTEXTHANDLE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); } - | tCONTEXTHANDLENOSERIALIZE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } - | tCONTEXTHANDLESERIALIZE { $$ = attr_int( ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } - | tCONTRACT '(' contract_req ')' { $$ = attr_ptr( ATTR_CONTRACT, $3 ); } - | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_int( ATTR_CONTRACTVERSION, $3 ); } - | tCONTROL { $$ = attr_int( ATTR_CONTROL, 0 ); } + | tACTIVATABLE '(' activatable_attr ')' { $$ = attr_ptr( @$, ATTR_ACTIVATABLE, $3 ); } + | tAGGREGATABLE { $$ = attr_int( @$, ATTR_AGGREGATABLE, 0 ); } + | tANNOTATION '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_ANNOTATION, $3 ); } + | tAPPOBJECT { $$ = attr_int( @$, ATTR_APPOBJECT, 0 ); } + | tASYNC { $$ = attr_int( @$, ATTR_ASYNC, 0 ); } + | tAUTOHANDLE { $$ = attr_int( @$, ATTR_AUTO_HANDLE, 0 ); } + | tBINDABLE { $$ = attr_int( @$, ATTR_BINDABLE, 0 ); } + | tBROADCAST { $$ = attr_int( @$, ATTR_BROADCAST, 0 ); } + | tCALLAS '(' ident ')' { $$ = attr_ptr( @$, ATTR_CALLAS, $3 ); } + | tCASE '(' expr_list_int_const ')' { $$ = attr_ptr( @$, ATTR_CASE, $3 ); } + | tCODE { $$ = attr_int( @$, ATTR_CODE, 0 ); } + | tCOMMSTATUS { $$ = attr_int( @$, ATTR_COMMSTATUS, 0 ); } + | tCONTEXTHANDLE { $$ = attr_int( @$, ATTR_CONTEXTHANDLE, 0 ); } + | tCONTEXTHANDLENOSERIALIZE { $$ = attr_int( @$, ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_DONT_SERIALIZE */ } + | tCONTEXTHANDLESERIALIZE { $$ = attr_int( @$, ATTR_CONTEXTHANDLE, 0 ); /* RPC_CONTEXT_HANDLE_SERIALIZE */ } + | tCONTRACT '(' contract_req ')' { $$ = attr_ptr( @$, ATTR_CONTRACT, $3 ); } + | tCONTRACTVERSION '(' contract_ver ')' { $$ = attr_int( @$, ATTR_CONTRACTVERSION, $3 ); } + | tCONTROL { $$ = attr_int( @$, ATTR_CONTROL, 0 ); } | tCUSTOM '(' aUUID ',' expr_const ')' { attr_custdata_t *data = xmalloc( sizeof(*data) ); data->id = *$3; data->pval = $5; - $$ = attr_ptr( ATTR_CUSTOM, data ); + $$ = attr_ptr( @$, ATTR_CUSTOM, data ); } - | tDECODE { $$ = attr_int( ATTR_DECODE, 0 ); } - | tDEFAULT { $$ = attr_int( ATTR_DEFAULT, 0 ); } - | tDEFAULTBIND { $$ = attr_int( ATTR_DEFAULTBIND, 0 ); } - | tDEFAULTCOLLELEM { $$ = attr_int( ATTR_DEFAULTCOLLELEM, 0 ); } - | tDEFAULTVALUE '(' expr_const ')' { $$ = attr_ptr( ATTR_DEFAULTVALUE, $3 ); } - | tDEFAULTVTABLE { $$ = attr_int( ATTR_DEFAULTVTABLE, 0 ); } - | tDISABLECONSISTENCYCHECK { $$ = attr_int( ATTR_DISABLECONSISTENCYCHECK, 0 ); } - | tDISPLAYBIND { $$ = attr_int( ATTR_DISPLAYBIND, 0 ); } - | tDLLNAME '(' aSTRING ')' { $$ = attr_ptr( ATTR_DLLNAME, $3 ); } - | tDUAL { $$ = attr_int( ATTR_DUAL, 0 ); } - | tENABLEALLOCATE { $$ = attr_int( ATTR_ENABLEALLOCATE, 0 ); } - | tENCODE { $$ = attr_int( ATTR_ENCODE, 0 ); } - | tENDPOINT '(' str_list ')' { $$ = attr_ptr( ATTR_ENDPOINT, $3 ); } - | tENTRY '(' expr_const ')' { $$ = attr_ptr( ATTR_ENTRY, $3 ); } - | tEVENTADD { $$ = attr_int( ATTR_EVENTADD, 0 ); } - | tEVENTREMOVE { $$ = attr_int( ATTR_EVENTREMOVE, 0 ); } + | tDECODE { $$ = attr_int( @$, ATTR_DECODE, 0 ); } + | tDEFAULT { $$ = attr_int( @$, ATTR_DEFAULT, 0 ); } + | tDEFAULTBIND { $$ = attr_int( @$, ATTR_DEFAULTBIND, 0 ); } + | tDEFAULTCOLLELEM { $$ = attr_int( @$, ATTR_DEFAULTCOLLELEM, 0 ); } + | tDEFAULTVALUE '(' expr_const ')' { $$ = attr_ptr( @$, ATTR_DEFAULTVALUE, $3 ); } + | tDEFAULTVTABLE { $$ = attr_int( @$, ATTR_DEFAULTVTABLE, 0 ); } + | tDISABLECONSISTENCYCHECK { $$ = attr_int( @$, ATTR_DISABLECONSISTENCYCHECK, 0 ); } + | tDISPLAYBIND { $$ = attr_int( @$, ATTR_DISPLAYBIND, 0 ); } + | tDLLNAME '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_DLLNAME, $3 ); } + | tDUAL { $$ = attr_int( @$, ATTR_DUAL, 0 ); } + | tENABLEALLOCATE { $$ = attr_int( @$, ATTR_ENABLEALLOCATE, 0 ); } + | tENCODE { $$ = attr_int( @$, ATTR_ENCODE, 0 ); } + | tENDPOINT '(' str_list ')' { $$ = attr_ptr( @$, ATTR_ENDPOINT, $3 ); } + | tENTRY '(' expr_const ')' { $$ = attr_ptr( @$, ATTR_ENTRY, $3 ); } + | tEVENTADD { $$ = attr_int( @$, ATTR_EVENTADD, 0 ); } + | tEVENTREMOVE { $$ = attr_int( @$, ATTR_EVENTREMOVE, 0 ); } | tEXCLUSIVETO '(' decl_spec ')' { if ($3->type->type_type != TYPE_RUNTIMECLASS) error_loc( "type %s is not a runtimeclass\n", $3->type->name ); - $$ = attr_ptr( ATTR_EXCLUSIVETO, $3->type ); + $$ = attr_ptr( @$, ATTR_EXCLUSIVETO, $3->type ); } - | tEXPLICITHANDLE { $$ = attr_int( ATTR_EXPLICIT_HANDLE, 0 ); } - | tFAULTSTATUS { $$ = attr_int( ATTR_FAULTSTATUS, 0 ); } - | tFLAGS { $$ = attr_int( ATTR_FLAGS, 0 ); } - | tFORCEALLOCATE { $$ = attr_int( ATTR_FORCEALLOCATE, 0 ); } - | tHANDLE { $$ = attr_int( ATTR_HANDLE, 0 ); } - | tHELPCONTEXT '(' expr_int_const ')' { $$ = attr_ptr( ATTR_HELPCONTEXT, $3 ); } - | tHELPFILE '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPFILE, $3 ); } - | tHELPSTRING '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPSTRING, $3 ); } + | tEXPLICITHANDLE { $$ = attr_int( @$, ATTR_EXPLICIT_HANDLE, 0 ); } + | tFAULTSTATUS { $$ = attr_int( @$, ATTR_FAULTSTATUS, 0 ); } + | tFLAGS { $$ = attr_int( @$, ATTR_FLAGS, 0 ); } + | tFORCEALLOCATE { $$ = attr_int( @$, ATTR_FORCEALLOCATE, 0 ); } + | tHANDLE { $$ = attr_int( @$, ATTR_HANDLE, 0 ); } + | tHELPCONTEXT '(' expr_int_const ')' { $$ = attr_ptr( @$, ATTR_HELPCONTEXT, $3 ); } + | tHELPFILE '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_HELPFILE, $3 ); } + | tHELPSTRING '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_HELPSTRING, $3 ); } | tHELPSTRINGCONTEXT '(' expr_int_const ')' - { $$ = attr_ptr( ATTR_HELPSTRINGCONTEXT, $3 ); } - | tHELPSTRINGDLL '(' aSTRING ')' { $$ = attr_ptr( ATTR_HELPSTRINGDLL, $3 ); } - | tHIDDEN { $$ = attr_int( ATTR_HIDDEN, 0 ); } - | tID '(' expr_int_const ')' { $$ = attr_ptr( ATTR_ID, $3 ); } - | tIDEMPOTENT { $$ = attr_int( ATTR_IDEMPOTENT, 0 ); } - | tIGNORE { $$ = attr_int( ATTR_IGNORE, 0 ); } - | tIIDIS '(' expr ')' { $$ = attr_ptr( ATTR_IIDIS, $3 ); } - | tIMMEDIATEBIND { $$ = attr_int( ATTR_IMMEDIATEBIND, 0 ); } - | tIMPLICITHANDLE '(' arg ')' { $$ = attr_ptr( ATTR_IMPLICIT_HANDLE, $3 ); } - | tIN { $$ = attr_int( ATTR_IN, 0 ); } - | tINPUTSYNC { $$ = attr_int( ATTR_INPUTSYNC, 0 ); } - | tLENGTHIS '(' m_exprs ')' { $$ = attr_ptr( ATTR_LENGTHIS, $3 ); } - | tLCID '(' expr_int_const ')' { $$ = attr_ptr( ATTR_LIBLCID, $3 ); } - | tLCID { $$ = attr_int( ATTR_PARAMLCID, 0 ); } - | tLICENSED { $$ = attr_int( ATTR_LICENSED, 0 ); } - | tLOCAL { $$ = attr_int( ATTR_LOCAL, 0 ); } + { $$ = attr_ptr( @$, ATTR_HELPSTRINGCONTEXT, $3 ); } + | tHELPSTRINGDLL '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_HELPSTRINGDLL, $3 ); } + | tHIDDEN { $$ = attr_int( @$, ATTR_HIDDEN, 0 ); } + | tID '(' expr_int_const ')' { $$ = attr_ptr( @$, ATTR_ID, $3 ); } + | tIDEMPOTENT { $$ = attr_int( @$, ATTR_IDEMPOTENT, 0 ); } + | tIGNORE { $$ = attr_int( @$, ATTR_IGNORE, 0 ); } + | tIIDIS '(' expr ')' { $$ = attr_ptr( @$, ATTR_IIDIS, $3 ); } + | tIMMEDIATEBIND { $$ = attr_int( @$, ATTR_IMMEDIATEBIND, 0 ); } + | tIMPLICITHANDLE '(' arg ')' { $$ = attr_ptr( @$, ATTR_IMPLICIT_HANDLE, $3 ); } + | tIN { $$ = attr_int( @$, ATTR_IN, 0 ); } + | tINPUTSYNC { $$ = attr_int( @$, ATTR_INPUTSYNC, 0 ); } + | tLENGTHIS '(' m_exprs ')' { $$ = attr_ptr( @$, ATTR_LENGTHIS, $3 ); } + | tLCID '(' expr_int_const ')' { $$ = attr_ptr( @$, ATTR_LIBLCID, $3 ); } + | tLCID { $$ = attr_int( @$, ATTR_PARAMLCID, 0 ); } + | tLICENSED { $$ = attr_int( @$, ATTR_LICENSED, 0 ); } + | tLOCAL { $$ = attr_int( @$, ATTR_LOCAL, 0 ); } | tMARSHALINGBEHAVIOR '(' marshaling_behavior ')' - { $$ = attr_int( ATTR_MARSHALING_BEHAVIOR, $3 ); } - | tMAYBE { $$ = attr_int( ATTR_MAYBE, 0 ); } - | tMESSAGE { $$ = attr_int( ATTR_MESSAGE, 0 ); } - | tNOCODE { $$ = attr_int( ATTR_NOCODE, 0 ); } - | tNONBROWSABLE { $$ = attr_int( ATTR_NONBROWSABLE, 0 ); } - | tNONCREATABLE { $$ = attr_int( ATTR_NONCREATABLE, 0 ); } - | tNONEXTENSIBLE { $$ = attr_int( ATTR_NONEXTENSIBLE, 0 ); } - | tNOTIFY { $$ = attr_int( ATTR_NOTIFY, 0 ); } - | tNOTIFYFLAG { $$ = attr_int( ATTR_NOTIFYFLAG, 0 ); } - | tOBJECT { $$ = attr_int( ATTR_OBJECT, 0 ); } - | tODL { $$ = attr_int( ATTR_ODL, 0 ); } - | tOLEAUTOMATION { $$ = attr_int( ATTR_OLEAUTOMATION, 0 ); } - | tOPTIMIZE '(' aSTRING ')' { $$ = attr_ptr( ATTR_OPTIMIZE, $3 ); } - | tOPTIONAL { $$ = attr_int( ATTR_OPTIONAL, 0 ); } - | tOUT { $$ = attr_int( ATTR_OUT, 0 ); } - | tOVERLOAD '(' aSTRING ')' { $$ = attr_ptr( ATTR_OVERLOAD, $3 ); } - | tPARTIALIGNORE { $$ = attr_int( ATTR_PARTIALIGNORE, 0 ); } - | tPOINTERDEFAULT '(' pointer_type ')' { $$ = attr_int( ATTR_POINTERDEFAULT, $3 ); } - | tPROGID '(' aSTRING ')' { $$ = attr_ptr( ATTR_PROGID, $3 ); } - | tPROPGET { $$ = attr_int( ATTR_PROPGET, 0 ); } - | tPROPPUT { $$ = attr_int( ATTR_PROPPUT, 0 ); } - | tPROPPUTREF { $$ = attr_int( ATTR_PROPPUTREF, 0 ); } - | tPROXY { $$ = attr_int( ATTR_PROXY, 0 ); } - | tPUBLIC { $$ = attr_int( ATTR_PUBLIC, 0 ); } + { $$ = attr_int( @$, ATTR_MARSHALING_BEHAVIOR, $3 ); } + | tMAYBE { $$ = attr_int( @$, ATTR_MAYBE, 0 ); } + | tMESSAGE { $$ = attr_int( @$, ATTR_MESSAGE, 0 ); } + | tNOCODE { $$ = attr_int( @$, ATTR_NOCODE, 0 ); } + | tNONBROWSABLE { $$ = attr_int( @$, ATTR_NONBROWSABLE, 0 ); } + | tNONCREATABLE { $$ = attr_int( @$, ATTR_NONCREATABLE, 0 ); } + | tNONEXTENSIBLE { $$ = attr_int( @$, ATTR_NONEXTENSIBLE, 0 ); } + | tNOTIFY { $$ = attr_int( @$, ATTR_NOTIFY, 0 ); } + | tNOTIFYFLAG { $$ = attr_int( @$, ATTR_NOTIFYFLAG, 0 ); } + | tOBJECT { $$ = attr_int( @$, ATTR_OBJECT, 0 ); } + | tODL { $$ = attr_int( @$, ATTR_ODL, 0 ); } + | tOLEAUTOMATION { $$ = attr_int( @$, ATTR_OLEAUTOMATION, 0 ); } + | tOPTIMIZE '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_OPTIMIZE, $3 ); } + | tOPTIONAL { $$ = attr_int( @$, ATTR_OPTIONAL, 0 ); } + | tOUT { $$ = attr_int( @$, ATTR_OUT, 0 ); } + | tOVERLOAD '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_OVERLOAD, $3 ); } + | tPARTIALIGNORE { $$ = attr_int( @$, ATTR_PARTIALIGNORE, 0 ); } + | tPOINTERDEFAULT '(' pointer_type ')' { $$ = attr_int( @$, ATTR_POINTERDEFAULT, $3 ); } + | tPROGID '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_PROGID, $3 ); } + | tPROPGET { $$ = attr_int( @$, ATTR_PROPGET, 0 ); } + | tPROPPUT { $$ = attr_int( @$, ATTR_PROPPUT, 0 ); } + | tPROPPUTREF { $$ = attr_int( @$, ATTR_PROPPUTREF, 0 ); } + | tPROXY { $$ = attr_int( @$, ATTR_PROXY, 0 ); } + | tPUBLIC { $$ = attr_int( @$, ATTR_PUBLIC, 0 ); } | tRANGE '(' expr_int_const ',' expr_int_const ')' { expr_list_t *list = append_expr( NULL, $3 ); list = append_expr( list, $5 ); - $$ = attr_ptr( ATTR_RANGE, list ); + $$ = attr_ptr( @$, ATTR_RANGE, list ); } - | tREADONLY { $$ = attr_int( ATTR_READONLY, 0 ); } - | tREPRESENTAS '(' type ')' { $$ = attr_ptr( ATTR_REPRESENTAS, $3 ); } - | tREQUESTEDIT { $$ = attr_int( ATTR_REQUESTEDIT, 0 ); } - | tRESTRICTED { $$ = attr_int( ATTR_RESTRICTED, 0 ); } - | tRETVAL { $$ = attr_int( ATTR_RETVAL, 0 ); } - | tSIZEIS '(' m_exprs ')' { $$ = attr_ptr( ATTR_SIZEIS, $3 ); } - | tSOURCE { $$ = attr_int( ATTR_SOURCE, 0 ); } - | tSTATIC '(' static_attr ')' { $$ = attr_ptr( ATTR_STATIC, $3 ); } - | tSTRICTCONTEXTHANDLE { $$ = attr_int( ATTR_STRICTCONTEXTHANDLE, 0 ); } - | tSTRING { $$ = attr_int( ATTR_STRING, 0 ); } - | tSWITCHIS '(' expr ')' { $$ = attr_ptr( ATTR_SWITCHIS, $3 ); } - | tSWITCHTYPE '(' type ')' { $$ = attr_ptr( ATTR_SWITCHTYPE, $3 ); } - | tTRANSMITAS '(' type ')' { $$ = attr_ptr( ATTR_TRANSMITAS, $3 ); } - | tTHREADING '(' threading_type ')' { $$ = attr_int( ATTR_THREADING, $3 ); } - | tUIDEFAULT { $$ = attr_int( ATTR_UIDEFAULT, 0 ); } - | tUSESGETLASTERROR { $$ = attr_int( ATTR_USESGETLASTERROR, 0 ); } - | tUSERMARSHAL '(' type ')' { $$ = attr_ptr( ATTR_USERMARSHAL, $3 ); } - | tUUID '(' aUUID ')' { $$ = attr_ptr( ATTR_UUID, $3 ); } - | tASYNCUUID '(' aUUID ')' { $$ = attr_ptr( ATTR_ASYNCUUID, $3 ); } - | tV1ENUM { $$ = attr_int( ATTR_V1ENUM, 0 ); } - | tVARARG { $$ = attr_int( ATTR_VARARG, 0 ); } - | tVERSION '(' version ')' { $$ = attr_int( ATTR_VERSION, $3 ); } - | tVIPROGID '(' aSTRING ')' { $$ = attr_ptr( ATTR_VIPROGID, $3 ); } - | tWIREMARSHAL '(' type ')' { $$ = attr_ptr( ATTR_WIREMARSHAL, $3 ); } - | pointer_type { $$ = attr_int( ATTR_POINTERTYPE, $1 ); } + | tREADONLY { $$ = attr_int( @$, ATTR_READONLY, 0 ); } + | tREPRESENTAS '(' type ')' { $$ = attr_ptr( @$, ATTR_REPRESENTAS, $3 ); } + | tREQUESTEDIT { $$ = attr_int( @$, ATTR_REQUESTEDIT, 0 ); } + | tRESTRICTED { $$ = attr_int( @$, ATTR_RESTRICTED, 0 ); } + | tRETVAL { $$ = attr_int( @$, ATTR_RETVAL, 0 ); } + | tSIZEIS '(' m_exprs ')' { $$ = attr_ptr( @$, ATTR_SIZEIS, $3 ); } + | tSOURCE { $$ = attr_int( @$, ATTR_SOURCE, 0 ); } + | tSTATIC '(' static_attr ')' { $$ = attr_ptr( @$, ATTR_STATIC, $3 ); } + | tSTRICTCONTEXTHANDLE { $$ = attr_int( @$, ATTR_STRICTCONTEXTHANDLE, 0 ); } + | tSTRING { $$ = attr_int( @$, ATTR_STRING, 0 ); } + | tSWITCHIS '(' expr ')' { $$ = attr_ptr( @$, ATTR_SWITCHIS, $3 ); } + | tSWITCHTYPE '(' type ')' { $$ = attr_ptr( @$, ATTR_SWITCHTYPE, $3 ); } + | tTRANSMITAS '(' type ')' { $$ = attr_ptr( @$, ATTR_TRANSMITAS, $3 ); } + | tTHREADING '(' threading_type ')' { $$ = attr_int( @$, ATTR_THREADING, $3 ); } + | tUIDEFAULT { $$ = attr_int( @$, ATTR_UIDEFAULT, 0 ); } + | tUSESGETLASTERROR { $$ = attr_int( @$, ATTR_USESGETLASTERROR, 0 ); } + | tUSERMARSHAL '(' type ')' { $$ = attr_ptr( @$, ATTR_USERMARSHAL, $3 ); } + | tUUID '(' aUUID ')' { $$ = attr_ptr( @$, ATTR_UUID, $3 ); } + | tASYNCUUID '(' aUUID ')' { $$ = attr_ptr( @$, ATTR_ASYNCUUID, $3 ); } + | tV1ENUM { $$ = attr_int( @$, ATTR_V1ENUM, 0 ); } + | tVARARG { $$ = attr_int( @$, ATTR_VARARG, 0 ); } + | tVERSION '(' version ')' { $$ = attr_int( @$, ATTR_VERSION, $3 ); } + | tVIPROGID '(' aSTRING ')' { $$ = attr_ptr( @$, ATTR_VIPROGID, $3 ); } + | tWIREMARSHAL '(' type ')' { $$ = attr_ptr( @$, ATTR_WIREMARSHAL, $3 ); } + | pointer_type { $$ = attr_int( @$, ATTR_POINTERTYPE, $1 ); } ;
callconv: tCDECL @@ -742,11 +742,11 @@ cases | cases case { $$ = append_var( $1, $2 ); } ;
-case : tCASE expr_int_const ':' union_field { attr_t *a = attr_ptr( ATTR_CASE, append_expr( NULL, $2 ) ); +case : tCASE expr_int_const ':' union_field { attr_t *a = attr_ptr( @$, ATTR_CASE, append_expr( NULL, $2 ) ); $$ = $4; if (!$$) $$ = make_var( NULL ); $$->attrs = append_attr( $$->attrs, a ); } - | tDEFAULT ':' union_field { attr_t *a = attr_int( ATTR_DEFAULT, 0 ); + | tDEFAULT ':' union_field { attr_t *a = attr_int( @$, ATTR_DEFAULT, 0 ); $$ = $3; if (!$$) $$ = make_var( NULL ); $$->attrs = append_attr( $$->attrs, a ); } @@ -1031,7 +1031,7 @@ class_interface: dispinterface: tDISPINTERFACE typename { $$ = type_dispinterface_declare($2); } ;
-dispattributes: attributes { $$ = append_attr( $1, attr_int( ATTR_DISPINTERFACE, 0 ) ); } +dispattributes: attributes { $$ = append_attr( $1, attr_int( @$, ATTR_DISPINTERFACE, 0 ) ); } ;
dispint_props: tPROPERTIES ':' { $$ = NULL; } @@ -1170,7 +1170,7 @@ decl_spec_no_type: declarator: '*' m_type_qual_list declarator %prec PPTR { $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); } - | callconv declarator { $$ = $2; append_chain_callconv($$->type, $1); } + | callconv declarator { $$ = $2; append_chain_callconv( @$, $$->type, $1 ); } | direct_declarator ;
@@ -1185,7 +1185,7 @@ direct_declarator: abstract_declarator: '*' m_type_qual_list m_abstract_declarator %prec PPTR { $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); } - | callconv m_abstract_declarator { $$ = $2; append_chain_callconv($$->type, $1); } + | callconv m_abstract_declarator { $$ = $2; append_chain_callconv( @$, $$->type, $1 ); } | abstract_direct_declarator ;
@@ -1193,7 +1193,7 @@ abstract_declarator: abstract_declarator_no_direct: '*' m_type_qual_list m_any_declarator %prec PPTR { $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); } - | callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); } + | callconv m_any_declarator { $$ = $2; append_chain_callconv( @$, $$->type, $1 ); } ;
/* abstract declarator or empty */ @@ -1221,7 +1221,7 @@ abstract_direct_declarator: any_declarator: '*' m_type_qual_list m_any_declarator %prec PPTR { $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); } - | callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); } + | callconv m_any_declarator { $$ = $2; append_chain_callconv( @$, $$->type, $1 ); } | any_direct_declarator ;
@@ -1229,7 +1229,7 @@ any_declarator: any_declarator_no_direct: '*' m_type_qual_list m_any_declarator %prec PPTR { $$ = $3; append_chain_type($$, type_new_pointer(NULL), $2); } - | callconv m_any_declarator { $$ = $2; append_chain_callconv($$->type, $1); } + | callconv m_any_declarator { $$ = $2; append_chain_callconv( @$, $$->type, $1 ); } ;
/* abstract or non-abstract declarator or empty */ @@ -1322,7 +1322,7 @@ type:
typedef: m_attributes tTYPEDEF m_attributes decl_spec declarator_list { $1 = append_attribs($1, $3); - reg_typedefs($4, $5, check_typedef_attrs($1)); + reg_typedefs( @$, $4, $5, check_typedef_attrs( $1 ) ); $$ = make_statement_typedef($5, !$4->type->defined); } ; @@ -1378,10 +1378,10 @@ acf_attribute_list
acf_attribute : tALLOCATE '(' allocate_option_list ')' - { $$ = attr_int( ATTR_ALLOCATE, $3 ); } - | tENCODE { $$ = attr_int( ATTR_ENCODE, 0 ); } - | tDECODE { $$ = attr_int( ATTR_DECODE, 0 ); } - | tEXPLICITHANDLE { $$ = attr_int( ATTR_EXPLICIT_HANDLE, 0 ); } + { $$ = attr_int( @$, ATTR_ALLOCATE, $3 ); } + | tENCODE { $$ = attr_int( @$, ATTR_ENCODE, 0 ); } + | tDECODE { $$ = attr_int( @$, ATTR_DECODE, 0 ); } + | tEXPLICITHANDLE { $$ = attr_int( @$, ATTR_EXPLICIT_HANDLE, 0 ); } ;
allocate_option_list @@ -1636,12 +1636,12 @@ static void append_chain_type(declarator_t *decl, type_t *type, enum type_qualif type->attrs = move_attr(type->attrs, chain_type->attrs, ATTR_CALLCONV); }
-static void append_chain_callconv(type_t *chain, char *callconv) +static void append_chain_callconv( struct location where, type_t *chain, char *callconv ) { type_t *chain_end;
if (chain && (chain_end = get_chain_end(chain))) - chain_end->attrs = append_attr( chain_end->attrs, attr_ptr( ATTR_CALLCONV, callconv ) ); + chain_end->attrs = append_attr( chain_end->attrs, attr_ptr( where, ATTR_CALLCONV, callconv ) ); else error_loc("calling convention applied to non-function type\n"); } @@ -2062,13 +2062,13 @@ type_t *reg_type(type_t *type, const char *name, struct namespace *namespace, in return type; }
-static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, attr_list_t *attrs) +static type_t *reg_typedefs( struct location where, decl_spec_t *decl_spec, declarator_list_t *decls, attr_list_t *attrs ) { declarator_t *decl; type_t *type = decl_spec->type;
if (is_attr(attrs, ATTR_UUID) && !is_attr(attrs, ATTR_PUBLIC)) - attrs = append_attr( attrs, attr_int( ATTR_PUBLIC, 0 ) ); + attrs = append_attr( attrs, attr_int( where, ATTR_PUBLIC, 0 ) );
/* We must generate names for tagless enum, struct or union. Typedef-ing a tagless enum, struct or union means we want the typedef @@ -2082,7 +2082,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at { type->name = gen_name(); if (!is_attr(attrs, ATTR_PUBLIC)) - attrs = append_attr( attrs, attr_int( ATTR_PUBLIC, 0 ) ); + attrs = append_attr( attrs, attr_int( where, ATTR_PUBLIC, 0 ) ); }
/* replace existing attributes when generating a typelib */ @@ -2583,7 +2583,7 @@ static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func) * "[in] handle_t IDL_handle" as the first parameter to the * function */ var_t *idl_handle = make_var(xstrdup("IDL_handle")); - idl_handle->attrs = append_attr( NULL, attr_int( ATTR_IN, 0 ) ); + idl_handle->attrs = append_attr( NULL, attr_int( iface->where, ATTR_IN, 0 ) ); idl_handle->declspec.type = find_type_or_error(NULL, "handle_t"); type_function_add_head_arg(func->declspec.type, idl_handle); } @@ -2639,7 +2639,7 @@ static int async_iface_attrs(attr_list_t *attrs, const attr_t *attr) case ATTR_UUID: return 0; case ATTR_ASYNCUUID: - append_attr( attrs, attr_ptr( ATTR_UUID, attr->u.pval ) ); + append_attr( attrs, attr_ptr( attr->where, ATTR_UUID, attr->u.pval ) ); return 0; default: return 1; diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index bad9ece185c..7e4c4fd3a38 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -1268,7 +1268,7 @@ static void compute_interface_signature_uuid(type_t *iface) if (!(uuid = get_attrp(iface->attrs, ATTR_UUID))) { uuid = xmalloc(sizeof(*uuid)); - iface->attrs = append_attr( iface->attrs, attr_ptr( ATTR_UUID, uuid ) ); + iface->attrs = append_attr( iface->attrs, attr_ptr( iface->where, ATTR_UUID, uuid ) ); }
sha1_init(&ctx); diff --git a/tools/widl/widl.h b/tools/widl/widl.h index b8f1eb8d4c0..518ae613f83 100644 --- a/tools/widl/widl.h +++ b/tools/widl/widl.h @@ -97,8 +97,8 @@ extern void end_cplusplus_guard(FILE *fp);
/* attribute.c */
-extern attr_t *attr_int( enum attr_type attr_type, unsigned int val ); -extern attr_t *attr_ptr( enum attr_type attr_type, void *val ); +extern attr_t *attr_int( struct location where, enum attr_type attr_type, unsigned int val ); +extern attr_t *attr_ptr( struct location where, enum attr_type attr_type, void *val );
extern int is_attr( const attr_list_t *list, enum attr_type attr_type ); extern int is_ptrchain_attr( const var_t *var, enum attr_type attr_type ); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index fd108ecc473..652c0d822ee 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -341,6 +341,7 @@ struct _attr_t { } u; /* parser-internal */ struct list entry; + struct location where; };
struct _expr_t {
From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/attribute.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/tools/widl/attribute.c b/tools/widl/attribute.c index bceca3da46a..92c6f1a44fa 100644 --- a/tools/widl/attribute.c +++ b/tools/widl/attribute.c @@ -260,16 +260,13 @@ attr_list_t *append_attr( attr_list_t *list, attr_t *attr ) if (!allowed_attr[attr->type].multiple) { LIST_FOR_EACH_ENTRY( attr_existing, list, attr_t, entry ) - if (attr_existing->type == attr->type) - { - char buffer[1024]; - snprintf( buffer, sizeof(buffer), "duplicate attribute %s\n", - get_attr_display_name( attr->type ) ); - parser_warning( NULL, buffer ); - /* use the last attribute, like MIDL does */ - list_remove( &attr_existing->entry ); - break; - } + { + if (attr_existing->type != attr->type) continue; + warning_at( &attr->where, "duplicate attribute %s\n", get_attr_display_name( attr->type ) ); + /* use the last attribute, like MIDL does */ + list_remove( &attr_existing->entry ); + break; + } } list_add_tail( list, &attr->entry ); return list;
This merge request was approved by Jacek Caban.