mirror of
https://github.com/reactos/reactos.git
synced 2025-04-27 17:10:22 +00:00
[TOOLS]
- sync wpp, widl and wrc with wine 1.3.26 svn path=/trunk/; revision=53158
This commit is contained in:
parent
4dc0633003
commit
f0bd303530
54 changed files with 13181 additions and 9492 deletions
|
@ -20,118 +20,393 @@ typedef DWORD LCID;
|
|||
|
||||
#define CP_UTF8 65001
|
||||
|
||||
#define LANG_AFRIKAANS 0x36
|
||||
#define LANG_ALBANIAN 0x1c
|
||||
#define LANG_ARABIC 0x01
|
||||
#define LANG_ARMENIAN 0x2b
|
||||
#define LANG_ASSAMESE 0x4d
|
||||
#define LANG_AZERI 0x2c
|
||||
#define LANG_BASQUE 0x2d
|
||||
#define LANG_BELARUSIAN 0x23
|
||||
#define LANG_BENGALI 0x45
|
||||
#define LANG_BULGARIAN 0x02
|
||||
#define LANG_CATALAN 0x03
|
||||
#define LANG_CHINESE 0x04
|
||||
#define LANG_CROATIAN 0x1a
|
||||
#define LANG_CZECH 0x05
|
||||
#define LANG_DANISH 0x06
|
||||
#define LANG_DIVEHI 0x65
|
||||
#define LANG_DUTCH 0x13
|
||||
#define LANG_ENGLISH 0x09
|
||||
#define LANG_ESTONIAN 0x25
|
||||
#define LANG_FAEROESE 0x38
|
||||
#define LANG_FARSI 0x29
|
||||
#define LANG_FINNISH 0x0b
|
||||
#define LANG_FRENCH 0x0c
|
||||
#define LANG_GALICIAN 0x56
|
||||
#define LANG_GEORGIAN 0x37
|
||||
#define LANG_GERMAN 0x07
|
||||
#define LANG_GREEK 0x08
|
||||
#define LANG_GUJARATI 0x47
|
||||
#define LANG_HEBREW 0x0d
|
||||
#define LANG_HINDI 0x39
|
||||
#define LANG_HUNGARIAN 0x0e
|
||||
#define LANG_ICELANDIC 0x0f
|
||||
#define LANG_INDONESIAN 0x21
|
||||
#define LANG_IRISH 0x3c
|
||||
#define LANG_ITALIAN 0x10
|
||||
#define LANG_JAPANESE 0x11
|
||||
#define LANG_KANNADA 0x4b
|
||||
#define LANG_KASHMIRI 0x60
|
||||
#define LANG_KAZAK 0x3f
|
||||
#define LANG_KONKANI 0x57
|
||||
#define LANG_KOREAN 0x12
|
||||
#define LANG_KYRGYZ 0x40
|
||||
#define LANG_LATVIAN 0x26
|
||||
#define LANG_LITHUANIAN 0x27
|
||||
#define LANG_MACEDONIAN 0x2f
|
||||
#define LANG_MANIPURI 0x58
|
||||
#define LANG_MALAY 0x3e
|
||||
#define LANG_MALAYALAM 0x4c
|
||||
#define LANG_MARATHI 0x4e
|
||||
#define LANG_MONGOLIAN 0x50
|
||||
#define LANG_NEPALI 0x61
|
||||
#define LANG_NEUTRAL 0x00
|
||||
#define LANG_NORWEGIAN 0x14
|
||||
#define LANG_ORIYA 0x48
|
||||
#define LANG_POLISH 0x15
|
||||
#define LANG_PORTUGUESE 0x16
|
||||
#define LANG_PUNJABI 0x46
|
||||
#define LANG_ROMANIAN 0x18
|
||||
#define LANG_ROMANSH 0x17
|
||||
#define LANG_RUSSIAN 0x19
|
||||
#define LANG_SAMI 0x3b
|
||||
#define LANG_SANSKRIT 0x4f
|
||||
#define LANG_SERBIAN 0x1a
|
||||
#define LANG_SINDHI 0x59
|
||||
#define LANG_SLOVAK 0x1b
|
||||
#define LANG_SLOVENIAN 0x24
|
||||
#define LANG_SPANISH 0x0a
|
||||
#define LANG_SWAHILI 0x41
|
||||
#define LANG_SWEDISH 0x1d
|
||||
#define LANG_SYRIAC 0x5a
|
||||
#define LANG_TAJIK 0x28
|
||||
#define LANG_TAMIL 0x49
|
||||
#define LANG_TATAR 0x44
|
||||
#define LANG_TELUGU 0x4a
|
||||
#define LANG_THAI 0x1e
|
||||
#define LANG_TURKISH 0x1f
|
||||
#define LANG_UKRAINIAN 0x22
|
||||
#define LANG_URDU 0x20
|
||||
#define LANG_UZBEK 0x43
|
||||
#define LANG_VIETNAMESE 0x2a
|
||||
#define LANG_NEUTRAL 0x00
|
||||
#define LANG_INVARIANT 0x7f
|
||||
|
||||
#define LANG_AFRIKAANS 0x36
|
||||
#define LANG_ALBANIAN 0x1c
|
||||
#define LANG_ALSATIAN 0x84
|
||||
#define LANG_AMHARIC 0x5e
|
||||
#define LANG_ARABIC 0x01
|
||||
#define LANG_ARMENIAN 0x2b
|
||||
#define LANG_ASSAMESE 0x4d
|
||||
#define LANG_AZERI 0x2c
|
||||
#define LANG_BASHKIR 0x6d
|
||||
#define LANG_BASQUE 0x2d
|
||||
#define LANG_BELARUSIAN 0x23
|
||||
#define LANG_BENGALI 0x45
|
||||
#define LANG_BOSNIAN 0x1a
|
||||
#define LANG_BOSNIAN_NEUTRAL 0x781a
|
||||
#define LANG_BRETON 0x7e
|
||||
#define LANG_BULGARIAN 0x02
|
||||
#define LANG_CATALAN 0x03
|
||||
#define LANG_CHINESE 0x04
|
||||
#define LANG_CHINESE_SIMPLIFIED 0x0004
|
||||
#define LANG_CHINESE_TRADITIONAL 0x7c04
|
||||
#define LANG_CORSICAN 0x83
|
||||
#define LANG_CROATIAN 0x1a
|
||||
#define LANG_CZECH 0x05
|
||||
#define LANG_DANISH 0x06
|
||||
#define LANG_DARI 0x8c
|
||||
#define LANG_DIVEHI 0x65
|
||||
#define LANG_DUTCH 0x13
|
||||
#define LANG_ENGLISH 0x09
|
||||
#define LANG_ESTONIAN 0x25
|
||||
#define LANG_FAEROESE 0x38
|
||||
#define LANG_FARSI LANG_PERSIAN
|
||||
#define LANG_FILIPINO 0x64
|
||||
#define LANG_FINNISH 0x0b
|
||||
#define LANG_FRENCH 0x0c
|
||||
#define LANG_FRISIAN 0x62
|
||||
#define LANG_GALICIAN 0x56
|
||||
#define LANG_GEORGIAN 0x37
|
||||
#define LANG_GERMAN 0x07
|
||||
#define LANG_GREEK 0x08
|
||||
#define LANG_GREENLANDIC 0x6f
|
||||
#define LANG_GUJARATI 0x47
|
||||
#define LANG_HAUSA 0x68
|
||||
#define LANG_HEBREW 0x0d
|
||||
#define LANG_HINDI 0x39
|
||||
#define LANG_HUNGARIAN 0x0e
|
||||
#define LANG_ICELANDIC 0x0f
|
||||
#define LANG_IGBO 0x70
|
||||
#define LANG_INDONESIAN 0x21
|
||||
#define LANG_INUKTITUT 0x5d
|
||||
#define LANG_IRISH 0x3c
|
||||
#define LANG_ITALIAN 0x10
|
||||
#define LANG_JAPANESE 0x11
|
||||
#define LANG_KANNADA 0x4b
|
||||
#define LANG_KASHMIRI 0x60
|
||||
#define LANG_KAZAK 0x3f
|
||||
#define LANG_KHMER 0x53
|
||||
#define LANG_KICHE 0x86
|
||||
#define LANG_KINYARWANDA 0x87
|
||||
#define LANG_KONKANI 0x57
|
||||
#define LANG_KOREAN 0x12
|
||||
#define LANG_KYRGYZ 0x40
|
||||
#define LANG_LAO 0x54
|
||||
#define LANG_LATVIAN 0x26
|
||||
#define LANG_LITHUANIAN 0x27
|
||||
#define LANG_LOWER_SORBIAN 0x2e
|
||||
#define LANG_LUXEMBOURGISH 0x6e
|
||||
#define LANG_MACEDONIAN 0x2f
|
||||
#define LANG_MALAY 0x3e
|
||||
#define LANG_MALAYALAM 0x4c
|
||||
#define LANG_MALTESE 0x3a
|
||||
#define LANG_MANIPURI 0x58
|
||||
#define LANG_MAORI 0x81
|
||||
#define LANG_MAPUDUNGUN 0x7a
|
||||
#define LANG_MARATHI 0x4e
|
||||
#define LANG_MOHAWK 0x7c
|
||||
#define LANG_MONGOLIAN 0x50
|
||||
#define LANG_NEPALI 0x61
|
||||
#define LANG_NORWEGIAN 0x14
|
||||
#define LANG_OCCITAN 0x82
|
||||
#define LANG_ORIYA 0x48
|
||||
#define LANG_PASHTO 0x63
|
||||
#define LANG_PERSIAN 0x29
|
||||
#define LANG_POLISH 0x15
|
||||
#define LANG_PORTUGUESE 0x16
|
||||
#define LANG_PUNJABI 0x46
|
||||
#define LANG_QUECHUA 0x6b
|
||||
#define LANG_ROMANIAN 0x18
|
||||
#define LANG_ROMANSH 0x17
|
||||
#define LANG_RUSSIAN 0x19
|
||||
#define LANG_SAMI 0x3b
|
||||
#define LANG_SANSKRIT 0x4f
|
||||
#define LANG_SERBIAN 0x1a
|
||||
#define LANG_SERBIAN_NEUTRAL 0x7c1a
|
||||
#define LANG_SINDHI 0x59
|
||||
#define LANG_SINHALESE 0x5b
|
||||
#define LANG_SLOVAK 0x1b
|
||||
#define LANG_SLOVENIAN 0x24
|
||||
#define LANG_SOTHO 0x6c
|
||||
#define LANG_SPANISH 0x0a
|
||||
#define LANG_SWAHILI 0x41
|
||||
#define LANG_SWEDISH 0x1d
|
||||
#define LANG_SYRIAC 0x5a
|
||||
#define LANG_TAJIK 0x28
|
||||
#define LANG_TAMAZIGHT 0x5f
|
||||
#define LANG_TAMIL 0x49
|
||||
#define LANG_TATAR 0x44
|
||||
#define LANG_TELUGU 0x4a
|
||||
#define LANG_THAI 0x1e
|
||||
#define LANG_TIBETAN 0x51
|
||||
#define LANG_TIGRIGNA 0x73
|
||||
#define LANG_TSWANA 0x32
|
||||
#define LANG_TURKISH 0x1f
|
||||
#define LANG_TURKMEN 0x42
|
||||
#define LANG_UIGHUR 0x80
|
||||
#define LANG_UKRAINIAN 0x22
|
||||
#define LANG_UPPER_SORBIAN 0x2e
|
||||
#define LANG_URDU 0x20
|
||||
#define LANG_UZBEK 0x43
|
||||
#define LANG_VIETNAMESE 0x2a
|
||||
#define LANG_WELSH 0x52
|
||||
#define LANG_WOLOF 0x88
|
||||
#define LANG_XHOSA 0x34
|
||||
#define LANG_YAKUT 0x85
|
||||
#define LANG_YI 0x78
|
||||
#define LANG_YORUBA 0x6a
|
||||
#define LANG_ZULU 0x35
|
||||
|
||||
/* These are documented by the MSDN but are missing from the Windows header */
|
||||
#define LANG_MALAGASY 0x8d
|
||||
|
||||
/* FIXME: these are not defined anywhere */
|
||||
#define LANG_SUTU 0x30
|
||||
#define LANG_TSONGA 0x31
|
||||
#define LANG_VENDA 0x33
|
||||
|
||||
/* non standard; keep the number high enough (but < 0xff) */
|
||||
#define LANG_ESPERANTO 0x8f
|
||||
#define LANG_WALON 0x90
|
||||
#define LANG_CORNISH 0x91
|
||||
#define LANG_WELSH 0x92
|
||||
#define LANG_BRETON 0x93
|
||||
#define LANG_ESPERANTO 0x8f
|
||||
#define LANG_WALON 0x90
|
||||
#define LANG_CORNISH 0x91
|
||||
#define LANG_GAELIC 0x94
|
||||
|
||||
/* FIXME: these are not in the Windows header */
|
||||
#define LANG_GAELIC 0x94
|
||||
#define LANG_MALTESE 0x3a
|
||||
#define LANG_RHAETO_ROMANCE 0x17
|
||||
#define LANG_SAAMI 0x3b
|
||||
#define LANG_SORBIAN 0x2e
|
||||
#define LANG_LOWER_SORBIAN 0x2e
|
||||
#define LANG_UPPER_SORBIAN 0x2e
|
||||
#define LANG_SUTU 0x30
|
||||
#define LANG_TSONGA 0x31
|
||||
#define LANG_TSWANA 0x32
|
||||
#define LANG_VENDA 0x33
|
||||
#define LANG_XHOSA 0x34
|
||||
#define LANG_ZULU 0x35
|
||||
/* Sublanguage definitions */
|
||||
#define SUBLANG_NEUTRAL 0x00 /* language neutral */
|
||||
#define SUBLANG_DEFAULT 0x01 /* user default */
|
||||
#define SUBLANG_SYS_DEFAULT 0x02 /* system default */
|
||||
#define SUBLANG_CUSTOM_DEFAULT 0x03
|
||||
#define SUBLANG_CUSTOM_UNSPECIFIED 0x04
|
||||
#define SUBLANG_UI_CUSTOM_DEFAULT 0x05
|
||||
|
||||
/* Sublanguages */
|
||||
#define SUBLANG_AZERI_CYRILLIC 0x02
|
||||
#define SUBLANG_CHINESE_SINGAPORE 0x04
|
||||
#define SUBLANG_CHINESE_SIMPLIFIED 0x02
|
||||
#define SUBLANG_DEFAULT 0x01
|
||||
#define SUBLANG_NEUTRAL 0x00
|
||||
#define SUBLANG_NORWEGIAN_NYNORSK 0x02
|
||||
#define SUBLANG_SERBIAN_CYRILLIC 0x03
|
||||
#define SUBLANG_UZBEK_CYRILLIC 0x02
|
||||
#define SUBLANG_ENGLISH_US 0x01
|
||||
#define SUBLANG_AFRIKAANS_SOUTH_AFRICA 0x01
|
||||
#define SUBLANG_ALBANIAN_ALBANIA 0x01
|
||||
#define SUBLANG_ALSATIAN_FRANCE 0x01
|
||||
#define SUBLANG_AMHARIC_ETHIOPIA 0x01
|
||||
#define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
|
||||
#define SUBLANG_ARABIC_IRAQ 0x02
|
||||
#define SUBLANG_ARABIC_EGYPT 0x03
|
||||
#define SUBLANG_ARABIC_LIBYA 0x04
|
||||
#define SUBLANG_ARABIC_ALGERIA 0x05
|
||||
#define SUBLANG_ARABIC_MOROCCO 0x06
|
||||
#define SUBLANG_ARABIC_TUNISIA 0x07
|
||||
#define SUBLANG_ARABIC_OMAN 0x08
|
||||
#define SUBLANG_ARABIC_YEMEN 0x09
|
||||
#define SUBLANG_ARABIC_SYRIA 0x0a
|
||||
#define SUBLANG_ARABIC_JORDAN 0x0b
|
||||
#define SUBLANG_ARABIC_LEBANON 0x0c
|
||||
#define SUBLANG_ARABIC_KUWAIT 0x0d
|
||||
#define SUBLANG_ARABIC_UAE 0x0e
|
||||
#define SUBLANG_ARABIC_BAHRAIN 0x0f
|
||||
#define SUBLANG_ARABIC_QATAR 0x10
|
||||
#define SUBLANG_ARMENIAN_ARMENIA 0x01
|
||||
#define SUBLANG_ASSAMESE_INDIA 0x01
|
||||
#define SUBLANG_AZERI_LATIN 0x01
|
||||
#define SUBLANG_AZERI_CYRILLIC 0x02
|
||||
#define SUBLANG_BASHKIR_RUSSIA 0x01
|
||||
#define SUBLANG_BASQUE_BASQUE 0x01
|
||||
#define SUBLANG_BELARUSIAN_BELARUS 0x01
|
||||
#define SUBLANG_BENGALI_INDIA 0x01
|
||||
#define SUBLANG_BENGALI_BANGLADESH 0x02
|
||||
#define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN 0x05
|
||||
#define SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x08
|
||||
#define SUBLANG_BRETON_FRANCE 0x01
|
||||
#define SUBLANG_BULGARIAN_BULGARIA 0x01
|
||||
#define SUBLANG_CATALAN_CATALAN 0x01
|
||||
#define SUBLANG_CHINESE_TRADITIONAL 0x01
|
||||
#define SUBLANG_CHINESE_SIMPLIFIED 0x02
|
||||
#define SUBLANG_CHINESE_HONGKONG 0x03
|
||||
#define SUBLANG_CHINESE_SINGAPORE 0x04
|
||||
#define SUBLANG_CHINESE_MACAU 0x05
|
||||
#define SUBLANG_CORSICAN_FRANCE 0x01
|
||||
#define SUBLANG_CROATIAN_CROATIA 0x01
|
||||
#define SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN 0x04
|
||||
#define SUBLANG_CZECH_CZECH_REPUBLIC 0x01
|
||||
#define SUBLANG_DANISH_DENMARK 0x01
|
||||
#define SUBLANG_DARI_AFGHANISTAN 0x01
|
||||
#define SUBLANG_DIVEHI_MALDIVES 0x01
|
||||
#define SUBLANG_DUTCH 0x01
|
||||
#define SUBLANG_DUTCH_BELGIAN 0x02
|
||||
#define SUBLANG_ENGLISH_US 0x01
|
||||
#define SUBLANG_ENGLISH_UK 0x02
|
||||
#define SUBLANG_ENGLISH_AUS 0x03
|
||||
#define SUBLANG_ENGLISH_CAN 0x04
|
||||
#define SUBLANG_ENGLISH_NZ 0x05
|
||||
#define SUBLANG_ENGLISH_EIRE 0x06
|
||||
#define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
|
||||
#define SUBLANG_ENGLISH_JAMAICA 0x08
|
||||
#define SUBLANG_ENGLISH_CARIBBEAN 0x09
|
||||
#define SUBLANG_ENGLISH_BELIZE 0x0a
|
||||
#define SUBLANG_ENGLISH_TRINIDAD 0x0b
|
||||
#define SUBLANG_ENGLISH_ZIMBABWE 0x0c
|
||||
#define SUBLANG_ENGLISH_PHILIPPINES 0x0d
|
||||
#define SUBLANG_ENGLISH_INDIA 0x10
|
||||
#define SUBLANG_ENGLISH_MALAYSIA 0x11
|
||||
#define SUBLANG_ENGLISH_SINGAPORE 0x12
|
||||
#define SUBLANG_ESTONIAN_ESTONIA 0x01
|
||||
#define SUBLANG_FAEROESE_FAROE_ISLANDS 0x01
|
||||
#define SUBLANG_FILIPINO_PHILIPPINES 0x01
|
||||
#define SUBLANG_FINNISH_FINLAND 0x01
|
||||
#define SUBLANG_FRENCH 0x01
|
||||
#define SUBLANG_FRENCH_BELGIAN 0x02
|
||||
#define SUBLANG_FRENCH_CANADIAN 0x03
|
||||
#define SUBLANG_FRENCH_SWISS 0x04
|
||||
#define SUBLANG_FRENCH_LUXEMBOURG 0x05
|
||||
#define SUBLANG_FRENCH_MONACO 0x06
|
||||
#define SUBLANG_FRISIAN_NETHERLANDS 0x01
|
||||
#define SUBLANG_GALICIAN_GALICIAN 0x01
|
||||
#define SUBLANG_GEORGIAN_GEORGIA 0x01
|
||||
#define SUBLANG_GERMAN 0x01
|
||||
#define SUBLANG_GERMAN_SWISS 0x02
|
||||
#define SUBLANG_GERMAN_AUSTRIAN 0x03
|
||||
#define SUBLANG_GERMAN_LUXEMBOURG 0x04
|
||||
#define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
|
||||
#define SUBLANG_GREEK_GREECE 0x01
|
||||
#define SUBLANG_GREENLANDIC_GREENLAND 0x01
|
||||
#define SUBLANG_GUJARATI_INDIA 0x01
|
||||
#define SUBLANG_HAUSA_NIGERIA_LATIN 0x01
|
||||
#define SUBLANG_HEBREW_ISRAEL 0x01
|
||||
#define SUBLANG_HINDI_INDIA 0x01
|
||||
#define SUBLANG_HUNGARIAN_HUNGARY 0x01
|
||||
#define SUBLANG_ICELANDIC_ICELAND 0x01
|
||||
#define SUBLANG_IGBO_NIGERIA 0x01
|
||||
#define SUBLANG_INDONESIAN_INDONESIA 0x01
|
||||
#define SUBLANG_INUKTITUT_CANADA 0x01
|
||||
#define SUBLANG_INUKTITUT_CANADA_LATIN 0x02
|
||||
#define SUBLANG_IRISH_IRELAND 0x02
|
||||
#define SUBLANG_ITALIAN 0x01
|
||||
#define SUBLANG_ITALIAN_SWISS 0x02
|
||||
#define SUBLANG_JAPANESE_JAPAN 0x01
|
||||
#define SUBLANG_KANNADA_INDIA 0x01
|
||||
#define SUBLANG_KASHMIRI_SASIA 0x02
|
||||
#define SUBLANG_KASHMIRI_INDIA 0x02
|
||||
#define SUBLANG_KAZAK_KAZAKHSTAN 0x01
|
||||
#define SUBLANG_KHMER_CAMBODIA 0x01
|
||||
#define SUBLANG_KICHE_GUATEMALA 0x01
|
||||
#define SUBLANG_KINYARWANDA_RWANDA 0X01
|
||||
#define SUBLANG_KONKANI_INDIA 0x01
|
||||
#define SUBLANG_KOREAN 0x01
|
||||
#define SUBLANG_KYRGYZ_KYRGYZSTAN 0x01
|
||||
#define SUBLANG_LAO_LAO 0x01
|
||||
#define SUBLANG_LATVIAN_LATVIA 0x01
|
||||
#define SUBLANG_LITHUANIAN_LITHUANIA 0x01
|
||||
#define SUBLANG_LOWER_SORBIAN_GERMANY 0x02
|
||||
#define SUBLANG_LUXEMBOURGISH_LUXEMBOURG 0x01
|
||||
#define SUBLANG_MACEDONIAN_MACEDONIA 0x01
|
||||
#define SUBLANG_MALAY_MALAYSIA 0x01
|
||||
#define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
|
||||
#define SUBLANG_MALAYALAM_INDIA 0x01
|
||||
#define SUBLANG_MALTESE_MALTA 0x01
|
||||
#define SUBLANG_MAORI_NEW_ZEALAND 0x01
|
||||
#define SUBLANG_MAPUDUNGUN_CHILE 0x01
|
||||
#define SUBLANG_MARATHI_INDIA 0x01
|
||||
#define SUBLANG_MOHAWK_MOHAWK 0x01
|
||||
#define SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA 0x01
|
||||
#define SUBLANG_MONGOLIAN_PRC 0x02
|
||||
#define SUBLANG_NEPALI_INDIA 0x02
|
||||
#define SUBLANG_NEPALI_NEPAL 0x01
|
||||
#define SUBLANG_NORWEGIAN_BOKMAL 0x01
|
||||
#define SUBLANG_NORWEGIAN_NYNORSK 0x02
|
||||
#define SUBLANG_OCCITAN_FRANCE 0x01
|
||||
#define SUBLANG_ORIYA_INDIA 0x01
|
||||
#define SUBLANG_PASHTO_AFGHANISTAN 0x01
|
||||
#define SUBLANG_PERSIAN_IRAN 0x01
|
||||
#define SUBLANG_POLISH_POLAND 0x01
|
||||
#define SUBLANG_PORTUGUESE 0x02
|
||||
#define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
|
||||
#define SUBLANG_PUNJABI_INDIA 0x01
|
||||
#define SUBLANG_QUECHUA_BOLIVIA 0x01
|
||||
#define SUBLANG_QUECHUA_ECUADOR 0x02
|
||||
#define SUBLANG_QUECHUA_PERU 0x03
|
||||
#define SUBLANG_ROMANIAN_ROMANIA 0x01
|
||||
#define SUBLANG_ROMANSH_SWITZERLAND 0x01
|
||||
#define SUBLANG_RUSSIAN_RUSSIA 0x01
|
||||
#define SUBLANG_SAMI_NORTHERN_NORWAY 0x01
|
||||
#define SUBLANG_SAMI_NORTHERN_SWEDEN 0x02
|
||||
#define SUBLANG_SAMI_NORTHERN_FINLAND 0x03
|
||||
#define SUBLANG_SAMI_LULE_NORWAY 0x04
|
||||
#define SUBLANG_SAMI_LULE_SWEDEN 0x05
|
||||
#define SUBLANG_SAMI_SOUTHERN_NORWAY 0x06
|
||||
#define SUBLANG_SAMI_SOUTHERN_SWEDEN 0x07
|
||||
#define SUBLANG_SAMI_SKOLT_FINLAND 0x08
|
||||
#define SUBLANG_SAMI_INARI_FINLAND 0x09
|
||||
#define SUBLANG_SANSKRIT_INDIA 0x01
|
||||
#define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN 0x06
|
||||
#define SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC 0x07
|
||||
#define SUBLANG_SERBIAN_CROATIA 0x01
|
||||
#define SUBLANG_SERBIAN_LATIN 0x02
|
||||
#define SUBLANG_SERBIAN_CYRILLIC 0x03
|
||||
#define SUBLANG_SINDHI_AFGHANISTAN 0x02
|
||||
#define SUBLANG_SINHALESE_SRI_LANKA 0x01
|
||||
#define SUBLANG_SLOVAK_SLOVAKIA 0x01
|
||||
#define SUBLANG_SLOVENIAN_SLOVENIA 0x01
|
||||
#define SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA 0x01
|
||||
#define SUBLANG_SPANISH 0x01
|
||||
#define SUBLANG_SPANISH_MEXICAN 0x02
|
||||
#define SUBLANG_SPANISH_MODERN 0x03
|
||||
#define SUBLANG_SPANISH_GUATEMALA 0x04
|
||||
#define SUBLANG_SPANISH_COSTA_RICA 0x05
|
||||
#define SUBLANG_SPANISH_PANAMA 0x06
|
||||
#define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
|
||||
#define SUBLANG_SPANISH_VENEZUELA 0x08
|
||||
#define SUBLANG_SPANISH_COLOMBIA 0x09
|
||||
#define SUBLANG_SPANISH_PERU 0x0a
|
||||
#define SUBLANG_SPANISH_ARGENTINA 0x0b
|
||||
#define SUBLANG_SPANISH_ECUADOR 0x0c
|
||||
#define SUBLANG_SPANISH_CHILE 0x0d
|
||||
#define SUBLANG_SPANISH_URUGUAY 0x0e
|
||||
#define SUBLANG_SPANISH_PARAGUAY 0x0f
|
||||
#define SUBLANG_SPANISH_BOLIVIA 0x10
|
||||
#define SUBLANG_SPANISH_EL_SALVADOR 0x11
|
||||
#define SUBLANG_SPANISH_HONDURAS 0x12
|
||||
#define SUBLANG_SPANISH_NICARAGUA 0x13
|
||||
#define SUBLANG_SPANISH_PUERTO_RICO 0x14
|
||||
#define SUBLANG_SPANISH_US 0x15
|
||||
#define SUBLANG_SWAHILI_KENYA 0x01
|
||||
#define SUBLANG_SWEDISH 0x01
|
||||
#define SUBLANG_SWEDISH_FINLAND 0x02
|
||||
#define SUBLANG_SYRIAC_SYRIA 0x01
|
||||
#define SUBLANG_TAJIK_TAJIKISTAN 0x01
|
||||
#define SUBLANG_TAMAZIGHT_ALGERIA_LATIN 0x02
|
||||
#define SUBLANG_TAMIL_INDIA 0x01
|
||||
#define SUBLANG_TATAR_RUSSIA 0x01
|
||||
#define SUBLANG_TELUGU_INDIA 0x01
|
||||
#define SUBLANG_THAI_THAILAND 0x01
|
||||
#define SUBLANG_TIBETAN_PRC 0x01
|
||||
#define SUBLANG_TIBETAN_BHUTAN 0x02
|
||||
#define SUBLANG_TIGRIGNA_ERITREA 0x02
|
||||
#define SUBLANG_TSWANA_SOUTH_AFRICA 0x01
|
||||
#define SUBLANG_TURKISH_TURKEY 0x01
|
||||
#define SUBLANG_TURKMEN_TURKMENISTAN 0x01
|
||||
#define SUBLANG_UIGHUR_PRC 0x01
|
||||
#define SUBLANG_UKRAINIAN_UKRAINE 0x01
|
||||
#define SUBLANG_UPPER_SORBIAN_GERMANY 0x01
|
||||
#define SUBLANG_URDU_PAKISTAN 0x01
|
||||
#define SUBLANG_URDU_INDIA 0x02
|
||||
#define SUBLANG_UZBEK_LATIN 0x01
|
||||
#define SUBLANG_UZBEK_CYRILLIC 0x02
|
||||
#define SUBLANG_VIETNAMESE_VIETNAM 0x01
|
||||
#define SUBLANG_WELSH_UNITED_KINGDOM 0x01
|
||||
#define SUBLANG_WOLOF_SENEGAL 0x01
|
||||
#define SUBLANG_XHOSA_SOUTH_AFRICA 0x01
|
||||
#define SUBLANG_YAKUT_RUSSIA 0x01
|
||||
#define SUBLANG_YI_PRC 0x01
|
||||
#define SUBLANG_YORUBA_NIGERIA 0x01
|
||||
#define SUBLANG_ZULU_SOUTH_AFRICA 0x01
|
||||
|
||||
/* These are documented by the MSDN but are missing from the Windows header */
|
||||
#define SUBLANG_ENGLISH_IRELAND SUBLANG_ENGLISH_EIRE
|
||||
#define SUBLANG_HAUSA_NIGERIA SUBLANG_HAUSA_NIGERIA_LATIN
|
||||
#define SUBLANG_LAO_LAO_PDR SUBLANG_LAO_LAO
|
||||
#define SUBLANG_LITHUANIAN SUBLANG_LITHUANIAN_LITHUANIA
|
||||
#define SUBLANG_PORTUGUESE_PORTUGAL SUBLANG_PORTUGUESE
|
||||
#define SUBLANG_SWAHILI SUBLANG_SWAHILI_KENYA
|
||||
#define SUBLANG_SWEDISH_SWEDEN SUBLANG_SWEDISH
|
||||
#define SUBLANG_SYRIAC SUBLANG_SYRIAC_SYRIA
|
||||
|
||||
/* FIXME: these are not defined anywhere */
|
||||
#define SUBLANG_DUTCH_SURINAM 0x03
|
||||
#define SUBLANG_ROMANIAN SUBLANG_ROMANIAN_ROMANIA
|
||||
#define SUBLANG_ROMANIAN_MOLDAVIA 0x02
|
||||
#define SUBLANG_RUSSIAN SUBLANG_RUSSIAN_RUSSIA
|
||||
#define SUBLANG_RUSSIAN_MOLDAVIA 0x02
|
||||
#define SUBLANG_CROATIAN SUBLANG_CROATIAN_CROATIA
|
||||
#define SUBLANG_LITHUANIAN_CLASSIC 0x02
|
||||
#define SUBLANG_GAELIC 0x01
|
||||
#define SUBLANG_GAELIC_SCOTTISH 0x02
|
||||
#define SUBLANG_GAELIC_MANX 0x03
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,15 +22,41 @@
|
|||
#define __WINE_WPP_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern void wpp_add_define( const char *name, const char *value );
|
||||
struct wpp_callbacks
|
||||
{
|
||||
/* I/O callbacks */
|
||||
|
||||
/* Looks for a file to include, returning the path where it is found */
|
||||
/* parent_name is the directory of the parent source file (for local
|
||||
* includes), includepath is an array of additional include paths */
|
||||
char *(*lookup)( const char *filename, const char *parent_name,
|
||||
char **include_path, int include_path_count );
|
||||
/* Opens an include file */
|
||||
/* The type param is true if it is a local ("...") include */
|
||||
void *(*open)( const char *filename, int type );
|
||||
/* Closes a previously opened file */
|
||||
void (*close)( void *file );
|
||||
/* Reads buffer from the input */
|
||||
int (*read)( void *file, char *buffer, unsigned int len );
|
||||
/* Writes buffer to the output */
|
||||
void (*write)( const char *buffer, unsigned int len );
|
||||
|
||||
/* Error callbacks */
|
||||
void (*error)( const char *file, int line, int col, const char *near, const char *msg, va_list ap );
|
||||
void (*warning)( const char *file, int line, int col, const char *near, const char *msg, va_list ap );
|
||||
};
|
||||
|
||||
/* Return value == 0 means successful execution */
|
||||
extern int wpp_add_define( const char *name, const char *value );
|
||||
extern void wpp_del_define( const char *name );
|
||||
extern void wpp_add_cmdline_define( const char *value );
|
||||
extern int wpp_add_cmdline_define( const char *value );
|
||||
extern void wpp_set_debug( int lex_debug, int parser_debug, int msg_debug );
|
||||
extern void wpp_set_pedantic( int on );
|
||||
extern void wpp_add_include_path( const char *path );
|
||||
extern int wpp_add_include_path( const char *path );
|
||||
extern char *wpp_find_include( const char *name, const char *parent_name );
|
||||
extern int wpp_parse( const char *input, FILE *output );
|
||||
extern int wpp_parse_temp( const char *input, const char *output_base, char **output_name );
|
||||
extern void wpp_set_callbacks( const struct wpp_callbacks *callbacks );
|
||||
|
||||
#endif /* __WINE_WPP_H */
|
||||
|
|
|
@ -50,32 +50,248 @@ static void print_client( const char *format, ... )
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
|
||||
static void check_pointers(const var_t *func)
|
||||
static void write_client_func_decl( const type_t *iface, const var_t *func )
|
||||
{
|
||||
const var_t *var;
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
const var_list_t *args = type_get_function_args(func->type);
|
||||
type_t *rettype = type_function_get_rettype(func->type);
|
||||
|
||||
if (!type_get_function_args(func->type))
|
||||
return;
|
||||
if (!callconv) callconv = "__cdecl";
|
||||
write_type_decl_left(client, rettype);
|
||||
fprintf(client, " %s ", callconv);
|
||||
fprintf(client, "%s%s(\n", prefix_client, get_name(func));
|
||||
indent++;
|
||||
if (args)
|
||||
write_args(client, args, iface->name, 0, TRUE);
|
||||
else
|
||||
print_client("void");
|
||||
fprintf(client, ")\n");
|
||||
indent--;
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
static void write_function_stub( const type_t *iface, const var_t *func,
|
||||
int method_count, unsigned int proc_offset )
|
||||
{
|
||||
unsigned char explicit_fc, implicit_fc;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
type_t *rettype = type_function_get_rettype(func->type);
|
||||
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
|
||||
int has_ret = !is_void(rettype);
|
||||
|
||||
if (is_interpreted_func( iface, func ))
|
||||
{
|
||||
if (is_var_ptr(var) && cant_be_null(var))
|
||||
{
|
||||
print_client("if (!%s)\n", var->name);
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
print_client("RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
|
||||
indent--;
|
||||
print_client("}\n\n");
|
||||
}
|
||||
write_client_func_decl( iface, func );
|
||||
write_client_call_routine( client, iface, func, iface->name, proc_offset );
|
||||
return;
|
||||
}
|
||||
|
||||
print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
print_client( "__DECL_EXCEPTION_FRAME\n" );
|
||||
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
if (handle_var)
|
||||
{
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
print_client("%s %s;\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name );
|
||||
print_client("RPC_BINDING_HANDLE _Handle;\n");
|
||||
}
|
||||
|
||||
if (has_ret && decl_indirect(rettype))
|
||||
{
|
||||
print_client("void *_p_%s;\n", "_RetVal" );
|
||||
}
|
||||
indent--;
|
||||
print_client( "};\n\n" );
|
||||
|
||||
print_client( "static void __finally_%s%s(", prefix_client, get_name(func) );
|
||||
print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(client, indent, func);
|
||||
|
||||
print_client("NdrFreeBuffer(&__frame->_StubMsg);\n");
|
||||
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("if (__frame->_Handle)\n");
|
||||
indent++;
|
||||
print_client("%s_unbind(__frame->%s, __frame->_Handle);\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
|
||||
indent--;
|
||||
}
|
||||
indent--;
|
||||
print_client( "}\n\n" );
|
||||
|
||||
write_client_func_decl( iface, func );
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(client, "{\n");
|
||||
indent++;
|
||||
print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) );
|
||||
|
||||
/* declare return value '_RetVal' */
|
||||
if (has_ret)
|
||||
{
|
||||
print_client("%s", "");
|
||||
write_type_decl_left(client, rettype);
|
||||
fprintf(client, " _RetVal;\n");
|
||||
}
|
||||
print_client("RPC_MESSAGE _RpcMessage;\n");
|
||||
|
||||
if (handle_var)
|
||||
{
|
||||
print_client( "__frame->_Handle = 0;\n" );
|
||||
if (explicit_fc == RPC_FC_BIND_GENERIC)
|
||||
print_client("__frame->%s = %s;\n", handle_var->name, handle_var->name );
|
||||
}
|
||||
if (has_ret && decl_indirect(rettype))
|
||||
{
|
||||
print_client("__frame->_p_%s = &%s;\n",
|
||||
"_RetVal", "_RetVal");
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
|
||||
print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(func) );
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(client, indent, func, FALSE);
|
||||
|
||||
/* check pointers */
|
||||
write_pointer_checks( client, indent, func );
|
||||
|
||||
print_client("RpcTryFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
|
||||
print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n",
|
||||
iface->name, method_count);
|
||||
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT) || is_attr(func->attrs, ATTR_BROADCAST))
|
||||
{
|
||||
print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT ");
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT ");
|
||||
if (is_attr(func->attrs, ATTR_BROADCAST))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_BROADCAST ");
|
||||
fprintf(client, ");\n\n");
|
||||
}
|
||||
|
||||
switch (explicit_fc)
|
||||
{
|
||||
case RPC_FC_BIND_PRIMITIVE:
|
||||
print_client("__frame->_Handle = %s;\n", handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
case RPC_FC_BIND_GENERIC:
|
||||
print_client("__frame->_Handle = %s_bind(%s);\n",
|
||||
get_explicit_generic_handle_type(handle_var)->name, handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
case RPC_FC_BIND_CONTEXT:
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
int is_ch_ptr = !is_aliaschain_attr(handle_var->type, ATTR_CONTEXTHANDLE);
|
||||
print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", handle_var->name);
|
||||
indent++;
|
||||
print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n",
|
||||
is_ch_ptr ? "*" : "", handle_var->name);
|
||||
indent--;
|
||||
if (is_attr(handle_var->attrs, ATTR_IN) && !is_attr(handle_var->attrs, ATTR_OUT))
|
||||
{
|
||||
print_client("else\n");
|
||||
indent++;
|
||||
print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
|
||||
indent--;
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
break;
|
||||
}
|
||||
case 0: /* implicit handle */
|
||||
if (handle_var)
|
||||
{
|
||||
print_client("__frame->_Handle = %s;\n", handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_client("NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, ");
|
||||
if (handle_var)
|
||||
fprintf(client, "__frame->_Handle);\n\n");
|
||||
else
|
||||
fprintf(client,"%s__MIDL_AutoBindHandle);\n\n", iface->name);
|
||||
|
||||
/* marshal arguments */
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_MARSHAL);
|
||||
|
||||
/* send/receive message */
|
||||
/* print_client("NdrNsSendReceive(\n"); */
|
||||
/* print_client("(unsigned char *)__frame->_StubMsg.Buffer,\n"); */
|
||||
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
|
||||
print_client("NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);\n\n");
|
||||
|
||||
print_client("__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n");
|
||||
print_client("__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
|
||||
|
||||
if (has_out_arg_or_return(func))
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
|
||||
print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||
indent++;
|
||||
print_client("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
proc_offset);
|
||||
indent--;
|
||||
}
|
||||
|
||||
/* unmarshall arguments */
|
||||
fprintf(client, "\n");
|
||||
write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL);
|
||||
|
||||
/* unmarshal return value */
|
||||
if (has_ret)
|
||||
{
|
||||
if (decl_indirect(rettype))
|
||||
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
||||
else if (is_ptr(rettype) || is_array(rettype))
|
||||
print_client("%s = 0;\n", "_RetVal");
|
||||
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(func) );
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcEndFinally\n");
|
||||
|
||||
|
||||
/* emit return code */
|
||||
if (has_ret)
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("return _RetVal;\n");
|
||||
}
|
||||
|
||||
indent--;
|
||||
fprintf(client, "}\n");
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
|
||||
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
int method_count = 0;
|
||||
|
||||
if (!implicit_handle)
|
||||
|
@ -84,243 +300,8 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
|||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
const var_t* explicit_handle_var;
|
||||
const var_t* explicit_generic_handle_var = NULL;
|
||||
const var_t* context_handle_var = NULL;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
const var_list_t *args = type_get_function_args(func->type);
|
||||
|
||||
/* check for a defined binding handle */
|
||||
explicit_handle_var = get_explicit_handle_var(func);
|
||||
if (!explicit_handle_var)
|
||||
{
|
||||
explicit_generic_handle_var = get_explicit_generic_handle_var(func);
|
||||
if (!explicit_generic_handle_var)
|
||||
context_handle_var = get_context_handle_var(func);
|
||||
}
|
||||
|
||||
print_client( "struct __frame_%s%s\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
print_client( "__DECL_EXCEPTION_FRAME\n" );
|
||||
print_client("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var)
|
||||
{
|
||||
if (!implicit_handle && explicit_generic_handle_var)
|
||||
print_client("%s %s;\n",
|
||||
get_explicit_generic_handle_type(explicit_generic_handle_var)->name,
|
||||
explicit_generic_handle_var->name );
|
||||
print_client("RPC_BINDING_HANDLE _Handle;\n");
|
||||
}
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)) &&
|
||||
decl_indirect(type_function_get_rettype(func->type)))
|
||||
{
|
||||
print_client("void *_p_%s;\n", "_RetVal" );
|
||||
}
|
||||
indent--;
|
||||
print_client( "};\n\n" );
|
||||
|
||||
print_client( "static void __finally_%s%s(", prefix_client, get_name(func) );
|
||||
print_client( " struct __frame_%s%s *__frame )\n{\n", prefix_client, get_name(func) );
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(client, indent, func);
|
||||
|
||||
print_client("NdrFreeBuffer(&__frame->_StubMsg);\n");
|
||||
|
||||
if (!implicit_handle && explicit_generic_handle_var)
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("if (__frame->_Handle)\n");
|
||||
indent++;
|
||||
print_client("%s_unbind(__frame->%s, __frame->_Handle);\n",
|
||||
get_explicit_generic_handle_type(explicit_generic_handle_var)->name,
|
||||
explicit_generic_handle_var->name);
|
||||
indent--;
|
||||
}
|
||||
indent--;
|
||||
print_client( "}\n\n" );
|
||||
|
||||
write_type_decl_left(client, type_function_get_rettype(func->type));
|
||||
if (needs_space_after(type_function_get_rettype(func->type)))
|
||||
fprintf(client, " ");
|
||||
if (callconv) fprintf(client, "%s ", callconv);
|
||||
fprintf(client, "%s%s(\n", prefix_client, get_name(func));
|
||||
indent++;
|
||||
if (args)
|
||||
write_args(client, args, iface->name, 0, TRUE);
|
||||
else
|
||||
print_client("void");
|
||||
fprintf(client, ")\n");
|
||||
indent--;
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(client, "{\n");
|
||||
indent++;
|
||||
print_client( "struct __frame_%s%s __f, * const __frame = &__f;\n", prefix_client, get_name(func) );
|
||||
|
||||
/* declare return value '_RetVal' */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
{
|
||||
print_client("%s", "");
|
||||
write_type_decl_left(client, type_function_get_rettype(func->type));
|
||||
fprintf(client, " _RetVal;\n");
|
||||
}
|
||||
print_client("RPC_MESSAGE _RpcMessage;\n");
|
||||
|
||||
if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var)
|
||||
{
|
||||
print_client( "__frame->_Handle = 0;\n" );
|
||||
if (!implicit_handle && explicit_generic_handle_var)
|
||||
print_client("__frame->%s = %s;\n",
|
||||
explicit_generic_handle_var->name, explicit_generic_handle_var->name );
|
||||
}
|
||||
if (!is_void(type_function_get_rettype(func->type)) &&
|
||||
decl_indirect(type_function_get_rettype(func->type)))
|
||||
{
|
||||
print_client("__frame->_p_%s = &%s;\n",
|
||||
"_RetVal", "_RetVal");
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
|
||||
print_client( "RpcExceptionInit( 0, __finally_%s%s );\n", prefix_client, get_name(func) );
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(client, indent, func, FALSE);
|
||||
|
||||
/* check pointers */
|
||||
check_pointers(func);
|
||||
|
||||
print_client("RpcTryFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
|
||||
print_client("NdrClientInitializeNew(&_RpcMessage, &__frame->_StubMsg, &%s_StubDesc, %d);\n",
|
||||
iface->name, method_count);
|
||||
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT) || is_attr(func->attrs, ATTR_BROADCAST))
|
||||
{
|
||||
print_client("_RpcMessage.RpcFlags = ( RPC_NCA_FLAGS_DEFAULT ");
|
||||
if (is_attr(func->attrs, ATTR_IDEMPOTENT))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_IDEMPOTENT ");
|
||||
if (is_attr(func->attrs, ATTR_BROADCAST))
|
||||
fprintf(client, "| RPC_NCA_FLAGS_BROADCAST ");
|
||||
fprintf(client, ");\n\n");
|
||||
}
|
||||
|
||||
if (explicit_handle_var)
|
||||
{
|
||||
print_client("__frame->_Handle = %s;\n", explicit_handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
else if (explicit_generic_handle_var)
|
||||
{
|
||||
print_client("__frame->_Handle = %s_bind(%s);\n",
|
||||
get_explicit_generic_handle_type(explicit_generic_handle_var)->name,
|
||||
explicit_generic_handle_var->name);
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
else if (context_handle_var)
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
int is_ch_ptr = is_aliaschain_attr(context_handle_var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE;
|
||||
print_client("if (%s%s != 0)\n", is_ch_ptr ? "*" : "", context_handle_var->name);
|
||||
indent++;
|
||||
print_client("__frame->_Handle = NDRCContextBinding(%s%s);\n",
|
||||
is_ch_ptr ? "*" : "", context_handle_var->name);
|
||||
indent--;
|
||||
if (is_attr(context_handle_var->attrs, ATTR_IN) &&
|
||||
!is_attr(context_handle_var->attrs, ATTR_OUT))
|
||||
{
|
||||
print_client("else\n");
|
||||
indent++;
|
||||
print_client("RpcRaiseException(RPC_X_SS_IN_NULL_CONTEXT);\n");
|
||||
indent--;
|
||||
}
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
else if (implicit_handle)
|
||||
{
|
||||
print_client("__frame->_Handle = %s;\n", implicit_handle);
|
||||
fprintf(client, "\n");
|
||||
}
|
||||
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_client("NdrGetBuffer(&__frame->_StubMsg, __frame->_StubMsg.BufferLength, ");
|
||||
if (implicit_handle || explicit_handle_var || explicit_generic_handle_var || context_handle_var)
|
||||
fprintf(client, "__frame->_Handle);\n\n");
|
||||
else
|
||||
fprintf(client,"%s__MIDL_AutoBindHandle);\n\n", iface->name);
|
||||
|
||||
/* marshal arguments */
|
||||
write_remoting_arguments(client, indent, func, "", PASS_IN, PHASE_MARSHAL);
|
||||
|
||||
/* send/receive message */
|
||||
/* print_client("NdrNsSendReceive(\n"); */
|
||||
/* print_client("(unsigned char *)__frame->_StubMsg.Buffer,\n"); */
|
||||
/* print_client("(RPC_BINDING_HANDLE *) &%s__MIDL_AutoBindHandle);\n", iface->name); */
|
||||
print_client("NdrSendReceive(&__frame->_StubMsg, __frame->_StubMsg.Buffer);\n\n");
|
||||
|
||||
print_client("__frame->_StubMsg.BufferStart = _RpcMessage.Buffer;\n");
|
||||
print_client("__frame->_StubMsg.BufferEnd = __frame->_StubMsg.BufferStart + _RpcMessage.BufferLength;\n");
|
||||
|
||||
if (has_out_arg_or_return(func))
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
|
||||
print_client("if ((_RpcMessage.DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||
indent++;
|
||||
print_client("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
*proc_offset);
|
||||
indent--;
|
||||
}
|
||||
|
||||
/* unmarshall arguments */
|
||||
fprintf(client, "\n");
|
||||
write_remoting_arguments(client, indent, func, "", PASS_OUT, PHASE_UNMARSHAL);
|
||||
|
||||
/* unmarshal return value */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
{
|
||||
if (decl_indirect(type_function_get_rettype(func->type)))
|
||||
print_client("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
||||
else if (is_ptr(type_function_get_rettype(func->type)) ||
|
||||
is_array(type_function_get_rettype(func->type)))
|
||||
print_client("%s = 0;\n", "_RetVal");
|
||||
write_remoting_arguments(client, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
/* update proc_offset */
|
||||
*proc_offset += get_size_procformatstring_func( func );
|
||||
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcFinally\n");
|
||||
print_client("{\n");
|
||||
indent++;
|
||||
print_client( "__finally_%s%s( __frame );\n", prefix_client, get_name(func) );
|
||||
indent--;
|
||||
print_client("}\n");
|
||||
print_client("RpcEndFinally\n");
|
||||
|
||||
|
||||
/* emit return code */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
{
|
||||
fprintf(client, "\n");
|
||||
print_client("return _RetVal;\n");
|
||||
}
|
||||
|
||||
indent--;
|
||||
fprintf(client, "}\n");
|
||||
fprintf(client, "\n");
|
||||
|
||||
method_count++;
|
||||
write_function_stub( iface, func, method_count++, *proc_offset );
|
||||
*proc_offset += get_size_procformatstring_func( iface, func );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -334,7 +315,7 @@ static void write_stubdescdecl(type_t *iface)
|
|||
|
||||
static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
||||
{
|
||||
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
|
||||
print_client("static const MIDL_STUB_DESC %s_StubDesc =\n", iface->name);
|
||||
print_client("{\n");
|
||||
|
@ -345,13 +326,16 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
|||
print_client("{\n");
|
||||
indent++;
|
||||
if (implicit_handle)
|
||||
print_client("&%s,\n", implicit_handle);
|
||||
print_client("&%s,\n", implicit_handle->name);
|
||||
else
|
||||
print_client("&%s__MIDL_AutoBindHandle,\n", iface->name);
|
||||
indent--;
|
||||
print_client("},\n");
|
||||
print_client("0,\n");
|
||||
print_client("0,\n");
|
||||
if (!list_empty( &generic_handle_list ))
|
||||
print_client("BindingRoutines,\n");
|
||||
else
|
||||
print_client("0,\n");
|
||||
if (expr_eval_routines)
|
||||
print_client("ExprEvalRoutines,\n");
|
||||
else
|
||||
|
@ -359,7 +343,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
|||
print_client("0,\n");
|
||||
print_client("__MIDL_TypeFormatString.Format,\n");
|
||||
print_client("1, /* -error bounds_check flag */\n");
|
||||
print_client("0x10001, /* Ndr library version */\n");
|
||||
print_client("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
|
||||
print_client("0,\n");
|
||||
print_client("0x50100a4, /* MIDL Version 5.1.164 */\n");
|
||||
print_client("0,\n");
|
||||
|
@ -420,12 +404,12 @@ static void write_clientinterfacedecl(type_t *iface)
|
|||
|
||||
static void write_implicithandledecl(type_t *iface)
|
||||
{
|
||||
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
const var_t *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
|
||||
if (implicit_handle)
|
||||
{
|
||||
fprintf(client, "handle_t %s;\n", implicit_handle);
|
||||
fprintf(client, "\n");
|
||||
write_type_decl( client, implicit_handle->type, implicit_handle->name );
|
||||
fprintf(client, ";\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,10 +422,7 @@ static void init_client(void)
|
|||
|
||||
print_client("/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||
print_client("#include <string.h>\n");
|
||||
print_client("#ifdef _ALPHA_\n");
|
||||
print_client("#include <stdarg.h>\n");
|
||||
print_client("#endif\n");
|
||||
fprintf(client, "\n");
|
||||
print_client( "\n");
|
||||
print_client("#include \"%s\"\n", header_name);
|
||||
print_client( "\n");
|
||||
print_client( "#ifndef DECLSPEC_HIDDEN\n");
|
||||
|
@ -496,18 +477,39 @@ static void write_client_ifaces(const statement_list_t *stmts, int expr_eval_rou
|
|||
}
|
||||
}
|
||||
|
||||
static void write_generic_handle_routine_list(void)
|
||||
{
|
||||
generic_handle_t *gh;
|
||||
|
||||
if (list_empty( &generic_handle_list )) return;
|
||||
print_client( "static const GENERIC_BINDING_ROUTINE_PAIR BindingRoutines[] =\n" );
|
||||
print_client( "{\n" );
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( gh, &generic_handle_list, generic_handle_t, entry )
|
||||
{
|
||||
print_client( "{ (GENERIC_BINDING_ROUTINE)%s_bind, (GENERIC_UNBIND_ROUTINE)%s_unbind },\n",
|
||||
gh->name, gh->name );
|
||||
}
|
||||
indent--;
|
||||
print_client( "};\n\n" );
|
||||
}
|
||||
|
||||
static void write_client_routines(const statement_list_t *stmts)
|
||||
{
|
||||
unsigned int proc_offset = 0;
|
||||
int expr_eval_routines;
|
||||
|
||||
write_exceptions( client );
|
||||
print_client( "\n");
|
||||
if (need_inline_stubs_file( stmts ))
|
||||
{
|
||||
write_exceptions( client );
|
||||
print_client( "\n");
|
||||
}
|
||||
|
||||
write_formatstringsdecl(client, indent, stmts, need_stub);
|
||||
expr_eval_routines = write_expr_eval_routines(client, client_token);
|
||||
if (expr_eval_routines)
|
||||
write_expr_eval_routine_list(client, client_token);
|
||||
write_generic_handle_routine_list();
|
||||
write_user_quad_list(client);
|
||||
|
||||
write_client_ifaces(stmts, expr_eval_routines, &proc_offset);
|
||||
|
|
|
@ -94,6 +94,7 @@ static int is_signed_integer_type(const type_t *type)
|
|||
case TYPE_BASIC_HANDLE:
|
||||
return FALSE;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -648,6 +649,10 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc
|
|||
check_scalar_type(expr_loc, cont_type, result_first.type);
|
||||
result_second = resolve_expression(expr_loc, cont_type, e->u.ext);
|
||||
result_third = resolve_expression(expr_loc, cont_type, e->ext2);
|
||||
check_scalar_type(expr_loc, cont_type, result_second.type);
|
||||
check_scalar_type(expr_loc, cont_type, result_third.type);
|
||||
if (!is_ptr(result_second.type) ^ !is_ptr(result_third.type))
|
||||
error_loc_info(&expr_loc->v->loc_info, "type mismatch in ?: expression\n" );
|
||||
/* FIXME: determine the correct return type */
|
||||
result = result_second;
|
||||
result.is_variable = FALSE;
|
||||
|
|
|
@ -21,7 +21,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <nls.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
|
||||
#include "widltypes.h"
|
||||
#include "hash.h"
|
||||
|
@ -537,7 +539,7 @@ unsigned int lhash_val_of_name_sys( syskind_t skind, LCID lcid, LPCSTR lpStr)
|
|||
case LANG_VIETNAMESE: case LANG_MALTESE: case LANG_IRISH:
|
||||
case LANG_SAMI: case LANG_UPPER_SORBIAN: case LANG_TSWANA:
|
||||
case LANG_XHOSA: case LANG_ZULU: case LANG_WELSH:
|
||||
case LANG_BRETON:
|
||||
case LANG_BRETON: case LANG_NEUTRAL:
|
||||
/* some languages not in all windows versions or ReactOS */
|
||||
#ifdef LANG_GAELIC
|
||||
case LANG_GAELIC:
|
||||
|
|
|
@ -36,13 +36,11 @@
|
|||
#include "expr.h"
|
||||
#include "typetree.h"
|
||||
|
||||
typedef struct _user_type_t generic_handle_t;
|
||||
|
||||
static int indentation = 0;
|
||||
static int is_object_interface = 0;
|
||||
user_type_list_t user_type_list = LIST_INIT(user_type_list);
|
||||
static context_handle_list_t context_handle_list = LIST_INIT(context_handle_list);
|
||||
static struct list generic_handle_list = LIST_INIT(generic_handle_list);
|
||||
context_handle_list_t context_handle_list = LIST_INIT(context_handle_list);
|
||||
generic_handle_list_t generic_handle_list = LIST_INIT(generic_handle_list);
|
||||
|
||||
static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name);
|
||||
|
||||
|
@ -131,6 +129,28 @@ void write_guid(FILE *f, const char *guid_prefix, const char *name, const UUID *
|
|||
uuid->Data4[6], uuid->Data4[7]);
|
||||
}
|
||||
|
||||
static void write_uuid_decl(FILE *f, const char *name, const UUID *uuid)
|
||||
{
|
||||
fprintf(f, "#ifdef __CRT_UUID_DECL\n");
|
||||
fprintf(f, "__CRT_UUID_DECL(%s, 0x%08x, 0x%04x, 0x%04x, 0x%02x,0x%02x, 0x%02x,"
|
||||
"0x%02x,0x%02x,0x%02x,0x%02x,0x%02x)\n",
|
||||
name, uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1],
|
||||
uuid->Data4[2], uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6],
|
||||
uuid->Data4[7]);
|
||||
fprintf(f, "#endif\n");
|
||||
}
|
||||
|
||||
static const char *uuid_string(const UUID *uuid)
|
||||
{
|
||||
static char buf[37];
|
||||
|
||||
sprintf(buf, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
||||
uuid->Data1, uuid->Data2, uuid->Data3, uuid->Data4[0], uuid->Data4[1], uuid->Data4[2],
|
||||
uuid->Data4[3], uuid->Data4[4], uuid->Data4[5], uuid->Data4[6], uuid->Data4[7]);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *get_name(const var_t *v)
|
||||
{
|
||||
static char buffer[256];
|
||||
|
@ -441,6 +461,46 @@ static int generic_handle_registered(const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned int get_context_handle_offset( const type_t *type )
|
||||
{
|
||||
context_handle_t *ch;
|
||||
unsigned int index = 0;
|
||||
|
||||
while (!is_attr( type->attrs, ATTR_CONTEXTHANDLE ))
|
||||
{
|
||||
if (type_is_alias( type )) type = type_alias_get_aliasee( type );
|
||||
else if (is_ptr( type )) type = type_pointer_get_ref( type );
|
||||
else error( "internal error: %s is not a context handle\n", type->name );
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY( ch, &context_handle_list, context_handle_t, entry )
|
||||
{
|
||||
if (!strcmp( type->name, ch->name )) return index;
|
||||
index++;
|
||||
}
|
||||
error( "internal error: %s is not registered as a context handle\n", type->name );
|
||||
return index;
|
||||
}
|
||||
|
||||
unsigned int get_generic_handle_offset( const type_t *type )
|
||||
{
|
||||
generic_handle_t *gh;
|
||||
unsigned int index = 0;
|
||||
|
||||
while (!is_attr( type->attrs, ATTR_HANDLE ))
|
||||
{
|
||||
if (type_is_alias( type )) type = type_alias_get_aliasee( type );
|
||||
else if (is_ptr( type )) type = type_pointer_get_ref( type );
|
||||
else error( "internal error: %s is not a generic handle\n", type->name );
|
||||
}
|
||||
LIST_FOR_EACH_ENTRY( gh, &generic_handle_list, generic_handle_t, entry )
|
||||
{
|
||||
if (!strcmp( type->name, gh->name )) return index;
|
||||
index++;
|
||||
}
|
||||
error( "internal error: %s is not registered as a generic handle\n", type->name );
|
||||
return index;
|
||||
}
|
||||
|
||||
/* check for types which require additional prototypes to be generated in the
|
||||
* header */
|
||||
void check_for_additional_prototype_types(const var_list_t *list)
|
||||
|
@ -617,23 +677,6 @@ static void write_library(FILE *header, const typelib_t *typelib)
|
|||
}
|
||||
|
||||
|
||||
const var_t* get_explicit_handle_var(const var_t *func)
|
||||
{
|
||||
const var_t* var;
|
||||
|
||||
if (!type_get_function_args(func->type))
|
||||
return NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
{
|
||||
const type_t *type = var->type;
|
||||
if (type_get_type(type) == TYPE_BASIC && type_basic_get_type(type) == TYPE_BASIC_HANDLE)
|
||||
return var;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const type_t* get_explicit_generic_handle_type(const var_t* var)
|
||||
{
|
||||
const type_t *t;
|
||||
|
@ -646,31 +689,44 @@ const type_t* get_explicit_generic_handle_type(const var_t* var)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
const var_t* get_explicit_generic_handle_var(const var_t *func)
|
||||
const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
|
||||
unsigned char *explicit_fc, unsigned char *implicit_fc )
|
||||
{
|
||||
const var_t* var;
|
||||
const var_t *var;
|
||||
const var_list_t *args = type_get_function_args( func->type );
|
||||
|
||||
if (!type_get_function_args(func->type))
|
||||
return NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
if (get_explicit_generic_handle_type(var))
|
||||
*explicit_fc = *implicit_fc = 0;
|
||||
if (args) LIST_FOR_EACH_ENTRY( var, args, const var_t, entry )
|
||||
{
|
||||
if (!is_attr( var->attrs, ATTR_IN ) && is_attr( var->attrs, ATTR_OUT )) continue;
|
||||
if (type_get_type( var->type ) == TYPE_BASIC && type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
|
||||
{
|
||||
*explicit_fc = RPC_FC_BIND_PRIMITIVE;
|
||||
return var;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const var_t* get_context_handle_var(const var_t *func)
|
||||
{
|
||||
const var_t* var;
|
||||
|
||||
if (!type_get_function_args(func->type))
|
||||
return NULL;
|
||||
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
if (is_attr(var->attrs, ATTR_IN) && is_context_handle(var->type))
|
||||
}
|
||||
if (get_explicit_generic_handle_type( var ))
|
||||
{
|
||||
*explicit_fc = RPC_FC_BIND_GENERIC;
|
||||
return var;
|
||||
}
|
||||
if (is_context_handle( var->type ))
|
||||
{
|
||||
*explicit_fc = RPC_FC_BIND_CONTEXT;
|
||||
return var;
|
||||
}
|
||||
}
|
||||
|
||||
if ((var = get_attrp( iface->attrs, ATTR_IMPLICIT_HANDLE )))
|
||||
{
|
||||
if (type_get_type( var->type ) == TYPE_BASIC &&
|
||||
type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
|
||||
*implicit_fc = RPC_FC_BIND_PRIMITIVE;
|
||||
else
|
||||
*implicit_fc = RPC_FC_BIND_GENERIC;
|
||||
return var;
|
||||
}
|
||||
|
||||
*implicit_fc = RPC_FC_AUTO_HANDLE;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -960,10 +1016,10 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
|
|||
{
|
||||
const char *callconv = get_attrp(fun->type->attrs, ATTR_CALLCONV);
|
||||
|
||||
if (!callconv) callconv = "__cdecl";
|
||||
/* FIXME: do we need to handle call_as? */
|
||||
write_type_decl_left(header, type_function_get_rettype(fun->type));
|
||||
fprintf(header, " ");
|
||||
if (callconv) fprintf(header, "%s ", callconv);
|
||||
fprintf(header, " %s ", callconv);
|
||||
fprintf(header, "%s%s(\n", prefix, get_name(fun));
|
||||
if (type_get_function_args(fun->type))
|
||||
write_args(header, type_get_function_args(fun->type), iface->name, 0, TRUE);
|
||||
|
@ -980,24 +1036,6 @@ static void write_forward(FILE *header, type_t *iface)
|
|||
fprintf(header, "#endif\n\n" );
|
||||
}
|
||||
|
||||
static void write_iface_guid(FILE *header, const type_t *iface)
|
||||
{
|
||||
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
||||
write_guid(header, "IID", iface->name, uuid);
|
||||
}
|
||||
|
||||
static void write_dispiface_guid(FILE *header, const type_t *iface)
|
||||
{
|
||||
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
||||
write_guid(header, "DIID", iface->name, uuid);
|
||||
}
|
||||
|
||||
static void write_coclass_guid(FILE *header, const type_t *cocl)
|
||||
{
|
||||
const UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
|
||||
write_guid(header, "CLSID", cocl->name, uuid);
|
||||
}
|
||||
|
||||
static void write_com_interface_start(FILE *header, const type_t *iface)
|
||||
{
|
||||
int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
|
||||
|
@ -1011,21 +1049,26 @@ static void write_com_interface_start(FILE *header, const type_t *iface)
|
|||
static void write_com_interface_end(FILE *header, type_t *iface)
|
||||
{
|
||||
int dispinterface = is_attr(iface->attrs, ATTR_DISPINTERFACE);
|
||||
if (dispinterface)
|
||||
write_dispiface_guid(header, iface);
|
||||
else
|
||||
write_iface_guid(header, iface);
|
||||
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
||||
|
||||
if (uuid)
|
||||
write_guid(header, dispinterface ? "DIID" : "IID", iface->name, uuid);
|
||||
|
||||
/* C++ interface */
|
||||
fprintf(header, "#if defined(__cplusplus) && !defined(CINTERFACE)\n");
|
||||
if (uuid)
|
||||
fprintf(header, "MIDL_INTERFACE(\"%s\")\n", uuid_string(uuid));
|
||||
else
|
||||
fprintf(header, "interface ");
|
||||
if (type_iface_get_inherit(iface))
|
||||
{
|
||||
fprintf(header, "interface %s : public %s\n", iface->name,
|
||||
fprintf(header, "%s : public %s\n", iface->name,
|
||||
type_iface_get_inherit(iface)->name);
|
||||
fprintf(header, "{\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(header, "interface %s\n", iface->name);
|
||||
fprintf(header, "%s\n", iface->name);
|
||||
fprintf(header, "{\n");
|
||||
fprintf(header, " BEGIN_INTERFACE\n");
|
||||
fprintf(header, "\n");
|
||||
|
@ -1041,6 +1084,8 @@ static void write_com_interface_end(FILE *header, type_t *iface)
|
|||
if (!type_iface_get_inherit(iface))
|
||||
fprintf(header, " END_INTERFACE\n");
|
||||
fprintf(header, "};\n");
|
||||
if (uuid)
|
||||
write_uuid_decl(header, iface->name, uuid);
|
||||
fprintf(header, "#else\n");
|
||||
/* C interface */
|
||||
fprintf(header, "typedef struct %sVtbl {\n", iface->name);
|
||||
|
@ -1080,14 +1125,19 @@ static void write_com_interface_end(FILE *header, type_t *iface)
|
|||
static void write_rpc_interface_start(FILE *header, const type_t *iface)
|
||||
{
|
||||
unsigned int ver = get_attrv(iface->attrs, ATTR_VERSION);
|
||||
const char *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
const var_t *var = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
|
||||
|
||||
fprintf(header, "/*****************************************************************************\n");
|
||||
fprintf(header, " * %s interface (v%d.%d)\n", iface->name, MAJORVERSION(ver), MINORVERSION(ver));
|
||||
fprintf(header, " */\n");
|
||||
fprintf(header,"#ifndef __%s_INTERFACE_DEFINED__\n", iface->name);
|
||||
fprintf(header,"#define __%s_INTERFACE_DEFINED__\n\n", iface->name);
|
||||
if (var) fprintf(header, "extern handle_t %s;\n", var);
|
||||
if (var)
|
||||
{
|
||||
fprintf(header, "extern ");
|
||||
write_type_decl( header, var->type, var->name );
|
||||
fprintf(header, ";\n");
|
||||
}
|
||||
if (old_names)
|
||||
{
|
||||
fprintf(header, "extern RPC_IF_HANDLE %s%s_ClientIfHandle;\n", prefix_client, iface->name);
|
||||
|
@ -1109,10 +1159,24 @@ static void write_rpc_interface_end(FILE *header, const type_t *iface)
|
|||
|
||||
static void write_coclass(FILE *header, type_t *cocl)
|
||||
{
|
||||
const UUID *uuid = get_attrp(cocl->attrs, ATTR_UUID);
|
||||
|
||||
fprintf(header, "/*****************************************************************************\n");
|
||||
fprintf(header, " * %s coclass\n", cocl->name);
|
||||
fprintf(header, " */\n\n");
|
||||
write_coclass_guid(header, cocl);
|
||||
if (uuid)
|
||||
write_guid(header, "CLSID", cocl->name, uuid);
|
||||
fprintf(header, "\n#ifdef __cplusplus\n");
|
||||
if (uuid)
|
||||
{
|
||||
fprintf(header, "class DECLSPEC_UUID(\"%s\") %s;\n", uuid_string(uuid), cocl->name);
|
||||
write_uuid_decl(header, cocl->name, uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(header, "class %s;\n", cocl->name);
|
||||
}
|
||||
fprintf(header, "#endif\n");
|
||||
fprintf(header, "\n");
|
||||
}
|
||||
|
||||
|
@ -1225,7 +1289,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons
|
|||
write_header_stmts(header, type_iface_get_stmts(iface), iface, FALSE);
|
||||
write_rpc_interface_end(header, iface);
|
||||
}
|
||||
if (is_object(iface)) is_object_interface++;
|
||||
if (is_object(iface)) is_object_interface--;
|
||||
}
|
||||
else if (type_get_type(stmt->u.type) == TYPE_COCLASS)
|
||||
write_coclass(header, stmt->u.type);
|
||||
|
@ -1299,6 +1363,11 @@ void write_header(const statement_list_t *stmts)
|
|||
fprintf(header, "#include <rpc.h>\n" );
|
||||
fprintf(header, "#include <rpcndr.h>\n\n" );
|
||||
|
||||
fprintf(header, "#if !defined(COM_NO_WINDOWS_H) && !defined(__WINESRC__)\n");
|
||||
fprintf(header, "#include <windows.h>\n");
|
||||
fprintf(header, "#include <ole2.h>\n");
|
||||
fprintf(header, "#endif\n\n");
|
||||
|
||||
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
|
||||
fprintf(header, "#define __WIDL_%s\n\n", header_token);
|
||||
|
||||
|
|
|
@ -36,21 +36,24 @@ extern void write_type_left(FILE *h, type_t *t, int declonly);
|
|||
extern void write_type_right(FILE *h, type_t *t, int is_field);
|
||||
extern void write_type_decl(FILE *f, type_t *t, const char *name);
|
||||
extern void write_type_decl_left(FILE *f, type_t *t);
|
||||
extern unsigned int get_context_handle_offset( const type_t *type );
|
||||
extern unsigned int get_generic_handle_offset( const type_t *type );
|
||||
extern int needs_space_after(type_t *t);
|
||||
extern int is_object(const type_t *iface);
|
||||
extern int is_local(const attr_list_t *list);
|
||||
extern int count_methods(const type_t *iface);
|
||||
extern int need_stub(const type_t *iface);
|
||||
extern int need_proxy(const type_t *iface);
|
||||
extern int need_inline_stubs(const type_t *iface);
|
||||
extern int need_stub_files(const statement_list_t *stmts);
|
||||
extern int need_proxy_file(const statement_list_t *stmts);
|
||||
extern int need_inline_stubs_file(const statement_list_t *stmts);
|
||||
extern const var_t *is_callas(const attr_list_t *list);
|
||||
extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent);
|
||||
extern void write_array(FILE *h, array_dims_t *v, int field);
|
||||
extern const var_t* get_explicit_handle_var(const var_t *func);
|
||||
extern const type_t* get_explicit_generic_handle_type(const var_t* var);
|
||||
extern const var_t* get_explicit_generic_handle_var(const var_t *func);
|
||||
extern const var_t* get_context_handle_var(const var_t *func);
|
||||
extern const var_t *get_func_handle_var( const type_t *iface, const var_t *func,
|
||||
unsigned char *explicit_fc, unsigned char *implicit_fc );
|
||||
extern int has_out_arg_or_return(const var_t *func);
|
||||
extern void write_guid(FILE *f, const char *guid_prefix, const char *name,
|
||||
const UUID *uuid);
|
||||
|
|
|
@ -142,7 +142,6 @@ UUID *parse_uuid(const char *u)
|
|||
error_loc("Malformed '#...' line-directive; missing terminating \"\n");
|
||||
*cptr = '\0';
|
||||
line_number = lineno - 1; /* We didn't read the newline */
|
||||
free( input_name );
|
||||
input_name = xstrdup(fname);
|
||||
}
|
||||
<INITIAL,ATTR>\" yy_push_state(QUOTE); cbufidx = 0;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,9 @@
|
|||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -229,7 +228,7 @@
|
|||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 153 "parser.y"
|
||||
|
||||
attr_t *attr;
|
||||
|
@ -259,8 +258,8 @@ typedef union YYSTYPE
|
|||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 264 "parser.tab.h"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 263 "parser.tab.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
|
|
@ -133,7 +133,7 @@ static attr_list_t *check_dispiface_attrs(const char *name, attr_list_t *attrs);
|
|||
static attr_list_t *check_module_attrs(const char *name, attr_list_t *attrs);
|
||||
static attr_list_t *check_coclass_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(var_t *func);
|
||||
static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func);
|
||||
static void check_def(const type_t *t);
|
||||
|
||||
static statement_t *make_statement(enum statement_type type);
|
||||
|
@ -384,8 +384,11 @@ statement:
|
|||
|
||||
typedecl:
|
||||
enumdef
|
||||
| tENUM aIDENTIFIER { $$ = type_new_enum($2, FALSE, NULL); }
|
||||
| structdef
|
||||
| tSTRUCT aIDENTIFIER { $$ = type_new_struct($2, FALSE, NULL); }
|
||||
| uniondef
|
||||
| tUNION aIDENTIFIER { $$ = type_new_nonencapsulated_union($2, FALSE, NULL); }
|
||||
| attributes enumdef { $$ = $2; $$->attrs = check_enum_attrs($1); }
|
||||
| attributes structdef { $$ = $2; $$->attrs = check_struct_attrs($1); }
|
||||
| attributes uniondef { $$ = $2; $$->attrs = check_union_attrs($1); }
|
||||
|
@ -449,8 +452,12 @@ arg: attributes decl_spec m_any_declarator { if ($2->stgclass != STG_NONE && $
|
|||
}
|
||||
;
|
||||
|
||||
array: '[' m_expr ']' { $$ = $2; }
|
||||
array: '[' expr ']' { $$ = $2;
|
||||
if (!$$->is_const)
|
||||
error_loc("array dimension is not an integer constant\n");
|
||||
}
|
||||
| '[' '*' ']' { $$ = make_expr(EXPR_VOID); }
|
||||
| '[' ']' { $$ = make_expr(EXPR_VOID); }
|
||||
;
|
||||
|
||||
m_attributes: { $$ = NULL; }
|
||||
|
@ -515,7 +522,7 @@ attribute: { $$ = NULL; }
|
|||
| tIGNORE { $$ = make_attr(ATTR_IGNORE); }
|
||||
| tIIDIS '(' expr ')' { $$ = make_attrp(ATTR_IIDIS, $3); }
|
||||
| tIMMEDIATEBIND { $$ = make_attr(ATTR_IMMEDIATEBIND); }
|
||||
| tIMPLICITHANDLE '(' tHANDLET aIDENTIFIER ')' { $$ = make_attrp(ATTR_IMPLICIT_HANDLE, $4); }
|
||||
| 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); }
|
||||
|
@ -581,10 +588,10 @@ uuid_string:
|
|||
$$ = parse_uuid($1); }
|
||||
;
|
||||
|
||||
callconv: tCDECL { $$ = $<str>1; }
|
||||
| tFASTCALL { $$ = $<str>1; }
|
||||
| tPASCAL { $$ = $<str>1; }
|
||||
| tSTDCALL { $$ = $<str>1; }
|
||||
callconv: tCDECL { $$ = xstrdup("__cdecl"); }
|
||||
| tFASTCALL { $$ = xstrdup("__fastcall"); }
|
||||
| tPASCAL { $$ = xstrdup("__pascal"); }
|
||||
| tSTDCALL { $$ = xstrdup("__stdcall"); }
|
||||
;
|
||||
|
||||
cases: { $$ = NULL; }
|
||||
|
@ -635,16 +642,6 @@ m_exprs: m_expr { $$ = append_expr( NULL, $1 );
|
|||
| m_exprs ',' m_expr { $$ = append_expr( $1, $3 ); }
|
||||
;
|
||||
|
||||
/*
|
||||
exprs: { $$ = make_expr(EXPR_VOID); }
|
||||
| expr_list
|
||||
;
|
||||
|
||||
expr_list: expr
|
||||
| expr_list ',' expr { LINK($3, $1); $$ = $3; }
|
||||
;
|
||||
*/
|
||||
|
||||
m_expr: { $$ = make_expr(EXPR_VOID); }
|
||||
| expr
|
||||
;
|
||||
|
@ -1728,7 +1725,6 @@ static typelib_t *make_library(const char *name, const attr_list_t *attrs)
|
|||
{
|
||||
typelib_t *typelib = xmalloc(sizeof(*typelib));
|
||||
typelib->name = xstrdup(name);
|
||||
typelib->filename = NULL;
|
||||
typelib->attrs = attrs;
|
||||
list_init( &typelib->importlibs );
|
||||
return typelib;
|
||||
|
@ -1854,12 +1850,6 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at
|
|||
else if (is_attr(attrs, ATTR_UUID) && !is_attr(attrs, ATTR_PUBLIC))
|
||||
attrs = append_attr( attrs, make_attr(ATTR_PUBLIC) );
|
||||
|
||||
/* Append the SWITCHTYPE attribute to a non-encapsulated union if it does not already have it. */
|
||||
if (type_get_type_detect_alias(type) == TYPE_UNION &&
|
||||
is_attr(attrs, ATTR_SWITCHTYPE) &&
|
||||
!is_attr(type->attrs, ATTR_SWITCHTYPE))
|
||||
type->attrs = append_attr(type->attrs, make_attrp(ATTR_SWITCHTYPE, get_attrp(attrs, ATTR_SWITCHTYPE)));
|
||||
|
||||
LIST_FOR_EACH_ENTRY( decl, decls, const declarator_t, entry )
|
||||
{
|
||||
|
||||
|
@ -2114,7 +2104,7 @@ struct allowed_attr allowed_attr[] =
|
|||
/* ATTR_UUID */ { 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, "uuid" },
|
||||
/* ATTR_V1ENUM */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, "v1_enum" },
|
||||
/* ATTR_VARARG */ { 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "vararg" },
|
||||
/* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, "version" },
|
||||
/* ATTR_VERSION */ { 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, "version" },
|
||||
/* ATTR_VIPROGID */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, "vi_progid" },
|
||||
/* ATTR_WIREMARSHAL */ { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "wire_marshal" },
|
||||
};
|
||||
|
@ -2133,6 +2123,17 @@ static attr_list_t *check_iface_attrs(const char *name, attr_list_t *attrs)
|
|||
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->type) == TYPE_BASIC &&
|
||||
type_basic_get_type( var->type ) == TYPE_BASIC_HANDLE)
|
||||
continue;
|
||||
if (is_aliaschain_attr( var->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;
|
||||
}
|
||||
|
@ -2563,11 +2564,15 @@ static void check_remoting_args(const var_t *func)
|
|||
error_loc_info(&arg->loc_info, "out interface pointer \'%s\' of function \'%s\' is not a double pointer\n", arg->name, funcname);
|
||||
break;
|
||||
case TGT_STRING:
|
||||
if (is_ptr(type) ||
|
||||
(is_array(type) &&
|
||||
(!type_array_has_conformance(type) ||
|
||||
type_array_get_conformance(type)->type == EXPR_VOID)))
|
||||
error_loc_info(&arg->loc_info, "out parameter \'%s\' of function \'%s\' cannot be an unsized string\n", arg->name, funcname);
|
||||
if (is_array(type))
|
||||
{
|
||||
/* needs conformance or fixed dimension */
|
||||
if (type_array_has_conformance(type) &&
|
||||
type_array_get_conformance(type)->type != EXPR_VOID) break;
|
||||
if (!type_array_has_conformance(type) && type_array_get_dim(type)) break;
|
||||
}
|
||||
if (is_attr( arg->attrs, ATTR_IN )) break;
|
||||
error_loc_info(&arg->loc_info, "out parameter \'%s\' of function \'%s\' cannot be an unsized string\n", arg->name, funcname);
|
||||
break;
|
||||
case TGT_INVALID:
|
||||
/* already error'd before we get here */
|
||||
|
@ -2593,31 +2598,20 @@ static void check_remoting_args(const var_t *func)
|
|||
}
|
||||
}
|
||||
|
||||
static void add_explicit_handle_if_necessary(var_t *func)
|
||||
static void add_explicit_handle_if_necessary(const type_t *iface, var_t *func)
|
||||
{
|
||||
const var_t* explicit_handle_var;
|
||||
const var_t* explicit_generic_handle_var = NULL;
|
||||
const var_t* context_handle_var = NULL;
|
||||
unsigned char explicit_fc, implicit_fc;
|
||||
|
||||
/* check for a defined binding handle */
|
||||
explicit_handle_var = get_explicit_handle_var(func);
|
||||
if (!explicit_handle_var)
|
||||
if (!get_func_handle_var( iface, func, &explicit_fc, &implicit_fc ) || !explicit_fc)
|
||||
{
|
||||
explicit_generic_handle_var = get_explicit_generic_handle_var(func);
|
||||
if (!explicit_generic_handle_var)
|
||||
{
|
||||
context_handle_var = get_context_handle_var(func);
|
||||
if (!context_handle_var)
|
||||
{
|
||||
/* no explicit handle specified so add
|
||||
* "[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->type = find_type_or_error("handle_t", 0);
|
||||
type_function_add_head_arg(func->type, idl_handle);
|
||||
}
|
||||
}
|
||||
/* no explicit handle specified so add
|
||||
* "[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->type = find_type_or_error("handle_t", 0);
|
||||
type_function_add_head_arg(func->type, idl_handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2629,7 +2623,7 @@ static void check_functions(const type_t *iface, int is_inside_library)
|
|||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
add_explicit_handle_if_necessary(func);
|
||||
add_explicit_handle_if_necessary(iface, func);
|
||||
}
|
||||
}
|
||||
if (!is_inside_library && !is_attr(iface->attrs, ATTR_LOCAL))
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -48,8 +48,6 @@
|
|||
static FILE* proxy;
|
||||
static int indent = 0;
|
||||
|
||||
/* FIXME: support generation of stubless proxies */
|
||||
|
||||
static void print_proxy( const char *format, ... ) __attribute__((format (printf, 1, 2)));
|
||||
static void print_proxy( const char *format, ... )
|
||||
{
|
||||
|
@ -75,7 +73,7 @@ static void write_stubdesc(int expr_eval_routines)
|
|||
print_proxy( "{0}, 0, 0, %s, 0,\n", expr_eval_routines ? "ExprEvalRoutines" : "0");
|
||||
print_proxy( "__MIDL_TypeFormatString.Format,\n");
|
||||
print_proxy( "1, /* -error bounds_check flag */\n");
|
||||
print_proxy( "0x10001, /* Ndr library version */\n");
|
||||
print_proxy( "0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
|
||||
print_proxy( "0,\n");
|
||||
print_proxy( "0x50100a4, /* MIDL Version 5.1.164 */\n");
|
||||
print_proxy( "0,\n");
|
||||
|
@ -97,18 +95,8 @@ static void init_proxy(const statement_list_t *stmts)
|
|||
error("Could not open %s for output\n", proxy_name);
|
||||
print_proxy( "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
|
||||
print_proxy( "\n");
|
||||
print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
|
||||
print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ 440\n");
|
||||
print_proxy( "#endif /* __REDQ_RPCPROXY_H_VERSION__ */\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy( "#define __midl_proxy\n");
|
||||
print_proxy( "#include \"objbase.h\"\n");
|
||||
print_proxy( "#include \"rpcproxy.h\"\n");
|
||||
print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
|
||||
print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
|
||||
print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy( "#include \"%s\"\n", header_name);
|
||||
print_proxy( "\n");
|
||||
print_proxy( "#ifndef DECLSPEC_HIDDEN\n");
|
||||
print_proxy( "#define DECLSPEC_HIDDEN\n");
|
||||
|
@ -123,40 +111,21 @@ static void clear_output_vars( const var_list_t *args )
|
|||
if (!args) return;
|
||||
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||
{
|
||||
if (is_attr(arg->attrs, ATTR_OUT) && !is_attr(arg->attrs, ATTR_IN)) {
|
||||
print_proxy( "if(%s)\n", arg->name );
|
||||
indent++;
|
||||
print_proxy( "MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name );
|
||||
indent--;
|
||||
}
|
||||
if (is_attr(arg->attrs, ATTR_IN)) continue;
|
||||
if (!is_attr(arg->attrs, ATTR_OUT)) continue;
|
||||
if (is_ptr(arg->type))
|
||||
{
|
||||
if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_BASIC) continue;
|
||||
if (type_get_type(type_pointer_get_ref(arg->type)) == TYPE_ENUM) continue;
|
||||
}
|
||||
print_proxy( "if (%s) MIDL_memset( %s, 0, sizeof( *%s ));\n", arg->name, arg->name, arg->name );
|
||||
}
|
||||
}
|
||||
|
||||
int is_var_ptr(const var_t *v)
|
||||
{
|
||||
return is_ptr(v->type);
|
||||
}
|
||||
|
||||
int cant_be_null(const var_t *v)
|
||||
{
|
||||
switch (typegen_detect_type(v->type, v->attrs, TDT_IGNORE_STRINGS))
|
||||
{
|
||||
case TGT_ARRAY:
|
||||
case TGT_POINTER:
|
||||
return (get_pointer_fc(v->type, v->attrs, TRUE) == RPC_FC_RP);
|
||||
case TGT_CTXT_HANDLE_POINTER:
|
||||
return TRUE;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static int need_delegation(const type_t *iface)
|
||||
{
|
||||
return type_iface_get_inherit(iface) &&
|
||||
type_iface_get_inherit(type_iface_get_inherit(iface)) &&
|
||||
type_iface_get_inherit(iface)->ignore;
|
||||
const type_t *parent = type_iface_get_inherit( iface );
|
||||
return parent && type_iface_get_inherit(parent) && (parent->ignore || is_local( parent->attrs ));
|
||||
}
|
||||
|
||||
static int get_delegation_indirect(const type_t *iface, const type_t ** delegate_to)
|
||||
|
@ -177,39 +146,12 @@ static int need_delegation_indirect(const type_t *iface)
|
|||
return get_delegation_indirect(iface, NULL);
|
||||
}
|
||||
|
||||
static void proxy_check_pointers( const var_list_t *args )
|
||||
{
|
||||
const var_t *arg;
|
||||
|
||||
if (!args) return;
|
||||
LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||
{
|
||||
if (is_var_ptr(arg) && cant_be_null(arg)) {
|
||||
print_proxy( "if(!%s)\n", arg->name );
|
||||
indent++;
|
||||
print_proxy( "RpcRaiseException(RPC_X_NULL_REF_POINTER);\n");
|
||||
indent--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void free_variable( const var_t *arg, const char *local_var_prefix )
|
||||
{
|
||||
unsigned int type_offset = arg->type->typestring_offset;
|
||||
expr_t *iid;
|
||||
type_t *type = arg->type;
|
||||
expr_t *size = get_size_is_expr(type, arg->name);
|
||||
|
||||
if (size)
|
||||
{
|
||||
print_proxy( "__frame->_StubMsg.MaxCount = " );
|
||||
write_expr(proxy, size, 0, 1, NULL, NULL, local_var_prefix);
|
||||
fprintf(proxy, ";\n\n");
|
||||
print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
|
||||
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
|
||||
fprintf(proxy, "(void*)%s );\n", arg->name );
|
||||
return;
|
||||
}
|
||||
write_parameter_conf_or_var_exprs(proxy, indent, local_var_prefix, PHASE_FREE, arg, FALSE);
|
||||
|
||||
switch (typegen_detect_type(type, arg->attrs, TDT_IGNORE_STRINGS))
|
||||
{
|
||||
|
@ -223,23 +165,11 @@ static void free_variable( const var_t *arg, const char *local_var_prefix )
|
|||
break;
|
||||
|
||||
case TGT_IFACE_POINTER:
|
||||
iid = get_attrp( arg->attrs, ATTR_IIDIS );
|
||||
if( iid )
|
||||
{
|
||||
print_proxy( "__frame->_StubMsg.MaxCount = (ULONG_PTR) " );
|
||||
write_expr(proxy, iid, 1, 1, NULL, NULL, local_var_prefix);
|
||||
print_proxy( ";\n\n" );
|
||||
}
|
||||
/* fall through */
|
||||
case TGT_POINTER:
|
||||
if (get_pointer_fc(type, arg->attrs, TRUE) == RPC_FC_FP)
|
||||
{
|
||||
print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
|
||||
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
|
||||
fprintf(proxy, "(void*)%s );\n", arg->name );
|
||||
}
|
||||
else
|
||||
print_proxy("/* FIXME: %s code for %s type %d missing */\n", __FUNCTION__, arg->name, type_get_type(type) );
|
||||
case TGT_ARRAY:
|
||||
print_proxy( "NdrClearOutParameters( &__frame->_StubMsg, ");
|
||||
fprintf(proxy, "&__MIDL_TypeFormatString.Format[%u], ", type_offset );
|
||||
fprintf(proxy, "(void *)%s );\n", arg->name );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -263,12 +193,24 @@ static void proxy_free_variables( var_list_t *args, const char *local_var_prefix
|
|||
static void gen_proxy(type_t *iface, const var_t *func, int idx,
|
||||
unsigned int proc_offset)
|
||||
{
|
||||
int has_ret = !is_void(type_function_get_rettype(func->type));
|
||||
type_t *rettype = type_function_get_rettype(func->type);
|
||||
int has_ret = !is_void(rettype);
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
const char *callconv = get_attrp(func->type->attrs, ATTR_CALLCONV);
|
||||
const var_list_t *args = type_get_function_args(func->type);
|
||||
if (!callconv) callconv = "STDMETHODCALLTYPE";
|
||||
|
||||
indent = 0;
|
||||
if (is_interpreted_func( iface, func ))
|
||||
{
|
||||
if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return;
|
||||
write_type_decl_left(proxy, type_function_get_rettype(func->type));
|
||||
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
|
||||
write_args(proxy, args, iface->name, 1, TRUE);
|
||||
print_proxy( ")\n");
|
||||
write_client_call_routine( proxy, iface, func, "Object", proc_offset );
|
||||
return;
|
||||
}
|
||||
print_proxy( "static void __finally_%s_%s_Proxy( struct __proxy_frame *__frame )\n",
|
||||
iface->name, get_name(func) );
|
||||
print_proxy( "{\n");
|
||||
|
@ -279,9 +221,9 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
|
|||
print_proxy( "}\n");
|
||||
print_proxy( "\n");
|
||||
|
||||
write_type_decl_left(proxy, type_function_get_rettype(func->type));
|
||||
write_type_decl_left(proxy, rettype);
|
||||
print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func));
|
||||
write_args(proxy, type_get_function_args(func->type), iface->name, 1, TRUE);
|
||||
write_args(proxy, args, iface->name, 1, TRUE);
|
||||
print_proxy( ")\n");
|
||||
print_proxy( "{\n");
|
||||
indent ++;
|
||||
|
@ -289,12 +231,12 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
|
|||
/* local variables */
|
||||
if (has_ret) {
|
||||
print_proxy( "%s", "" );
|
||||
write_type_decl_left(proxy, type_function_get_rettype(func->type));
|
||||
write_type_decl_left(proxy, rettype);
|
||||
print_proxy( " _RetVal;\n");
|
||||
}
|
||||
print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
|
||||
if (has_ret) {
|
||||
if (decl_indirect(type_function_get_rettype(func->type)))
|
||||
if (decl_indirect(rettype))
|
||||
print_proxy("void *_p_%s = &%s;\n",
|
||||
"_RetVal", "_RetVal");
|
||||
}
|
||||
|
@ -313,7 +255,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
|
|||
print_proxy( "{\n" );
|
||||
indent++;
|
||||
print_proxy( "NdrProxyInitialize(This, &_RpcMessage, &__frame->_StubMsg, &Object_StubDesc, %d);\n", idx);
|
||||
proxy_check_pointers( type_get_function_args(func->type) );
|
||||
write_pointer_checks( proxy, indent, func );
|
||||
|
||||
print_proxy( "RpcTryFinally\n" );
|
||||
print_proxy( "{\n" );
|
||||
|
@ -340,10 +282,9 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx,
|
|||
|
||||
if (has_ret)
|
||||
{
|
||||
if (decl_indirect(type_function_get_rettype(func->type)))
|
||||
if (decl_indirect(rettype))
|
||||
print_proxy("MIDL_memset(&%s, 0, sizeof(%s));\n", "_RetVal", "_RetVal");
|
||||
else if (is_ptr(type_function_get_rettype(func->type)) ||
|
||||
is_array(type_function_get_rettype(func->type)))
|
||||
else if (is_ptr(rettype) || is_array(rettype))
|
||||
print_proxy("%s = 0;\n", "_RetVal");
|
||||
write_remoting_arguments(proxy, indent, func, "", PASS_RETURN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
@ -385,6 +326,8 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
|
|||
int has_ret = !is_void(type_function_get_rettype(func->type));
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
|
||||
if (is_interpreted_func( iface, func )) return;
|
||||
|
||||
indent = 0;
|
||||
print_proxy( "struct __frame_%s_%s_Stub\n{\n", iface->name, get_name(func));
|
||||
indent++;
|
||||
|
@ -490,6 +433,32 @@ static void gen_stub(type_t *iface, const var_t *func, const char *cas,
|
|||
print_proxy("\n");
|
||||
}
|
||||
|
||||
static void gen_stub_thunk( type_t *iface, const var_t *func, unsigned int proc_offset )
|
||||
{
|
||||
int has_ret = !is_void( type_function_get_rettype( func->type ));
|
||||
const var_t *arg, *callas = is_callas( func->attrs );
|
||||
const var_list_t *args = type_get_function_args( func->type );
|
||||
|
||||
indent = 0;
|
||||
print_proxy( "void __RPC_API %s_%s_Thunk( PMIDL_STUB_MESSAGE pStubMsg )\n",
|
||||
iface->name, get_name(func) );
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
write_func_param_struct( proxy, iface, func->type,
|
||||
"*pParamStruct = (struct _PARAM_STRUCT *)pStubMsg->StackTop", has_ret );
|
||||
print_proxy( "%s%s_%s_Stub( pParamStruct->This",
|
||||
has_ret ? "pParamStruct->_RetVal = " : "", iface->name, callas->name );
|
||||
indent++;
|
||||
if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry )
|
||||
{
|
||||
fprintf( proxy, ",\n%*spParamStruct->%s", 4 * indent, "", arg->name );
|
||||
}
|
||||
fprintf( proxy, " );\n" );
|
||||
indent--;
|
||||
indent--;
|
||||
print_proxy( "}\n\n");
|
||||
}
|
||||
|
||||
int count_methods(const type_t *iface)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
@ -516,6 +485,36 @@ static const statement_t * get_callas_source(const type_t * iface, const var_t *
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void write_proxy_procformatstring_offsets( const type_t *iface, int skip )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (type_iface_get_inherit(iface))
|
||||
write_proxy_procformatstring_offsets( type_iface_get_inherit(iface), need_delegation(iface));
|
||||
else
|
||||
return;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
int missing = 0;
|
||||
|
||||
if (is_callas(func->attrs)) continue;
|
||||
if (is_local(func->attrs))
|
||||
{
|
||||
const statement_t * callas_source = get_callas_source(iface, func);
|
||||
if (!callas_source)
|
||||
missing = 1;
|
||||
else
|
||||
func = callas_source->u.var;
|
||||
}
|
||||
if (skip || missing)
|
||||
print_proxy( "(unsigned short)-1, /* %s::%s */\n", iface->name, get_name(func));
|
||||
else
|
||||
print_proxy( "%u, /* %s::%s */\n", func->procstring_offset, iface->name, get_name(func));
|
||||
}
|
||||
}
|
||||
|
||||
static int write_proxy_methods(type_t *iface, int skip)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
@ -527,12 +526,14 @@ static int write_proxy_methods(type_t *iface, int skip)
|
|||
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
|
||||
const var_t *func = stmt->u.var;
|
||||
if (!is_callas(func->attrs)) {
|
||||
if (i != func->type->details.function->idx )
|
||||
error("widl internal error: method index mismatch\n");
|
||||
if (i) fprintf(proxy, ",\n");
|
||||
if (skip || (is_local(func->attrs) && !get_callas_source(iface, func)))
|
||||
print_proxy( "0 /* %s_%s_Proxy */", iface->name, get_name(func));
|
||||
else print_proxy( "%s_%s_Proxy", iface->name, get_name(func));
|
||||
print_proxy( "0, /* %s::%s */\n", iface->name, get_name(func));
|
||||
else if (is_interpreted_func( iface, func ) &&
|
||||
!is_local( func->attrs ) &&
|
||||
type_iface_get_inherit(iface))
|
||||
print_proxy( "(void *)-1, /* %s::%s */\n", iface->name, get_name(func));
|
||||
else
|
||||
print_proxy( "%s_%s_Proxy,\n", iface->name, get_name(func));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
@ -563,6 +564,8 @@ static int write_stub_methods(type_t *iface, int skip)
|
|||
}
|
||||
if (i) fprintf(proxy,",\n");
|
||||
if (skip || missing) print_proxy("STUB_FORWARDING_FUNCTION");
|
||||
else if (is_interpreted_func( iface, func ))
|
||||
print_proxy( "(PRPC_STUB_FUNCTION)%s", get_stub_mode() == MODE_Oif ? "NdrStubCall2" : "NdrStubCall" );
|
||||
else print_proxy( "%s_%s_Stub", iface->name, fname);
|
||||
i++;
|
||||
}
|
||||
|
@ -570,13 +573,37 @@ static int write_stub_methods(type_t *iface, int skip)
|
|||
return i;
|
||||
}
|
||||
|
||||
static void write_thunk_methods( type_t *iface, int skip )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (type_iface_get_inherit( iface ))
|
||||
write_thunk_methods( type_iface_get_inherit(iface), need_delegation(iface) );
|
||||
else
|
||||
return; /* skip IUnknown */
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
const statement_t * callas_source = NULL;
|
||||
|
||||
if (is_callas(func->attrs)) continue;
|
||||
if (is_local(func->attrs)) callas_source = get_callas_source(iface, func);
|
||||
|
||||
if (!skip && callas_source && is_interpreted_func( iface, func ))
|
||||
print_proxy( "%s_%s_Thunk,\n", iface->name, get_name(callas_source->u.var) );
|
||||
else
|
||||
print_proxy( "0, /* %s::%s */\n", iface->name, get_name(func) );
|
||||
}
|
||||
}
|
||||
|
||||
static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
||||
{
|
||||
int count;
|
||||
const statement_t *stmt;
|
||||
int first_func = 1;
|
||||
|
||||
/* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
|
||||
int needs_stub_thunks = 0;
|
||||
int needs_inline_stubs = need_inline_stubs( iface ) || need_delegation( iface );
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC(stmt, type_iface_get_stmts(iface)) {
|
||||
var_t *func = stmt->u.var;
|
||||
|
@ -604,13 +631,39 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
|||
func->procstring_offset = *proc_offset;
|
||||
gen_proxy(iface, func, idx, *proc_offset);
|
||||
gen_stub(iface, func, cname, *proc_offset);
|
||||
*proc_offset += get_size_procformatstring_func( func );
|
||||
if (cas && is_interpreted_func( iface, func ))
|
||||
{
|
||||
needs_stub_thunks = 1;
|
||||
gen_stub_thunk(iface, func, *proc_offset);
|
||||
}
|
||||
*proc_offset += get_size_procformatstring_func( iface, func );
|
||||
}
|
||||
}
|
||||
|
||||
count = count_methods(iface);
|
||||
|
||||
write_procformatstring_offsets( proxy, iface );
|
||||
print_proxy( "static const unsigned short %s_FormatStringOffsetTable[] =\n", iface->name );
|
||||
print_proxy( "{\n" );
|
||||
indent++;
|
||||
write_proxy_procformatstring_offsets( iface, 0 );
|
||||
indent--;
|
||||
print_proxy( "};\n\n" );
|
||||
|
||||
/* proxy info */
|
||||
if (get_stub_mode() == MODE_Oif)
|
||||
{
|
||||
print_proxy( "static const MIDL_STUBLESS_PROXY_INFO %s_ProxyInfo =\n", iface->name );
|
||||
print_proxy( "{\n" );
|
||||
indent++;
|
||||
print_proxy( "&Object_StubDesc,\n" );
|
||||
print_proxy( "__MIDL_ProcFormatString.Format,\n" );
|
||||
print_proxy( "&%s_FormatStringOffsetTable[-3],\n", iface->name );
|
||||
print_proxy( "0,\n" );
|
||||
print_proxy( "0,\n" );
|
||||
print_proxy( "0\n" );
|
||||
indent--;
|
||||
print_proxy( "};\n\n" );
|
||||
}
|
||||
|
||||
/* proxy vtable */
|
||||
print_proxy( "static %sCINTERFACE_PROXY_VTABLE(%d) _%sProxyVtbl =\n",
|
||||
|
@ -619,18 +672,29 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
|||
indent++;
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
if (get_stub_mode() == MODE_Oif) print_proxy( "&%s_ProxyInfo,\n", iface->name );
|
||||
print_proxy( "&IID_%s,\n", iface->name);
|
||||
indent--;
|
||||
print_proxy( "},\n");
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
write_proxy_methods(iface, FALSE);
|
||||
fprintf(proxy, "\n");
|
||||
indent--;
|
||||
print_proxy( "}\n");
|
||||
indent--;
|
||||
print_proxy( "};\n\n");
|
||||
|
||||
/* stub thunk table */
|
||||
if (needs_stub_thunks)
|
||||
{
|
||||
print_proxy( "static const STUB_THUNK %s_StubThunkTable[] =\n", iface->name);
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
write_thunk_methods( iface, 0 );
|
||||
indent--;
|
||||
print_proxy( "};\n\n");
|
||||
}
|
||||
|
||||
/* server info */
|
||||
print_proxy( "static const MIDL_SERVER_INFO %s_ServerInfo =\n", iface->name );
|
||||
print_proxy( "{\n" );
|
||||
|
@ -639,7 +703,10 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
|||
print_proxy( "0,\n" );
|
||||
print_proxy( "__MIDL_ProcFormatString.Format,\n" );
|
||||
print_proxy( "&%s_FormatStringOffsetTable[-3],\n", iface->name );
|
||||
print_proxy( "0,\n" );
|
||||
if (needs_stub_thunks)
|
||||
print_proxy( "&%s_StubThunkTable[-3],\n", iface->name );
|
||||
else
|
||||
print_proxy( "0,\n" );
|
||||
print_proxy( "0,\n" );
|
||||
print_proxy( "0,\n" );
|
||||
print_proxy( "0\n" );
|
||||
|
@ -647,14 +714,16 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
|||
print_proxy( "};\n\n" );
|
||||
|
||||
/* stub vtable */
|
||||
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
write_stub_methods(iface, FALSE);
|
||||
fprintf(proxy, "\n");
|
||||
indent--;
|
||||
fprintf(proxy, "};\n");
|
||||
print_proxy( "\n");
|
||||
if (needs_inline_stubs)
|
||||
{
|
||||
print_proxy( "static const PRPC_STUB_FUNCTION %s_table[] =\n", iface->name);
|
||||
print_proxy( "{\n");
|
||||
indent++;
|
||||
write_stub_methods(iface, FALSE);
|
||||
fprintf(proxy, "\n");
|
||||
indent--;
|
||||
fprintf(proxy, "};\n\n");
|
||||
}
|
||||
print_proxy( "static %sCInterfaceStubVtbl _%sStubVtbl =\n",
|
||||
need_delegation_indirect(iface) ? "" : "const ", iface->name);
|
||||
print_proxy( "{\n");
|
||||
|
@ -664,7 +733,8 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
|||
print_proxy( "&IID_%s,\n", iface->name);
|
||||
print_proxy( "&%s_ServerInfo,\n", iface->name );
|
||||
print_proxy( "%d,\n", count);
|
||||
print_proxy( "&%s_table[-3],\n", iface->name);
|
||||
if (needs_inline_stubs) print_proxy( "&%s_table[-3]\n", iface->name );
|
||||
else print_proxy( "0\n" );
|
||||
indent--;
|
||||
print_proxy( "},\n");
|
||||
print_proxy( "{\n");
|
||||
|
@ -701,7 +771,11 @@ static int does_any_iface(const statement_list_t *stmts, type_pred_t pred)
|
|||
|
||||
int need_proxy(const type_t *iface)
|
||||
{
|
||||
return is_object(iface) && !is_local(iface->attrs);
|
||||
if (!is_object( iface )) return 0;
|
||||
if (is_local( iface->attrs )) return 0;
|
||||
if (is_attr( iface->attrs, ATTR_OLEAUTOMATION )) return 0;
|
||||
if (is_attr( iface->attrs, ATTR_DISPINTERFACE )) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int need_stub(const type_t *iface)
|
||||
|
@ -714,11 +788,47 @@ int need_proxy_file(const statement_list_t *stmts)
|
|||
return does_any_iface(stmts, need_proxy);
|
||||
}
|
||||
|
||||
int need_inline_stubs(const type_t *iface)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (get_stub_mode() == MODE_Os) return 1;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
if (is_local( func->attrs )) continue;
|
||||
if (!is_interpreted_func( iface, func )) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int need_proxy_and_inline_stubs(const type_t *iface)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (!need_proxy( iface )) return 0;
|
||||
if (get_stub_mode() == MODE_Os) return 1;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
const var_t *func = stmt->u.var;
|
||||
if (is_local( func->attrs )) continue;
|
||||
if (!is_interpreted_func( iface, func )) return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int need_stub_files(const statement_list_t *stmts)
|
||||
{
|
||||
return does_any_iface(stmts, need_stub);
|
||||
}
|
||||
|
||||
int need_inline_stubs_file(const statement_list_t *stmts)
|
||||
{
|
||||
return does_any_iface(stmts, need_inline_stubs);
|
||||
}
|
||||
|
||||
static void write_proxy_stmts(const statement_list_t *stmts, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
@ -779,25 +889,41 @@ static void write_proxy_routines(const statement_list_t *stmts)
|
|||
int expr_eval_routines;
|
||||
unsigned int proc_offset = 0;
|
||||
char *file_id = proxy_token;
|
||||
int i, count, have_baseiid;
|
||||
int i, count, have_baseiid = 0;
|
||||
type_t **interfaces;
|
||||
const type_t * delegate_to;
|
||||
|
||||
write_exceptions( proxy );
|
||||
print_proxy( "#ifndef __REDQ_RPCPROXY_H_VERSION__\n");
|
||||
print_proxy( "#define __REQUIRED_RPCPROXY_H_VERSION__ %u\n", get_stub_mode() == MODE_Oif ? 475 : 440);
|
||||
print_proxy( "#endif\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy( "struct __proxy_frame\n");
|
||||
print_proxy( "{\n");
|
||||
print_proxy( " __DECL_EXCEPTION_FRAME\n");
|
||||
print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
print_proxy( " void *This;\n");
|
||||
print_proxy( "};\n");
|
||||
if (get_stub_mode() == MODE_Oif) print_proxy( "#define USE_STUBLESS_PROXY\n");
|
||||
print_proxy( "#include \"rpcproxy.h\"\n");
|
||||
print_proxy( "#ifndef __RPCPROXY_H_VERSION__\n");
|
||||
print_proxy( "#error This code needs a newer version of rpcproxy.h\n");
|
||||
print_proxy( "#endif /* __RPCPROXY_H_VERSION__ */\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n");
|
||||
print_proxy( "{\n");
|
||||
print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n");
|
||||
print_proxy( "}\n");
|
||||
print_proxy( "#include \"%s\"\n", header_name);
|
||||
print_proxy( "\n");
|
||||
|
||||
if (does_any_iface(stmts, need_proxy_and_inline_stubs))
|
||||
{
|
||||
write_exceptions( proxy );
|
||||
print_proxy( "\n");
|
||||
print_proxy( "struct __proxy_frame\n");
|
||||
print_proxy( "{\n");
|
||||
print_proxy( " __DECL_EXCEPTION_FRAME\n");
|
||||
print_proxy( " MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
print_proxy( " void *This;\n");
|
||||
print_proxy( "};\n");
|
||||
print_proxy( "\n");
|
||||
print_proxy("static int __proxy_filter( struct __proxy_frame *__frame )\n");
|
||||
print_proxy( "{\n");
|
||||
print_proxy( " return (__frame->_StubMsg.dwStubPhase != PROXY_SENDRECEIVE);\n");
|
||||
print_proxy( "}\n");
|
||||
print_proxy( "\n");
|
||||
}
|
||||
|
||||
write_formatstringsdecl(proxy, indent, stmts, need_proxy);
|
||||
write_stubdescproto();
|
||||
write_proxy_stmts(stmts, &proc_offset);
|
||||
|
@ -840,7 +966,10 @@ static void write_proxy_routines(const statement_list_t *stmts)
|
|||
fprintf(proxy, "};\n");
|
||||
fprintf(proxy, "\n");
|
||||
|
||||
if ((have_baseiid = does_any_iface(stmts, need_delegation_indirect)))
|
||||
for (i = 0; i < count; i++)
|
||||
if ((have_baseiid = get_delegation_indirect( interfaces[i], NULL ))) break;
|
||||
|
||||
if (have_baseiid)
|
||||
{
|
||||
fprintf(proxy, "static const IID * _%s_BaseIIDList[] =\n", file_id);
|
||||
fprintf(proxy, "{\n");
|
||||
|
@ -881,7 +1010,7 @@ static void write_proxy_routines(const statement_list_t *stmts)
|
|||
else fprintf(proxy, " 0,\n");
|
||||
fprintf(proxy, " _%s_IID_Lookup,\n", file_id);
|
||||
fprintf(proxy, " %d,\n", count);
|
||||
fprintf(proxy, " 1,\n");
|
||||
fprintf(proxy, " %d,\n", get_stub_mode() == MODE_Oif ? 2 : 1);
|
||||
fprintf(proxy, " 0,\n");
|
||||
fprintf(proxy, " 0,\n");
|
||||
fprintf(proxy, " 0,\n");
|
||||
|
|
|
@ -61,39 +61,88 @@ static const char *get_coclass_threading( const type_t *class )
|
|||
return models[get_attrv( class->attrs, ATTR_THREADING )];
|
||||
}
|
||||
|
||||
static int write_interface( const type_t *iface )
|
||||
static const type_t *find_ps_factory( const statement_list_t *stmts )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE)
|
||||
{
|
||||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS && !strcmp( type->name, "PSFactoryBuffer" ))
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void write_interface( const type_t *iface, const type_t *ps_factory )
|
||||
{
|
||||
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
|
||||
const UUID *ps_uuid = get_attrp( ps_factory->attrs, ATTR_UUID );
|
||||
|
||||
if (!uuid) return 0;
|
||||
if (!is_object( iface )) return 0;
|
||||
if (!uuid) return;
|
||||
if (!is_object( iface )) return;
|
||||
if (!type_iface_get_inherit(iface)) /* special case for IUnknown */
|
||||
{
|
||||
put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
return 0;
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
return;
|
||||
}
|
||||
if (is_local( iface->attrs )) return 0;
|
||||
put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
if (is_local( iface->attrs )) return;
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
put_str( indent, "{\n" );
|
||||
indent++;
|
||||
put_str( indent, "NumMethods = s %u\n", count_methods( iface ));
|
||||
put_str( indent, "ProxyStubClsid32 = s '%%CLSID_PSFactoryBuffer%%'\n" );
|
||||
put_str( indent, "ProxyStubClsid32 = s '%s'\n", format_uuid( ps_uuid ));
|
||||
indent--;
|
||||
put_str( indent, "}\n" );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int write_interfaces( const statement_list_t *stmts )
|
||||
static void write_interfaces( const statement_list_t *stmts, const type_t *ps_factory )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
int count = 0;
|
||||
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE)
|
||||
count += write_interface( stmt->u.type );
|
||||
write_interface( stmt->u.type, ps_factory );
|
||||
}
|
||||
}
|
||||
|
||||
static void write_typelib_interface( const type_t *iface, const typelib_t *typelib )
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
const UUID *uuid = get_attrp( iface->attrs, ATTR_UUID );
|
||||
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
|
||||
if (!uuid) return;
|
||||
if (!is_object( iface )) return;
|
||||
if (!is_attr( iface->attrs, ATTR_OLEAUTOMATION ) && !is_attr( iface->attrs, ATTR_DISPINTERFACE ))
|
||||
return;
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), iface->name );
|
||||
put_str( indent, "{\n" );
|
||||
indent++;
|
||||
put_str( indent, "ProxyStubClsid = s '{00020424-0000-0000-C000-000000000046}'\n" );
|
||||
put_str( indent, "ProxyStubClsid32 = s '{00020424-0000-0000-C000-000000000046}'\n" );
|
||||
if (version)
|
||||
put_str( indent, "TypeLib = s '%s' { val Version = s '%u.%u' }\n",
|
||||
format_uuid( typelib_uuid ), MAJORVERSION(version), MINORVERSION(version) );
|
||||
else
|
||||
put_str( indent, "TypeLib = s '%s'", format_uuid( typelib_uuid ));
|
||||
indent--;
|
||||
put_str( indent, "}\n" );
|
||||
}
|
||||
|
||||
static void write_typelib_interfaces( const typelib_t *typelib )
|
||||
{
|
||||
const statement_t *stmt;
|
||||
|
||||
if (typelib->stmts) LIST_FOR_EACH_ENTRY( stmt, typelib->stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && type_get_type( stmt->u.type ) == TYPE_INTERFACE)
|
||||
write_typelib_interface( stmt->u.type, typelib );
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
static int write_coclass( const type_t *class, const typelib_t *typelib )
|
||||
|
@ -103,12 +152,13 @@ static int write_coclass( const type_t *class, const typelib_t *typelib )
|
|||
const char *progid = get_attrp( class->attrs, ATTR_PROGID );
|
||||
const char *vi_progid = get_attrp( class->attrs, ATTR_VIPROGID );
|
||||
const char *threading = get_coclass_threading( class );
|
||||
unsigned int version = get_attrv( class->attrs, ATTR_VERSION );
|
||||
|
||||
if (!uuid) return 0;
|
||||
if (typelib && !threading) return 0;
|
||||
if (typelib && !threading && !progid) return 0;
|
||||
if (!descr) descr = class->name;
|
||||
|
||||
put_str( indent, "ForceRemove '%s' = s '%s'\n", format_uuid( uuid ), descr );
|
||||
put_str( indent, "'%s' = s '%s'\n", format_uuid( uuid ), descr );
|
||||
put_str( indent++, "{\n" );
|
||||
if (threading) put_str( indent, "InprocServer32 = s '%%MODULE%%' { val ThreadingModel = s '%s' }\n",
|
||||
threading );
|
||||
|
@ -116,10 +166,10 @@ static int write_coclass( const type_t *class, const typelib_t *typelib )
|
|||
if (typelib)
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
const unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
put_str( indent, "TypeLib = s '%s'\n", format_uuid( typelib_uuid ));
|
||||
put_str( indent, "Version = s '%u.%u'\n", MAJORVERSION(version), MINORVERSION(version) );
|
||||
if (!version) version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
}
|
||||
if (version) put_str( indent, "Version = s '%u.%u'\n", MAJORVERSION(version), MINORVERSION(version) );
|
||||
if (vi_progid) put_str( indent, "VersionIndependentProgId = s '%s'\n", vi_progid );
|
||||
put_str( --indent, "}\n" );
|
||||
return 1;
|
||||
|
@ -136,11 +186,6 @@ static void write_coclasses( const statement_list_t *stmts, const typelib_t *typ
|
|||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS) write_coclass( type, typelib );
|
||||
}
|
||||
else if (stmt->type == STMT_LIBRARY)
|
||||
{
|
||||
const typelib_t *lib = stmt->u.lib;
|
||||
write_coclasses( lib->stmts, lib );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,27 +228,12 @@ static void write_progids( const statement_list_t *stmts )
|
|||
const type_t *type = stmt->u.type;
|
||||
if (type_get_type(type) == TYPE_COCLASS) write_progid( type );
|
||||
}
|
||||
else if (stmt->type == STMT_LIBRARY)
|
||||
{
|
||||
write_progids( stmt->u.lib->stmts );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* put a string into the resource file */
|
||||
static inline void put_string( const char *str )
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
unsigned char ch = *str++;
|
||||
put_word( toupper(ch) );
|
||||
}
|
||||
put_word( 0 );
|
||||
}
|
||||
|
||||
void write_regscript( const statement_list_t *stmts )
|
||||
{
|
||||
int count;
|
||||
const type_t *ps_factory;
|
||||
|
||||
if (!do_regscript) return;
|
||||
if (do_everything && !need_proxy_file( stmts )) return;
|
||||
|
@ -215,18 +245,12 @@ void write_regscript( const statement_list_t *stmts )
|
|||
|
||||
put_str( indent, "NoRemove Interface\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
count = write_interfaces( stmts );
|
||||
ps_factory = find_ps_factory( stmts );
|
||||
if (ps_factory) write_interfaces( stmts, ps_factory );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove CLSID\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
if (count)
|
||||
{
|
||||
put_str( indent, "ForceRemove '%%CLSID_PSFactoryBuffer%%' = s 'PSFactoryBuffer'\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "InprocServer32 = s '%%MODULE%%' { val ThreadingModel = s 'Both' }\n" );
|
||||
put_str( --indent, "}\n" );
|
||||
}
|
||||
write_coclasses( stmts, NULL );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
|
@ -235,41 +259,8 @@ void write_regscript( const statement_list_t *stmts )
|
|||
|
||||
if (strendswith( regscript_name, ".res" )) /* create a binary resource file */
|
||||
{
|
||||
unsigned char *data = output_buffer;
|
||||
size_t data_size = output_buffer_pos;
|
||||
size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
|
||||
|
||||
header_size += (strlen(regscript_token) + strlen("WINE_REGISTRY") + 2) * sizeof(unsigned short);
|
||||
|
||||
init_output_buffer();
|
||||
|
||||
put_dword( 0 ); /* ResSize */
|
||||
put_dword( 32 ); /* HeaderSize */
|
||||
put_word( 0xffff ); /* ResType */
|
||||
put_word( 0x0000 );
|
||||
put_word( 0xffff ); /* ResName */
|
||||
put_word( 0x0000 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
put_dword( data_size ); /* ResSize */
|
||||
put_dword( (header_size + 3) & ~3 ); /* HeaderSize */
|
||||
put_string( "WINE_REGISTRY" ); /* ResType */
|
||||
put_string( regscript_token ); /* ResName */
|
||||
align_output( 4 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
put_data( data, data_size );
|
||||
free( data );
|
||||
align_output( 4 );
|
||||
flush_output_buffer( regscript_name );
|
||||
add_output_to_resources( "WINE_REGISTRY", regscript_token );
|
||||
flush_output_resources( regscript_name );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -281,3 +272,48 @@ void write_regscript( const statement_list_t *stmts )
|
|||
error( "Failed to write to %s\n", regscript_name );
|
||||
}
|
||||
}
|
||||
|
||||
void output_typelib_regscript( const typelib_t *typelib )
|
||||
{
|
||||
const UUID *typelib_uuid = get_attrp( typelib->attrs, ATTR_UUID );
|
||||
const char *descr = get_attrp( typelib->attrs, ATTR_HELPSTRING );
|
||||
const expr_t *lcid_expr = get_attrp( typelib->attrs, ATTR_LIBLCID );
|
||||
unsigned int version = get_attrv( typelib->attrs, ATTR_VERSION );
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (is_attr( typelib->attrs, ATTR_RESTRICTED )) flags |= 1; /* LIBFLAG_FRESTRICTED */
|
||||
if (is_attr( typelib->attrs, ATTR_CONTROL )) flags |= 2; /* LIBFLAG_FCONTROL */
|
||||
if (is_attr( typelib->attrs, ATTR_HIDDEN )) flags |= 4; /* LIBFLAG_FHIDDEN */
|
||||
|
||||
put_str( indent, "HKCR\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
|
||||
put_str( indent, "NoRemove Typelib\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "NoRemove '%s'\n", format_uuid( typelib_uuid ));
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "'%u.%u' = s '%s'\n",
|
||||
MAJORVERSION(version), MINORVERSION(version), descr ? descr : typelib->name );
|
||||
put_str( indent++, "{\n" );
|
||||
put_str( indent, "'%x' { %s = s '%%MODULE%%' }\n",
|
||||
lcid_expr ? lcid_expr->cval : 0, typelib_kind == SYS_WIN64 ? "win64" : "win32" );
|
||||
put_str( indent, "FLAGS = s '%u'\n", flags );
|
||||
put_str( --indent, "}\n" );
|
||||
put_str( --indent, "}\n" );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove Interface\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
write_typelib_interfaces( typelib );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
put_str( indent, "NoRemove CLSID\n" );
|
||||
put_str( indent++, "{\n" );
|
||||
write_coclasses( typelib->stmts, typelib );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
write_progids( typelib->stmts );
|
||||
put_str( --indent, "}\n" );
|
||||
|
||||
add_output_to_resources( "WINE_REGISTRY", typelib_name );
|
||||
}
|
||||
|
|
|
@ -49,202 +49,209 @@ static void print_server(const char *format, ...)
|
|||
va_end(va);
|
||||
}
|
||||
|
||||
static void write_function_stub(const type_t *iface, const var_t *func, unsigned int proc_offset)
|
||||
{
|
||||
const var_t *var;
|
||||
unsigned char explicit_fc, implicit_fc;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
const var_t *handle_var = get_func_handle_var( iface, func, &explicit_fc, &implicit_fc );
|
||||
|
||||
if (is_interpreted_func( iface, func )) return;
|
||||
|
||||
print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(func));
|
||||
indent++;
|
||||
print_server("__DECL_EXCEPTION_FRAME\n");
|
||||
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
|
||||
/* Declare arguments */
|
||||
declare_stub_args(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("};\n\n");
|
||||
|
||||
print_server("static void __finally_%s_%s(", iface->name, get_name(func));
|
||||
fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(func));
|
||||
|
||||
indent++;
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_FREE);
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("}\n\n");
|
||||
|
||||
print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(func));
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(server, "{\n");
|
||||
indent++;
|
||||
print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(func));
|
||||
if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
print_server("NdrServerInitializeNew(\n");
|
||||
indent++;
|
||||
print_server("_pRpcMessage,\n");
|
||||
print_server("&__frame->_StubMsg,\n");
|
||||
print_server("&%s_StubDesc);\n", iface->name);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(func));
|
||||
|
||||
write_parameters_init(server, indent, func, "__frame->");
|
||||
|
||||
if (explicit_fc == RPC_FC_BIND_PRIMITIVE)
|
||||
{
|
||||
print_server("__frame->%s = _pRpcMessage->Handle;\n", handle_var->name);
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
print_server("RpcTryFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcTryExcept\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(server, indent, func, TRUE);
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||
indent++;
|
||||
print_server("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
proc_offset);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
|
||||
/* unmarshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
print_server("if (__frame->_StubMsg.Buffer > __frame->_StubMsg.BufferEnd)\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcExcept(RPC_BAD_STUB_DATA_EXCEPTION_FILTER)\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcEndExcept\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
/* Assign 'out' arguments */
|
||||
assign_stub_out_args(server, indent, func, "__frame->");
|
||||
|
||||
/* Call the real server function */
|
||||
print_server("%s%s%s",
|
||||
is_void(type_function_get_rettype(func->type)) ? "" : "__frame->_RetVal = ",
|
||||
prefix_server, get_name(func));
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
int first_arg = 1;
|
||||
|
||||
fprintf(server, "(\n");
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
{
|
||||
if (first_arg)
|
||||
first_arg = 0;
|
||||
else
|
||||
fprintf(server, ",\n");
|
||||
if (is_context_handle(var->type))
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
int is_ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE;
|
||||
print_server("(");
|
||||
write_type_decl_left(server, var->type);
|
||||
fprintf(server, ")%sNDRSContextValue(__frame->%s)",
|
||||
is_ch_ptr ? "" : "*", var->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_server("%s__frame->%s", is_array(var->type) && !type_array_is_decl_as_ptr(var->type) ? "*" : "", var->name);
|
||||
}
|
||||
}
|
||||
fprintf(server, ");\n");
|
||||
indent--;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(server, "();\n");
|
||||
}
|
||||
|
||||
if (has_out_arg_or_return(func))
|
||||
{
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n");
|
||||
fprintf(server, "\n");
|
||||
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");
|
||||
print_server("if (_Status)\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(_Status);\n");
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
print_server("__frame->_StubMsg.Buffer = _pRpcMessage->Buffer;\n");
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
/* marshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL);
|
||||
|
||||
/* marshall the return value */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL);
|
||||
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(func));
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcEndFinally\n");
|
||||
|
||||
/* calculate buffer length */
|
||||
fprintf(server, "\n");
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
|
||||
indent--;
|
||||
fprintf(server, "}\n");
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
|
||||
static void write_function_stubs(type_t *iface, unsigned int *proc_offset)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
const var_t *var;
|
||||
const var_t* explicit_handle_var;
|
||||
|
||||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
int has_full_pointer = is_full_pointer_function(func);
|
||||
|
||||
/* check for a defined binding handle */
|
||||
explicit_handle_var = get_explicit_handle_var(func);
|
||||
|
||||
print_server("struct __frame_%s_%s\n{\n", iface->name, get_name(func));
|
||||
indent++;
|
||||
print_server("__DECL_EXCEPTION_FRAME\n");
|
||||
print_server("MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
|
||||
/* Declare arguments */
|
||||
declare_stub_args(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("};\n\n");
|
||||
|
||||
print_server("static void __finally_%s_%s(", iface->name, get_name(func));
|
||||
fprintf(server," struct __frame_%s_%s *__frame )\n{\n", iface->name, get_name(func));
|
||||
|
||||
indent++;
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_FREE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_FREE);
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_free(server, indent, func);
|
||||
|
||||
indent--;
|
||||
print_server("}\n\n");
|
||||
|
||||
print_server("void __RPC_STUB %s_%s( PRPC_MESSAGE _pRpcMessage )\n", iface->name, get_name(func));
|
||||
|
||||
/* write the functions body */
|
||||
fprintf(server, "{\n");
|
||||
indent++;
|
||||
print_server("struct __frame_%s_%s __f, * const __frame = &__f;\n", iface->name, get_name(func));
|
||||
if (has_out_arg_or_return(func)) print_server("RPC_STATUS _Status;\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
print_server("NdrServerInitializeNew(\n");
|
||||
indent++;
|
||||
print_server("_pRpcMessage,\n");
|
||||
print_server("&__frame->_StubMsg,\n");
|
||||
print_server("&%s_StubDesc);\n", iface->name);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
print_server( "RpcExceptionInit( __server_filter, __finally_%s_%s );\n", iface->name, get_name(func));
|
||||
|
||||
write_parameters_init(server, indent, func, "__frame->");
|
||||
|
||||
if (explicit_handle_var)
|
||||
{
|
||||
print_server("__frame->%s = _pRpcMessage->Handle;\n", explicit_handle_var->name);
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
print_server("RpcTryFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcTryExcept\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
|
||||
if (has_full_pointer)
|
||||
write_full_pointer_init(server, indent, func, TRUE);
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
print_server("if ((_pRpcMessage->DataRepresentation & 0x0000FFFFUL) != NDR_LOCAL_DATA_REPRESENTATION)\n");
|
||||
indent++;
|
||||
print_server("NdrConvert(&__frame->_StubMsg, (PFORMAT_STRING)&__MIDL_ProcFormatString.Format[%u]);\n",
|
||||
*proc_offset);
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
|
||||
/* unmarshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_IN, PHASE_UNMARSHAL);
|
||||
}
|
||||
|
||||
print_server("if (__frame->_StubMsg.Buffer > __frame->_StubMsg.BufferEnd)\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcExcept(RPC_BAD_STUB_DATA_EXCEPTION_FILTER)\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(RPC_X_BAD_STUB_DATA);\n");
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcEndExcept\n");
|
||||
fprintf(server, "\n");
|
||||
|
||||
/* Assign 'out' arguments */
|
||||
assign_stub_out_args(server, indent, func, "__frame->");
|
||||
|
||||
/* Call the real server function */
|
||||
print_server("%s%s%s",
|
||||
is_void(type_function_get_rettype(func->type)) ? "" : "__frame->_RetVal = ",
|
||||
prefix_server, get_name(func));
|
||||
|
||||
if (type_get_function_args(func->type))
|
||||
{
|
||||
int first_arg = 1;
|
||||
|
||||
fprintf(server, "(\n");
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( var, type_get_function_args(func->type), const var_t, entry )
|
||||
{
|
||||
if (first_arg)
|
||||
first_arg = 0;
|
||||
else
|
||||
fprintf(server, ",\n");
|
||||
if (is_context_handle(var->type))
|
||||
{
|
||||
/* if the context_handle attribute appears in the chain of types
|
||||
* without pointers being followed, then the context handle must
|
||||
* be direct, otherwise it is a pointer */
|
||||
int is_ch_ptr = is_aliaschain_attr(var->type, ATTR_CONTEXTHANDLE) ? FALSE : TRUE;
|
||||
print_server("(");
|
||||
write_type_decl_left(server, var->type);
|
||||
fprintf(server, ")%sNDRSContextValue(__frame->%s)",
|
||||
is_ch_ptr ? "" : "*", var->name);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_server("%s__frame->%s", is_array(var->type) && !type_array_is_decl_as_ptr(var->type) ? "*" : "", var->name);
|
||||
}
|
||||
}
|
||||
fprintf(server, ");\n");
|
||||
indent--;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(server, "();\n");
|
||||
}
|
||||
|
||||
if (has_out_arg_or_return(func))
|
||||
{
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_BUFFERSIZE);
|
||||
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_BUFFERSIZE);
|
||||
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.BufferLength;\n");
|
||||
fprintf(server, "\n");
|
||||
print_server("_Status = I_RpcGetBuffer(_pRpcMessage);\n");
|
||||
print_server("if (_Status)\n");
|
||||
indent++;
|
||||
print_server("RpcRaiseException(_Status);\n");
|
||||
indent--;
|
||||
fprintf(server, "\n");
|
||||
print_server("__frame->_StubMsg.Buffer = _pRpcMessage->Buffer;\n");
|
||||
fprintf(server, "\n");
|
||||
}
|
||||
|
||||
/* marshall arguments */
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_OUT, PHASE_MARSHAL);
|
||||
|
||||
/* marshall the return value */
|
||||
if (!is_void(type_function_get_rettype(func->type)))
|
||||
write_remoting_arguments(server, indent, func, "__frame->", PASS_RETURN, PHASE_MARSHAL);
|
||||
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcFinally\n");
|
||||
print_server("{\n");
|
||||
indent++;
|
||||
print_server("__finally_%s_%s( __frame );\n", iface->name, get_name(func));
|
||||
indent--;
|
||||
print_server("}\n");
|
||||
print_server("RpcEndFinally\n");
|
||||
|
||||
/* calculate buffer length */
|
||||
fprintf(server, "\n");
|
||||
print_server("_pRpcMessage->BufferLength = __frame->_StubMsg.Buffer - (unsigned char *)_pRpcMessage->Buffer;\n");
|
||||
indent--;
|
||||
fprintf(server, "}\n");
|
||||
fprintf(server, "\n");
|
||||
write_function_stub( iface, func, *proc_offset );
|
||||
|
||||
/* update proc_offset */
|
||||
func->procstring_offset = *proc_offset;
|
||||
*proc_offset += get_size_procformatstring_func( func );
|
||||
*proc_offset += get_size_procformatstring_func( iface, func );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,7 +269,10 @@ static void write_dispatchtable(type_t *iface)
|
|||
STATEMENTS_FOR_EACH_FUNC( stmt, type_iface_get_stmts(iface) )
|
||||
{
|
||||
var_t *func = stmt->u.var;
|
||||
print_server("%s_%s,\n", iface->name, get_name(func));
|
||||
if (is_interpreted_func( iface, func ))
|
||||
print_server("%s,\n", get_stub_mode() == MODE_Oif ? "NdrServerCall2" : "NdrServerCall");
|
||||
else
|
||||
print_server("%s_%s,\n", iface->name, get_name(func));
|
||||
method_count++;
|
||||
}
|
||||
print_server("0\n");
|
||||
|
@ -290,7 +300,27 @@ static void write_routinetable(type_t *iface)
|
|||
{
|
||||
var_t *func = stmt->u.var;
|
||||
if (is_local( func->attrs )) continue;
|
||||
print_server( "(SERVER_ROUTINE)%s,\n", func->name );
|
||||
print_server( "(SERVER_ROUTINE)%s%s,\n", prefix_server, get_name(func));
|
||||
}
|
||||
indent--;
|
||||
print_server( "};\n\n" );
|
||||
}
|
||||
|
||||
|
||||
static void write_rundown_routines(void)
|
||||
{
|
||||
context_handle_t *ch;
|
||||
int count = list_count( &context_handle_list );
|
||||
|
||||
if (!count) return;
|
||||
print_server( "static const NDR_RUNDOWN RundownRoutines[] =\n" );
|
||||
print_server( "{\n" );
|
||||
indent++;
|
||||
LIST_FOR_EACH_ENTRY( ch, &context_handle_list, context_handle_t, entry )
|
||||
{
|
||||
print_server( "%s_rundown", ch->name );
|
||||
if (--count) fputc( ',', server );
|
||||
fputc( '\n', server );
|
||||
}
|
||||
indent--;
|
||||
print_server( "};\n\n" );
|
||||
|
@ -335,7 +365,10 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
|||
print_server("0,\n");
|
||||
indent--;
|
||||
print_server("},\n");
|
||||
print_server("0,\n");
|
||||
if (!list_empty( &context_handle_list ))
|
||||
print_server("RundownRoutines,\n");
|
||||
else
|
||||
print_server("0,\n");
|
||||
print_server("0,\n");
|
||||
if (expr_eval_routines)
|
||||
print_server("ExprEvalRoutines,\n");
|
||||
|
@ -344,7 +377,7 @@ static void write_stubdescriptor(type_t *iface, int expr_eval_routines)
|
|||
print_server("0,\n");
|
||||
print_server("__MIDL_TypeFormatString.Format,\n");
|
||||
print_server("1, /* -error bounds_check flag */\n");
|
||||
print_server("0x10001, /* Ndr library version */\n");
|
||||
print_server("0x%x, /* Ndr library version */\n", get_stub_mode() == MODE_Oif ? 0x50002 : 0x10001);
|
||||
print_server("0,\n");
|
||||
print_server("0x50100a4, /* MIDL Version 5.1.164 */\n");
|
||||
print_server("0,\n");
|
||||
|
@ -470,28 +503,32 @@ static void write_server_routines(const statement_list_t *stmts)
|
|||
unsigned int proc_offset = 0;
|
||||
int expr_eval_routines;
|
||||
|
||||
write_exceptions( server );
|
||||
print_server("\n");
|
||||
print_server("struct __server_frame\n");
|
||||
print_server("{\n");
|
||||
print_server(" __DECL_EXCEPTION_FRAME\n");
|
||||
print_server(" MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
print_server("};\n");
|
||||
print_server("\n");
|
||||
print_server("static int __server_filter( struct __server_frame *__frame )\n");
|
||||
print_server( "{\n");
|
||||
print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n");
|
||||
print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n");
|
||||
print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n");
|
||||
print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n");
|
||||
print_server( "}\n");
|
||||
print_server( "\n");
|
||||
if (need_inline_stubs_file( stmts ))
|
||||
{
|
||||
write_exceptions( server );
|
||||
print_server("\n");
|
||||
print_server("struct __server_frame\n");
|
||||
print_server("{\n");
|
||||
print_server(" __DECL_EXCEPTION_FRAME\n");
|
||||
print_server(" MIDL_STUB_MESSAGE _StubMsg;\n");
|
||||
print_server("};\n");
|
||||
print_server("\n");
|
||||
print_server("static int __server_filter( struct __server_frame *__frame )\n");
|
||||
print_server( "{\n");
|
||||
print_server( " return (__frame->code == STATUS_ACCESS_VIOLATION) ||\n");
|
||||
print_server( " (__frame->code == STATUS_DATATYPE_MISALIGNMENT) ||\n");
|
||||
print_server( " (__frame->code == RPC_X_BAD_STUB_DATA) ||\n");
|
||||
print_server( " (__frame->code == RPC_S_INVALID_BOUND);\n");
|
||||
print_server( "}\n");
|
||||
print_server( "\n");
|
||||
}
|
||||
|
||||
write_formatstringsdecl(server, indent, stmts, need_stub);
|
||||
expr_eval_routines = write_expr_eval_routines(server, server_token);
|
||||
if (expr_eval_routines)
|
||||
write_expr_eval_routine_list(server, server_token);
|
||||
write_user_quad_list(server);
|
||||
write_rundown_routines();
|
||||
|
||||
write_server_stmts(stmts, expr_eval_routines, &proc_offset);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -68,20 +68,28 @@ void write_typeformatstring(FILE *file, const statement_list_t *stmts, type_pred
|
|||
void write_procformatstring_offsets( FILE *file, const type_t *iface );
|
||||
void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, enum remoting_phase phase,
|
||||
enum pass pass, const var_t *var, const char *varname);
|
||||
void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char *local_var_prefix,
|
||||
enum remoting_phase phase, const var_t *var, int valid_variance);
|
||||
void write_remoting_arguments(FILE *file, int indent, const var_t *func, const char *local_var_prefix,
|
||||
enum pass pass, enum remoting_phase phase);
|
||||
unsigned int get_size_procformatstring_func(const var_t *func);
|
||||
unsigned int get_size_procformatstring_func(const type_t *iface, const var_t *func);
|
||||
unsigned int get_size_procformatstring(const statement_list_t *stmts, type_pred_t pred);
|
||||
unsigned int get_size_typeformatstring(const statement_list_t *stmts, type_pred_t pred);
|
||||
void assign_stub_out_args( FILE *file, int indent, const var_t *func, const char *local_var_prefix );
|
||||
void declare_stub_args( FILE *file, int indent, const var_t *func );
|
||||
void write_func_param_struct( FILE *file, const type_t *iface, const type_t *func,
|
||||
const char *var_decl, int add_retval );
|
||||
void write_pointer_checks( FILE *file, int indent, const var_t *func );
|
||||
int write_expr_eval_routines(FILE *file, const char *iface);
|
||||
void write_expr_eval_routine_list(FILE *file, const char *iface);
|
||||
void write_user_quad_list(FILE *file);
|
||||
void write_endpoints( FILE *f, const char *prefix, const str_list_t *list );
|
||||
void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func,
|
||||
const char *prefix, unsigned int proc_offset );
|
||||
void write_exceptions( FILE *file );
|
||||
unsigned int type_memsize(const type_t *t);
|
||||
int decl_indirect(const type_t *t);
|
||||
int is_interpreted_func(const type_t *iface, const var_t *func);
|
||||
void write_parameters_init(FILE *file, int indent, const var_t *func, const char *local_var_prefix);
|
||||
void print(FILE *file, int indent, const char *format, va_list ap);
|
||||
expr_t *get_size_is_expr(const type_t *t, const char *name);
|
||||
|
|
|
@ -35,7 +35,8 @@
|
|||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include <typedefs.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#include "widl.h"
|
||||
#include "utils.h"
|
||||
|
@ -254,9 +255,7 @@ unsigned short get_type_vt(type_t *t)
|
|||
void start_typelib(typelib_t *typelib_type)
|
||||
{
|
||||
if (!do_typelib) return;
|
||||
|
||||
typelib = typelib_type;
|
||||
typelib->filename = xstrdup(typelib_name);
|
||||
}
|
||||
|
||||
void end_typelib(void)
|
||||
|
|
|
@ -302,7 +302,7 @@ typedef struct {
|
|||
*
|
||||
*/
|
||||
|
||||
#include <pshpack1.h>
|
||||
#include "pshpack1.h"
|
||||
|
||||
typedef struct {
|
||||
/*00*/ DWORD SLTG_magic; /* 0x47544c53 == "SLTG" */
|
||||
|
@ -599,7 +599,7 @@ WORD offset from start of block to SAFEARRAY
|
|||
WORD typeofarray
|
||||
*/
|
||||
|
||||
#include <poppack.h>
|
||||
#include "poppack.h"
|
||||
|
||||
/*---------------------------END--------------------------------------------*/
|
||||
#endif
|
||||
|
|
|
@ -253,6 +253,13 @@ unsigned char *output_buffer;
|
|||
size_t output_buffer_pos;
|
||||
size_t output_buffer_size;
|
||||
|
||||
static struct resource
|
||||
{
|
||||
unsigned char *data;
|
||||
size_t size;
|
||||
} resources[16];
|
||||
static unsigned int nb_resources;
|
||||
|
||||
static void check_output_buffer_space( size_t size )
|
||||
{
|
||||
if (output_buffer_pos + size >= output_buffer_size)
|
||||
|
@ -279,6 +286,93 @@ void flush_output_buffer( const char *name )
|
|||
free( output_buffer );
|
||||
}
|
||||
|
||||
static inline void put_resource_id( const char *str )
|
||||
{
|
||||
if (str[0] != '#')
|
||||
{
|
||||
while (*str)
|
||||
{
|
||||
unsigned char ch = *str++;
|
||||
put_word( toupper(ch) );
|
||||
}
|
||||
put_word( 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
put_word( 0xffff );
|
||||
put_word( atoi( str + 1 ));
|
||||
}
|
||||
}
|
||||
|
||||
void add_output_to_resources( const char *type, const char *name )
|
||||
{
|
||||
size_t data_size = output_buffer_pos;
|
||||
size_t header_size = 5 * sizeof(unsigned int) + 2 * sizeof(unsigned short);
|
||||
|
||||
assert( nb_resources < sizeof(resources)/sizeof(resources[0]) );
|
||||
|
||||
if (type[0] != '#') header_size += (strlen( type ) + 1) * sizeof(unsigned short);
|
||||
else header_size += 2 * sizeof(unsigned short);
|
||||
if (name[0] != '#') header_size += (strlen( name ) + 1) * sizeof(unsigned short);
|
||||
else header_size += 2 * sizeof(unsigned short);
|
||||
|
||||
header_size = (header_size + 3) & ~3;
|
||||
align_output( 4 );
|
||||
check_output_buffer_space( header_size );
|
||||
resources[nb_resources].size = header_size + output_buffer_pos;
|
||||
memmove( output_buffer + header_size, output_buffer, output_buffer_pos );
|
||||
|
||||
output_buffer_pos = 0;
|
||||
put_dword( data_size ); /* ResSize */
|
||||
put_dword( header_size ); /* HeaderSize */
|
||||
put_resource_id( type ); /* ResType */
|
||||
put_resource_id( name ); /* ResName */
|
||||
align_output( 4 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
resources[nb_resources++].data = output_buffer;
|
||||
init_output_buffer();
|
||||
}
|
||||
|
||||
void flush_output_resources( const char *name )
|
||||
{
|
||||
int fd;
|
||||
unsigned int i;
|
||||
|
||||
/* all output must have been saved with add_output_to_resources() first */
|
||||
assert( !output_buffer_pos );
|
||||
|
||||
put_dword( 0 ); /* ResSize */
|
||||
put_dword( 32 ); /* HeaderSize */
|
||||
put_word( 0xffff ); /* ResType */
|
||||
put_word( 0x0000 );
|
||||
put_word( 0xffff ); /* ResName */
|
||||
put_word( 0x0000 );
|
||||
put_dword( 0 ); /* DataVersion */
|
||||
put_word( 0 ); /* Memory options */
|
||||
put_word( 0 ); /* Language */
|
||||
put_dword( 0 ); /* Version */
|
||||
put_dword( 0 ); /* Characteristics */
|
||||
|
||||
fd = open( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666 );
|
||||
if (fd == -1) error( "Error creating %s\n", name );
|
||||
if (write( fd, output_buffer, output_buffer_pos ) != output_buffer_pos)
|
||||
error( "Error writing to %s\n", name );
|
||||
for (i = 0; i < nb_resources; i++)
|
||||
{
|
||||
if (write( fd, resources[i].data, resources[i].size ) != resources[i].size)
|
||||
error( "Error writing to %s\n", name );
|
||||
free( resources[i].data );
|
||||
}
|
||||
close( fd );
|
||||
nb_resources = 0;
|
||||
free( output_buffer );
|
||||
}
|
||||
|
||||
void put_data( const void *data, size_t size )
|
||||
{
|
||||
check_output_buffer_space( size );
|
||||
|
|
|
@ -58,6 +58,8 @@ extern size_t output_buffer_size;
|
|||
|
||||
extern void init_output_buffer(void);
|
||||
extern void flush_output_buffer( const char *name );
|
||||
extern void add_output_to_resources( const char *type, const char *name );
|
||||
extern void flush_output_resources( const char *name );
|
||||
extern void put_data( const void *data, size_t size );
|
||||
extern void put_byte( unsigned char val );
|
||||
extern void put_word( unsigned short val );
|
||||
|
|
|
@ -46,7 +46,6 @@
|
|||
/* future options to reserve characters for: */
|
||||
/* A = ACF input filename */
|
||||
/* J = do not search standard include path */
|
||||
/* O = generate interpreted stubs */
|
||||
/* w = select win16/win32 output (?) */
|
||||
|
||||
static const char usage[] =
|
||||
|
@ -65,6 +64,7 @@ static const char usage[] =
|
|||
" -N Do not preprocess input\n"
|
||||
" --oldnames Use old naming conventions\n"
|
||||
" -o, --output=NAME Set the output file name\n"
|
||||
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
|
||||
" -p Generate proxy\n"
|
||||
" --prefix-all=p Prefix names of client stubs / server functions with 'p'\n"
|
||||
" --prefix-client=p Prefix names of client stubs with 'p'\n"
|
||||
|
@ -111,6 +111,7 @@ int do_win32 = 1;
|
|||
int do_win64 = 1;
|
||||
int win32_packing = 8;
|
||||
int win64_packing = 8;
|
||||
static enum stub_mode stub_mode = MODE_Os;
|
||||
|
||||
char *input_name;
|
||||
char *header_name;
|
||||
|
@ -136,7 +137,7 @@ int line_number = 1;
|
|||
|
||||
static FILE *idfile;
|
||||
|
||||
size_t pointer_size = 0;
|
||||
unsigned int pointer_size = 0;
|
||||
syskind_t typelib_kind = sizeof(void*) == 8 ? SYS_WIN64 : SYS_WIN32;
|
||||
|
||||
time_t now;
|
||||
|
@ -156,7 +157,7 @@ enum {
|
|||
};
|
||||
|
||||
static const char short_options[] =
|
||||
"b:cC:d:D:EhH:I:m:No:pP:rsS:tT:uU:VW";
|
||||
"b:cC:d:D:EhH:I:m:No:O:pP:rsS:tT:uU:VW";
|
||||
static const struct option long_options[] = {
|
||||
{ "dlldata", 1, NULL, DLLDATA_OPTION },
|
||||
{ "dlldata-only", 0, NULL, DLLDATA_ONLY_OPTION },
|
||||
|
@ -175,6 +176,13 @@ static const struct option long_options[] = {
|
|||
|
||||
static void rm_tempfile(void);
|
||||
|
||||
enum stub_mode get_stub_mode(void)
|
||||
{
|
||||
/* old-style interpreted stubs are not supported on 64-bit */
|
||||
if (stub_mode == MODE_Oi && pointer_size == 8) return MODE_Oif;
|
||||
return stub_mode;
|
||||
}
|
||||
|
||||
static char *make_token(const char *name)
|
||||
{
|
||||
char *token;
|
||||
|
@ -482,8 +490,6 @@ void write_id_data(const statement_list_t *stmts)
|
|||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
extern char* optarg;
|
||||
extern int optind;
|
||||
int optc;
|
||||
int ret = 0;
|
||||
int opti = 0;
|
||||
|
@ -582,6 +588,14 @@ int main(int argc,char *argv[])
|
|||
case 'o':
|
||||
output_name = xstrdup(optarg);
|
||||
break;
|
||||
case 'O':
|
||||
if (!strcmp( optarg, "s" )) stub_mode = MODE_Os;
|
||||
else if (!strcmp( optarg, "i" )) stub_mode = MODE_Oi;
|
||||
else if (!strcmp( optarg, "ic" )) stub_mode = MODE_Oif;
|
||||
else if (!strcmp( optarg, "if" )) stub_mode = MODE_Oif;
|
||||
else if (!strcmp( optarg, "icf" )) stub_mode = MODE_Oif;
|
||||
else error( "Invalid argument '-O%s'\n", optarg );
|
||||
break;
|
||||
case 'p':
|
||||
do_everything = 0;
|
||||
do_proxies = 1;
|
||||
|
|
|
@ -66,18 +66,27 @@ extern char *regscript_name;
|
|||
extern char *regscript_token;
|
||||
extern const char *prefix_client;
|
||||
extern const char *prefix_server;
|
||||
extern size_t pointer_size;
|
||||
extern unsigned int pointer_size;
|
||||
extern time_t now;
|
||||
|
||||
extern int line_number;
|
||||
extern int char_number;
|
||||
|
||||
enum stub_mode
|
||||
{
|
||||
MODE_Os, /* inline stubs */
|
||||
MODE_Oi, /* old-style interpreted stubs */
|
||||
MODE_Oif /* new-style fully interpreted stubs */
|
||||
};
|
||||
extern enum stub_mode get_stub_mode(void);
|
||||
|
||||
extern void write_header(const statement_list_t *stmts);
|
||||
extern void write_id_data(const statement_list_t *stmts);
|
||||
extern void write_proxies(const statement_list_t *stmts);
|
||||
extern void write_client(const statement_list_t *stmts);
|
||||
extern void write_server(const statement_list_t *stmts);
|
||||
extern void write_regscript(const statement_list_t *stmts);
|
||||
extern void output_typelib_regscript( const typelib_t *typelib );
|
||||
extern void write_local_stubs(const statement_list_t *stmts);
|
||||
extern void write_dlldata(const statement_list_t *stmts);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
|
||||
<module name="widl" type="buildtool" allowwarnings="true">
|
||||
<define name="INT16">SHORT</define>
|
||||
<define name="YYDEBUG">1</define>
|
||||
<include base="wpp">.</include>
|
||||
<library>wpp</library>
|
||||
<file>client.c</file>
|
||||
|
|
|
@ -21,13 +21,6 @@
|
|||
#ifndef __WIDL_WIDLTYPES_H
|
||||
#define __WIDL_WIDLTYPES_H
|
||||
|
||||
#define S_OK 0
|
||||
#define S_FALSE 1
|
||||
#define E_OUTOFMEMORY ((HRESULT)0x8007000EL)
|
||||
#define TYPE_E_IOERROR ((HRESULT)0x80028CA2L)
|
||||
|
||||
#define max(a, b) ((a) > (b) ? a : b)
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include "guiddef.h"
|
||||
|
@ -39,9 +32,7 @@
|
|||
typedef GUID UUID;
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#define FALSE 0
|
||||
|
||||
typedef struct _loc_info_t loc_info_t;
|
||||
|
@ -57,6 +48,7 @@ typedef struct _importinfo_t importinfo_t;
|
|||
typedef struct _typelib_t typelib_t;
|
||||
typedef struct _user_type_t user_type_t;
|
||||
typedef struct _user_type_t context_handle_t;
|
||||
typedef struct _user_type_t generic_handle_t;
|
||||
typedef struct _type_list_t type_list_t;
|
||||
typedef struct _statement_t statement_t;
|
||||
|
||||
|
@ -69,6 +61,7 @@ typedef struct list ifref_list_t;
|
|||
typedef struct list array_dims_t;
|
||||
typedef struct list user_type_list_t;
|
||||
typedef struct list context_handle_list_t;
|
||||
typedef struct list generic_handle_list_t;
|
||||
typedef struct list statement_list_t;
|
||||
|
||||
enum attr_type
|
||||
|
@ -361,6 +354,7 @@ struct array_details
|
|||
unsigned int dim;
|
||||
unsigned char ptr_def_fc;
|
||||
unsigned char declptr; /* if declared as a pointer */
|
||||
unsigned short ptr_tfsoff; /* offset of pointer definition for declptr */
|
||||
};
|
||||
|
||||
struct coclass_details
|
||||
|
@ -500,7 +494,6 @@ struct _importlib_t {
|
|||
|
||||
struct _typelib_t {
|
||||
char *name;
|
||||
char *filename;
|
||||
const attr_list_t *attrs;
|
||||
struct list importlibs;
|
||||
statement_list_t *stmts;
|
||||
|
@ -539,6 +532,8 @@ typedef enum {
|
|||
|
||||
extern syskind_t typelib_kind;
|
||||
extern user_type_list_t user_type_list;
|
||||
extern context_handle_list_t context_handle_list;
|
||||
extern generic_handle_list_t generic_handle_list;
|
||||
void check_for_additional_prototype_types(const var_list_t *list);
|
||||
|
||||
void init_types(void);
|
||||
|
@ -548,8 +543,6 @@ void clear_all_offsets(void);
|
|||
|
||||
int is_ptr(const type_t *t);
|
||||
int is_array(const type_t *t);
|
||||
int is_var_ptr(const var_t *v);
|
||||
int cant_be_null(const var_t *v);
|
||||
|
||||
#define tsENUM 1
|
||||
#define tsSTRUCT 2
|
||||
|
|
|
@ -40,8 +40,10 @@
|
|||
#define NONAMELESSUNION
|
||||
#define NONAMELESSSTRUCT
|
||||
|
||||
#include <typedefs.h>
|
||||
#include <nls.h>
|
||||
#include "winerror.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
|
||||
#include "widl.h"
|
||||
#include "typelib.h"
|
||||
|
@ -82,7 +84,7 @@ typedef struct _msft_typelib_t
|
|||
typelib_t *typelib;
|
||||
MSFT_Header typelib_header;
|
||||
MSFT_pSeg typelib_segdir[MSFT_SEG_MAX];
|
||||
char *typelib_segment_data[MSFT_SEG_MAX];
|
||||
unsigned char *typelib_segment_data[MSFT_SEG_MAX];
|
||||
int typelib_segment_block_length[MSFT_SEG_MAX];
|
||||
|
||||
INT typelib_typeinfo_offsets[0x200]; /* Hope that's enough. */
|
||||
|
@ -397,7 +399,7 @@ static int ctl2_alloc_segment(
|
|||
}
|
||||
|
||||
while ((typelib->typelib_segdir[segment].length + size) > typelib->typelib_segment_block_length[segment]) {
|
||||
char *block;
|
||||
unsigned char *block;
|
||||
|
||||
block_size = typelib->typelib_segment_block_length[segment];
|
||||
block = xrealloc(typelib->typelib_segment_data[segment], block_size << 1);
|
||||
|
@ -407,7 +409,7 @@ static int ctl2_alloc_segment(
|
|||
msft_typeinfo_t *typeinfo;
|
||||
|
||||
for (typeinfo = typelib->typeinfos; typeinfo; typeinfo = typeinfo->next_typeinfo) {
|
||||
typeinfo->typeinfo = (void *)&block[((char *)typeinfo->typeinfo) - typelib->typelib_segment_data[segment]];
|
||||
typeinfo->typeinfo = (void *)&block[((unsigned char *)typeinfo->typeinfo) - typelib->typelib_segment_data[segment]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -568,14 +570,14 @@ static int ctl2_alloc_string(
|
|||
{
|
||||
int length;
|
||||
int offset;
|
||||
char *string_space;
|
||||
unsigned char *string_space;
|
||||
char *encoded_string;
|
||||
|
||||
length = ctl2_encode_string(string, &encoded_string);
|
||||
|
||||
for (offset = 0; offset < typelib->typelib_segdir[MSFT_SEG_STRING].length;
|
||||
offset += ((((typelib->typelib_segment_data[MSFT_SEG_STRING][offset + 1] << 8) & 0xff)
|
||||
| (typelib->typelib_segment_data[MSFT_SEG_STRING][offset + 0] & 0xff)) + 5) & ~3) {
|
||||
offset += (((typelib->typelib_segment_data[MSFT_SEG_STRING][offset + 1] << 8) |
|
||||
typelib->typelib_segment_data[MSFT_SEG_STRING][offset + 0]) + 5) & ~3) {
|
||||
if (!memcmp(encoded_string, typelib->typelib_segment_data[MSFT_SEG_STRING] + offset, length)) return offset;
|
||||
}
|
||||
|
||||
|
@ -651,8 +653,8 @@ static int alloc_importfile(
|
|||
encoded_string[0] |= 1;
|
||||
|
||||
for (offset = 0; offset < typelib->typelib_segdir[MSFT_SEG_IMPORTFILES].length;
|
||||
offset += ((((typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES][offset + 0xd] << 8) & 0xff)
|
||||
| (typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES][offset + 0xc] & 0xff)) >> 2) + 0xc) {
|
||||
offset += (((typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES][offset + 0xd] << 8) |
|
||||
typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES][offset + 0xc]) >> 2) + 0xc) {
|
||||
if (!memcmp(encoded_string, typelib->typelib_segment_data[MSFT_SEG_IMPORTFILES] + offset + 0xc, length)) return offset;
|
||||
}
|
||||
|
||||
|
@ -909,7 +911,7 @@ static int encode_type(
|
|||
|
||||
if (typeoffset == typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length) {
|
||||
int mix_field;
|
||||
|
||||
|
||||
if (target_type & 0x80000000) {
|
||||
mix_field = ((target_type >> 16) & 0x3fff) | VT_BYREF;
|
||||
} else {
|
||||
|
@ -947,7 +949,7 @@ static int encode_type(
|
|||
|
||||
if (typeoffset == typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length) {
|
||||
int mix_field;
|
||||
|
||||
|
||||
if (target_type & 0x80000000) {
|
||||
mix_field = ((target_type >> 16) & VT_TYPEMASK) | VT_ARRAY;
|
||||
} else {
|
||||
|
@ -1129,7 +1131,7 @@ static int encode_var(
|
|||
|
||||
if (typeoffset == typelib->typelib_segdir[MSFT_SEG_TYPEDESC].length) {
|
||||
int mix_field;
|
||||
|
||||
|
||||
if (target_type & 0x80000000) {
|
||||
mix_field = ((target_type >> 16) & 0x3fff) | VT_BYREF;
|
||||
} else {
|
||||
|
@ -1265,7 +1267,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
|
|||
int decoded_size, extra_attr = 0;
|
||||
int num_params = 0, num_optional = 0, num_defaults = 0;
|
||||
var_t *arg;
|
||||
char *namedata;
|
||||
unsigned char *namedata;
|
||||
const attr_t *attr;
|
||||
unsigned int funcflags = 0, callconv = 4 /* CC_STDCALL */;
|
||||
unsigned int funckind, invokekind = 1 /* INVOKE_FUNC */;
|
||||
|
@ -1548,7 +1550,7 @@ static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, var_t *func, int index)
|
|||
}
|
||||
|
||||
/* update the index data */
|
||||
typeinfo->func_indices[typeinfo->typeinfo->cElement & 0xffff] = id;
|
||||
typeinfo->func_indices[typeinfo->typeinfo->cElement & 0xffff] = id;
|
||||
typeinfo->func_offsets[typeinfo->typeinfo->cElement & 0xffff] = offset;
|
||||
typeinfo->func_names[typeinfo->typeinfo->cElement & 0xffff] = name_offset;
|
||||
|
||||
|
@ -1605,11 +1607,11 @@ static HRESULT add_var_desc(msft_typeinfo_t *typeinfo, UINT index, var_t* var)
|
|||
INT *typedata;
|
||||
int var_datawidth;
|
||||
int var_alignment;
|
||||
int var_type_size, var_kind = 0 /* VAR_PERINSTANCE */;
|
||||
int var_type_size, var_kind = 0 /* VAR_PERINSTANCE */;
|
||||
int alignment;
|
||||
int varflags = 0;
|
||||
const attr_t *attr;
|
||||
char *namedata;
|
||||
unsigned char *namedata;
|
||||
int var_num = (typeinfo->typeinfo->cElement >> 16) & 0xffff;
|
||||
|
||||
chat("add_var_desc(%d, %s)\n", index, var->name);
|
||||
|
@ -2540,7 +2542,14 @@ static void save_all_changes(msft_typelib_t *typelib)
|
|||
ctl2_write_segment( typelib, MSFT_SEG_CUSTDATAGUID );
|
||||
|
||||
ctl2_write_typeinfos(typelib);
|
||||
flush_output_buffer( typelib->typelib->filename );
|
||||
|
||||
if (strendswith( typelib_name, ".res" )) /* create a binary resource file */
|
||||
{
|
||||
add_output_to_resources( "TYPELIB", "#1" );
|
||||
output_typelib_regscript( typelib->typelib );
|
||||
flush_output_resources( typelib_name );
|
||||
}
|
||||
else flush_output_buffer( typelib_name );
|
||||
}
|
||||
|
||||
int create_msft_typelib(typelib_t *typelib)
|
||||
|
@ -2551,8 +2560,8 @@ int create_msft_typelib(typelib_t *typelib)
|
|||
time_t cur_time;
|
||||
char *time_override;
|
||||
unsigned int version = 5 << 24 | 1 << 16 | 164; /* 5.01.0164 */
|
||||
GUID midl_time_guid = {0xde77ba63,0x517c,0x11d1,{0xa2,0xda,0x00,0x00,0xf8,0x77,0x3c,0xe9}};
|
||||
GUID midl_version_guid = {0xde77ba64,0x517c,0x11d1,{0xa2,0xda,0x00,0x00,0xf8,0x77,0x3c,0xe9}};
|
||||
GUID midl_time_guid = {0xde77ba63,0x517c,0x11d1,{0xa2,0xda,0x00,0x00,0xf8,0x77,0x3c,0xe9}};
|
||||
GUID midl_version_guid = {0xde77ba64,0x517c,0x11d1,{0xa2,0xda,0x00,0x00,0xf8,0x77,0x3c,0xe9}};
|
||||
|
||||
pointer_size = (typelib_kind == SYS_WIN64) ? 8 : 4;
|
||||
|
||||
|
@ -2594,7 +2603,7 @@ int create_msft_typelib(typelib_t *typelib)
|
|||
set_help_context(msft);
|
||||
set_help_string_dll(msft);
|
||||
set_help_string_context(msft);
|
||||
|
||||
|
||||
/* midl adds two sets of custom data to the library: the current unix time
|
||||
and midl's version number */
|
||||
time_override = getenv( "WIDL_TIME_OVERRIDE");
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -121,6 +121,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
%top{
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
}
|
||||
|
||||
/*
|
||||
* Special flex options and exclusive scanner start-conditions
|
||||
*/
|
||||
|
@ -156,8 +161,6 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
|
|||
ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
|
||||
|
||||
%{
|
||||
#include "config.h"
|
||||
#include "wine/port.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -178,6 +181,7 @@ ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
|
|||
#define YY_NO_UNISTD_H
|
||||
#endif
|
||||
|
||||
#include "wine/wpp.h"
|
||||
#include "wpp_private.h"
|
||||
#include "ppy.tab.h"
|
||||
|
||||
|
@ -205,6 +209,7 @@ ul [uUlL]|[uUlL][lL]|[lL][uU]|[lL][lL][uU]|[uU][lL][lL]|[lL][uU][lL]
|
|||
|
||||
typedef struct bufferstackentry {
|
||||
YY_BUFFER_STATE bufferstate; /* Buffer to switch back to */
|
||||
void *filehandle; /* Handle to be used with wpp_callbacks->read */
|
||||
pp_entry_t *define; /* Points to expanding define or NULL if handling includes */
|
||||
int line_number; /* Line that we were handling */
|
||||
int char_number; /* The current position on that line */
|
||||
|
@ -298,6 +303,56 @@ include_state_t pp_incl_state =
|
|||
|
||||
includelogicentry_t *pp_includelogiclist = NULL;
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
{ \
|
||||
result = wpp_callbacks->read(pp_status.file, buf, max_size); \
|
||||
}
|
||||
|
||||
#define BUFFERINITIALCAPACITY 256
|
||||
|
||||
void pp_writestring(const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int len;
|
||||
static char *buffer;
|
||||
static int buffercapacity;
|
||||
char *new_buffer;
|
||||
|
||||
if(buffercapacity == 0)
|
||||
{
|
||||
buffer = pp_xmalloc(BUFFERINITIALCAPACITY);
|
||||
if(buffer == NULL)
|
||||
return;
|
||||
buffercapacity = BUFFERINITIALCAPACITY;
|
||||
}
|
||||
|
||||
va_start(valist, format);
|
||||
len = vsnprintf(buffer, buffercapacity,
|
||||
format, valist);
|
||||
/* If the string is longer than buffersize, vsnprintf returns
|
||||
* the string length with glibc >= 2.1, -1 with glibc < 2.1 */
|
||||
while(len > buffercapacity || len < 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
buffercapacity *= 2;
|
||||
} while(len > buffercapacity);
|
||||
|
||||
new_buffer = pp_xrealloc(buffer, buffercapacity);
|
||||
if(new_buffer == NULL)
|
||||
{
|
||||
va_end(valist);
|
||||
return;
|
||||
}
|
||||
buffer = new_buffer;
|
||||
len = vsnprintf(buffer, buffercapacity,
|
||||
format, valist);
|
||||
}
|
||||
va_end(valist);
|
||||
|
||||
wpp_callbacks->write(buffer, len);
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
/*
|
||||
|
@ -437,7 +492,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
|
|||
/*
|
||||
* Handle left side of #define
|
||||
*/
|
||||
<pp_def>{cident}\( ppy_lval.cptr = pp_xstrdup(ppy_text); ppy_lval.cptr[ppy_leng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO;
|
||||
<pp_def>{cident}\( ppy_lval.cptr = pp_xstrdup(ppy_text); if(ppy_lval.cptr) ppy_lval.cptr[ppy_leng-1] = '\0'; yy_pp_state(pp_macro); return tMACRO;
|
||||
<pp_def>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); yy_pp_state(pp_define); return tDEFINE;
|
||||
<pp_def>{ws}+ ;
|
||||
<pp_def>\\\r?\n newline(0);
|
||||
|
@ -472,7 +527,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
|
|||
<pp_mbody>{cident} ppy_lval.cptr = pp_xstrdup(ppy_text); return tIDENT;
|
||||
<pp_mbody>\#\# return tCONCAT;
|
||||
<pp_mbody>\# return tSTRINGIZE;
|
||||
<pp_mbody>[0-9][^'"#/\\\n]* ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
|
||||
<pp_mbody>[0-9][a-zA-Z0-9]*[^a-zA-Z0-9'"#/\\\n]* ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
|
||||
<pp_mbody>(\\\r?)|(\/[^/*'"#\\\n]*) ppy_lval.cptr = pp_xstrdup(ppy_text); return tLITERAL;
|
||||
<pp_mbody>\\\r?\n{ws}+ newline(0); ppy_lval.cptr = pp_xstrdup(" "); return tLITERAL;
|
||||
<pp_mbody>\\\r?\n newline(0);
|
||||
|
@ -639,7 +694,7 @@ includelogicentry_t *pp_includelogiclist = NULL;
|
|||
if(yy_current_state() == pp_inc)
|
||||
ppy_error("Expected include filename");
|
||||
|
||||
if(yy_current_state() == pp_if)
|
||||
else if(yy_current_state() == pp_if)
|
||||
{
|
||||
ppy_lval.cptr = pp_xstrdup(ppy_text);
|
||||
return tIDENT;
|
||||
|
@ -808,7 +863,10 @@ static int make_number(int radix, YYSTYPE *val, const char *str, int len)
|
|||
ext[0] = len > 2 ? toupper(str[len-3]) : ' ';
|
||||
|
||||
if(!strcmp(ext, "LUL"))
|
||||
{
|
||||
ppy_error("Invalid constant suffix");
|
||||
return 0;
|
||||
}
|
||||
else if(!strcmp(ext, "LLU") || !strcmp(ext, "ULL"))
|
||||
{
|
||||
is_ll++;
|
||||
|
@ -903,21 +961,25 @@ static int make_number(int radix, YYSTYPE *val, const char *str, int len)
|
|||
*/
|
||||
static void expand_special(pp_entry_t *ppp)
|
||||
{
|
||||
const char *dbgtext = "?";
|
||||
static char *buf = NULL;
|
||||
char *new_buf;
|
||||
|
||||
assert(ppp->type == def_special);
|
||||
|
||||
if(!strcmp(ppp->ident, "__LINE__"))
|
||||
{
|
||||
dbgtext = "def_special(__LINE__)";
|
||||
buf = pp_xrealloc(buf, 32);
|
||||
new_buf = pp_xrealloc(buf, 32);
|
||||
if(!new_buf)
|
||||
return;
|
||||
buf = new_buf;
|
||||
sprintf(buf, "%d", pp_status.line_number);
|
||||
}
|
||||
else if(!strcmp(ppp->ident, "__FILE__"))
|
||||
{
|
||||
dbgtext = "def_special(__FILE__)";
|
||||
buf = pp_xrealloc(buf, strlen(pp_status.input) + 3);
|
||||
new_buf = pp_xrealloc(buf, strlen(pp_status.input) + 3);
|
||||
if(!new_buf)
|
||||
return;
|
||||
buf = new_buf;
|
||||
sprintf(buf, "\"%s\"", pp_status.input);
|
||||
}
|
||||
else
|
||||
|
@ -962,12 +1024,19 @@ static char *curdef_text = NULL;
|
|||
|
||||
static void add_text(const char *str, int len)
|
||||
{
|
||||
int new_alloc;
|
||||
char *new_text;
|
||||
|
||||
if(len == 0)
|
||||
return;
|
||||
if(curdef_idx >= curdef_alloc || curdef_alloc - curdef_idx < len)
|
||||
{
|
||||
curdef_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1);
|
||||
curdef_text = pp_xrealloc(curdef_text, curdef_alloc * sizeof(curdef_text[0]));
|
||||
new_alloc = curdef_alloc + ((len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1));
|
||||
new_text = pp_xrealloc(curdef_text, new_alloc * sizeof(curdef_text[0]));
|
||||
if(!new_text)
|
||||
return;
|
||||
curdef_text = new_text;
|
||||
curdef_alloc = new_alloc;
|
||||
if(curdef_alloc > 65536)
|
||||
ppy_warning("Reallocating macro-expansion buffer larger than 64kB");
|
||||
}
|
||||
|
@ -1085,7 +1154,10 @@ static void expand_macro(macexpstackentry_t *mep)
|
|||
assert(ppp->expanding == 0);
|
||||
|
||||
if((ppp->nargs >= 0 && nargs != ppp->nargs) || (ppp->nargs < 0 && nargs < -ppp->nargs))
|
||||
{
|
||||
ppy_error("Too %s macro arguments (%d)", nargs < abs(ppp->nargs) ? "few" : "many", nargs);
|
||||
return;
|
||||
}
|
||||
|
||||
for(n = 0; n < nargs; n++)
|
||||
nnl += mep->nnls[n];
|
||||
|
@ -1162,12 +1234,19 @@ static void new_string(void)
|
|||
|
||||
static void add_string(const char *str, int len)
|
||||
{
|
||||
int new_alloc;
|
||||
char *new_buffer;
|
||||
|
||||
if(len == 0)
|
||||
return;
|
||||
if(strbuf_idx >= strbuf_alloc || strbuf_alloc - strbuf_idx < len)
|
||||
{
|
||||
strbuf_alloc += (len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1);
|
||||
strbuffer = pp_xrealloc(strbuffer, strbuf_alloc * sizeof(strbuffer[0]));
|
||||
new_alloc = strbuf_alloc + ((len + ALLOCBLOCKSIZE-1) & ~(ALLOCBLOCKSIZE-1));
|
||||
new_buffer = pp_xrealloc(strbuffer, new_alloc * sizeof(strbuffer[0]));
|
||||
if(!new_buffer)
|
||||
return;
|
||||
strbuffer = new_buffer;
|
||||
strbuf_alloc = new_alloc;
|
||||
if(strbuf_alloc > 65536)
|
||||
ppy_warning("Reallocating string buffer larger than 64kB");
|
||||
}
|
||||
|
@ -1178,6 +1257,8 @@ static void add_string(const char *str, int len)
|
|||
static char *get_string(void)
|
||||
{
|
||||
char *str = pp_xmalloc(strbuf_idx + 1);
|
||||
if(!str)
|
||||
return NULL;
|
||||
memcpy(str, strbuffer, strbuf_idx);
|
||||
str[strbuf_idx] = '\0';
|
||||
#ifdef DEBUG
|
||||
|
@ -1214,6 +1295,7 @@ static void push_buffer(pp_entry_t *ppp, char *filename, char *incname, int pop)
|
|||
|
||||
memset(&bufferstack[bufferstackidx], 0, sizeof(bufferstack[0]));
|
||||
bufferstack[bufferstackidx].bufferstate = YY_CURRENT_BUFFER;
|
||||
bufferstack[bufferstackidx].filehandle = pp_status.file;
|
||||
bufferstack[bufferstackidx].define = ppp;
|
||||
bufferstack[bufferstackidx].line_number = pp_status.line_number;
|
||||
bufferstack[bufferstackidx].char_number = pp_status.char_number;
|
||||
|
@ -1253,14 +1335,10 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
bufferstack[bufferstackidx].define->expanding = 0;
|
||||
else
|
||||
{
|
||||
pp_status.line_number = bufferstack[bufferstackidx].line_number;
|
||||
pp_status.char_number = bufferstack[bufferstackidx].char_number;
|
||||
pp_status.input = bufferstack[bufferstackidx].filename;
|
||||
ncontinuations = bufferstack[bufferstackidx].ncontinuations;
|
||||
if(!bufferstack[bufferstackidx].should_pop)
|
||||
{
|
||||
fclose(ppy_in);
|
||||
fprintf(ppy_out, "# %d \"%s\" 2\n", pp_status.line_number, pp_status.input);
|
||||
wpp_callbacks->close(pp_status.file);
|
||||
pp_writestring("# %d \"%s\" 2\n", bufferstack[bufferstackidx].line_number, bufferstack[bufferstackidx].filename);
|
||||
|
||||
/* We have EOF, check the include logic */
|
||||
if(pp_incl_state.state == 2 && !pp_incl_state.seen_junk && pp_incl_state.ppp)
|
||||
|
@ -1269,6 +1347,9 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
if(ppp)
|
||||
{
|
||||
includelogicentry_t *iep = pp_xmalloc(sizeof(includelogicentry_t));
|
||||
if(!iep)
|
||||
return NULL;
|
||||
|
||||
iep->ppp = ppp;
|
||||
ppp->iep = iep;
|
||||
iep->filename = bufferstack[bufferstackidx].include_filename;
|
||||
|
@ -1278,7 +1359,7 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
iep->next->prev = iep;
|
||||
pp_includelogiclist = iep;
|
||||
if(pp_status.debug)
|
||||
fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", pp_status.input, pp_status.line_number, pp_incl_state.ppp, iep->filename);
|
||||
fprintf(stderr, "pop_buffer: %s:%d: includelogic added, include_ppp='%s', file='%s'\n", bufferstack[bufferstackidx].filename, bufferstack[bufferstackidx].line_number, pp_incl_state.ppp, iep->filename);
|
||||
}
|
||||
else
|
||||
free(bufferstack[bufferstackidx].include_filename);
|
||||
|
@ -1287,6 +1368,10 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
pp_incl_state = bufferstack[bufferstackidx].incl;
|
||||
|
||||
}
|
||||
pp_status.line_number = bufferstack[bufferstackidx].line_number;
|
||||
pp_status.char_number = bufferstack[bufferstackidx].char_number;
|
||||
pp_status.input = bufferstack[bufferstackidx].filename;
|
||||
ncontinuations = bufferstack[bufferstackidx].ncontinuations;
|
||||
}
|
||||
|
||||
if(ppy_debug)
|
||||
|
@ -1300,7 +1385,8 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
bufferstack[bufferstackidx].filename,
|
||||
bufferstack[bufferstackidx].should_pop);
|
||||
|
||||
ppy__switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
|
||||
pp_status.file = bufferstack[bufferstackidx].filehandle;
|
||||
ppy__switch_to_buffer(bufferstack[bufferstackidx].bufferstate);
|
||||
|
||||
if(bufferstack[bufferstackidx].should_pop)
|
||||
{
|
||||
|
@ -1323,9 +1409,14 @@ static bufferstackentry_t *pop_buffer(void)
|
|||
static void push_macro(pp_entry_t *ppp)
|
||||
{
|
||||
if(macexpstackidx >= MAXMACEXPSTACK)
|
||||
{
|
||||
ppy_error("Too many nested macros");
|
||||
return;
|
||||
}
|
||||
|
||||
macexpstack[macexpstackidx] = pp_xmalloc(sizeof(macexpstack[0][0]));
|
||||
if(!macexpstack[macexpstackidx])
|
||||
return;
|
||||
memset( macexpstack[macexpstackidx], 0, sizeof(macexpstack[0][0]));
|
||||
macexpstack[macexpstackidx]->ppp = ppp;
|
||||
macexpstackidx++;
|
||||
|
@ -1363,8 +1454,13 @@ static void add_text_to_macro(const char *text, int len)
|
|||
|
||||
if(mep->curargalloc - mep->curargsize <= len+1) /* +1 for '\0' */
|
||||
{
|
||||
mep->curargalloc += (ALLOCBLOCKSIZE > len+1) ? ALLOCBLOCKSIZE : len+1;
|
||||
mep->curarg = pp_xrealloc(mep->curarg, mep->curargalloc * sizeof(mep->curarg[0]));
|
||||
char *new_curarg;
|
||||
int new_alloc = mep->curargalloc + ((ALLOCBLOCKSIZE > len+1) ? ALLOCBLOCKSIZE : len+1);
|
||||
new_curarg = pp_xrealloc(mep->curarg, new_alloc * sizeof(mep->curarg[0]));
|
||||
if(!new_curarg)
|
||||
return;
|
||||
mep->curarg = new_curarg;
|
||||
mep->curargalloc = new_alloc;
|
||||
}
|
||||
memcpy(mep->curarg + mep->curargsize, text, len);
|
||||
mep->curargsize += len;
|
||||
|
@ -1375,14 +1471,30 @@ static void macro_add_arg(int last)
|
|||
{
|
||||
int nnl = 0;
|
||||
char *cptr;
|
||||
char **new_args, **new_ppargs;
|
||||
int *new_nnls;
|
||||
macexpstackentry_t *mep = top_macro();
|
||||
|
||||
assert(mep->ppp->expanding == 0);
|
||||
|
||||
mep->args = pp_xrealloc(mep->args, (mep->nargs+1) * sizeof(mep->args[0]));
|
||||
mep->ppargs = pp_xrealloc(mep->ppargs, (mep->nargs+1) * sizeof(mep->ppargs[0]));
|
||||
mep->nnls = pp_xrealloc(mep->nnls, (mep->nargs+1) * sizeof(mep->nnls[0]));
|
||||
new_args = pp_xrealloc(mep->args, (mep->nargs+1) * sizeof(mep->args[0]));
|
||||
if(!new_args)
|
||||
return;
|
||||
mep->args = new_args;
|
||||
|
||||
new_ppargs = pp_xrealloc(mep->ppargs, (mep->nargs+1) * sizeof(mep->ppargs[0]));
|
||||
if(!new_ppargs)
|
||||
return;
|
||||
mep->ppargs = new_ppargs;
|
||||
|
||||
new_nnls = pp_xrealloc(mep->nnls, (mep->nargs+1) * sizeof(mep->nnls[0]));
|
||||
if(!new_nnls)
|
||||
return;
|
||||
mep->nnls = new_nnls;
|
||||
|
||||
mep->args[mep->nargs] = pp_xstrdup(mep->curarg ? mep->curarg : "");
|
||||
if(!mep->args[mep->nargs])
|
||||
return;
|
||||
cptr = mep->args[mep->nargs]-1;
|
||||
while((cptr = strchr(cptr+1, '\n')))
|
||||
{
|
||||
|
@ -1427,7 +1539,7 @@ static void macro_add_expansion(void)
|
|||
pp_status.input,
|
||||
pp_status.line_number,
|
||||
mep->nargs-1,
|
||||
mep->ppargs[mep->nargs-1]);
|
||||
mep->ppargs[mep->nargs-1] ? mep->ppargs[mep->nargs-1] : "");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1441,7 +1553,7 @@ static void put_buffer(const char *s, int len)
|
|||
if(top_macro())
|
||||
add_text_to_macro(s, len);
|
||||
else
|
||||
fwrite(s, 1, len, ppy_out);
|
||||
wpp_callbacks->write(s, len);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1455,6 +1567,10 @@ void pp_do_include(char *fname, int type)
|
|||
char *newpath;
|
||||
int n;
|
||||
includelogicentry_t *iep;
|
||||
void *fp;
|
||||
|
||||
if(!fname)
|
||||
return;
|
||||
|
||||
for(iep = pp_includelogiclist; iep; iep = iep->next)
|
||||
{
|
||||
|
@ -1472,13 +1588,19 @@ void pp_do_include(char *fname, int type)
|
|||
n = strlen(fname);
|
||||
|
||||
if(n <= 2)
|
||||
{
|
||||
ppy_error("Empty include filename");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Undo the effect of the quotation */
|
||||
fname[n-1] = '\0';
|
||||
|
||||
if((ppy_in = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
|
||||
if((fp = pp_open_include(fname+1, type ? pp_status.input : NULL, &newpath)) == NULL)
|
||||
{
|
||||
ppy_error("Unable to open include file %s", fname+1);
|
||||
return;
|
||||
}
|
||||
|
||||
fname[n-1] = *fname; /* Redo the quotes */
|
||||
push_buffer(NULL, newpath, fname, 0);
|
||||
|
@ -1489,9 +1611,10 @@ void pp_do_include(char *fname, int type)
|
|||
if(pp_status.debug)
|
||||
fprintf(stderr, "pp_do_include: %s:%d: include_state=%d, include_ppp='%s', include_ifdepth=%d\n",
|
||||
pp_status.input, pp_status.line_number, pp_incl_state.state, pp_incl_state.ppp, pp_incl_state.ifdepth);
|
||||
ppy__switch_to_buffer(ppy__create_buffer(ppy_in, YY_BUF_SIZE));
|
||||
pp_status.file = fp;
|
||||
ppy__switch_to_buffer(ppy__create_buffer(NULL, YY_BUF_SIZE));
|
||||
|
||||
fprintf(ppy_out, "# 1 \"%s\" 1%s\n", newpath, type ? "" : " 3");
|
||||
pp_writestring("# 1 \"%s\" 1%s\n", newpath, type ? "" : " 3");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,36 @@
|
|||
/* A Bison parser, made by GNU Bison 2.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
under terms of your choice, so long as that work isn't itself a
|
||||
parser generator using the skeleton or a modified version thereof
|
||||
as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
the parser skeleton itself, you may (at your option) remove this
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
/* As a special exception, when this file is copied by Bison into a
|
||||
Bison output file, you may use that output file without restriction.
|
||||
This special exception was added by the Free Software Foundation
|
||||
in version 1.24 of Bison. */
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
|
@ -74,57 +83,16 @@
|
|||
tLSHIFT = 300
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
#define tRCINCLUDE 258
|
||||
#define tIF 259
|
||||
#define tIFDEF 260
|
||||
#define tIFNDEF 261
|
||||
#define tELSE 262
|
||||
#define tELIF 263
|
||||
#define tENDIF 264
|
||||
#define tDEFINED 265
|
||||
#define tNL 266
|
||||
#define tINCLUDE 267
|
||||
#define tLINE 268
|
||||
#define tGCCLINE 269
|
||||
#define tERROR 270
|
||||
#define tWARNING 271
|
||||
#define tPRAGMA 272
|
||||
#define tPPIDENT 273
|
||||
#define tUNDEF 274
|
||||
#define tMACROEND 275
|
||||
#define tCONCAT 276
|
||||
#define tELIPSIS 277
|
||||
#define tSTRINGIZE 278
|
||||
#define tIDENT 279
|
||||
#define tLITERAL 280
|
||||
#define tMACRO 281
|
||||
#define tDEFINE 282
|
||||
#define tDQSTRING 283
|
||||
#define tSQSTRING 284
|
||||
#define tIQSTRING 285
|
||||
#define tUINT 286
|
||||
#define tSINT 287
|
||||
#define tULONG 288
|
||||
#define tSLONG 289
|
||||
#define tULONGLONG 290
|
||||
#define tSLONGLONG 291
|
||||
#define tRCINCLUDEPATH 292
|
||||
#define tLOGOR 293
|
||||
#define tLOGAND 294
|
||||
#define tNE 295
|
||||
#define tEQ 296
|
||||
#define tGTE 297
|
||||
#define tLTE 298
|
||||
#define tRSHIFT 299
|
||||
#define tLSHIFT 300
|
||||
|
||||
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 126 "ppy.y"
|
||||
typedef union YYSTYPE {
|
||||
|
||||
int sint;
|
||||
unsigned int uint;
|
||||
long slong;
|
||||
|
@ -136,15 +104,17 @@ typedef union YYSTYPE {
|
|||
cval_t cval;
|
||||
marg_t *marg;
|
||||
mtext_t *mtext;
|
||||
|
||||
|
||||
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 112 "ppy.tab.h"
|
||||
} YYSTYPE;
|
||||
/* Line 1447 of yacc.c. */
|
||||
#line 142 "ppy.tab.h"
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE ppy_lval;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -59,9 +59,9 @@
|
|||
if(cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.si = v1.val.si OP v2.val.si; \
|
||||
else if(cv_signed(v1) && !cv_signed(v2)) \
|
||||
r.val.si = v1.val.si OP v2.val.ui; \
|
||||
r.val.si = v1.val.si OP (signed) v2.val.ui; \
|
||||
else if(!cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.ui = v1.val.ui OP v2.val.si; \
|
||||
r.val.si = (signed) v1.val.ui OP v2.val.si; \
|
||||
else \
|
||||
r.val.ui = v1.val.ui OP v2.val.ui;
|
||||
|
||||
|
@ -70,9 +70,9 @@
|
|||
if(cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.sl = v1.val.sl OP v2.val.sl; \
|
||||
else if(cv_signed(v1) && !cv_signed(v2)) \
|
||||
r.val.sl = v1.val.sl OP v2.val.ul; \
|
||||
r.val.sl = v1.val.sl OP (signed long) v2.val.ul; \
|
||||
else if(!cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.ul = v1.val.ul OP v2.val.sl; \
|
||||
r.val.sl = (signed long) v1.val.ul OP v2.val.sl; \
|
||||
else \
|
||||
r.val.ul = v1.val.ul OP v2.val.ul;
|
||||
|
||||
|
@ -81,9 +81,9 @@
|
|||
if(cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.sll = v1.val.sll OP v2.val.sll; \
|
||||
else if(cv_signed(v1) && !cv_signed(v2)) \
|
||||
r.val.sll = v1.val.sll OP v2.val.ull; \
|
||||
r.val.sll = v1.val.sll OP (wrc_sll_t) v2.val.ull; \
|
||||
else if(!cv_signed(v1) && cv_signed(v2)) \
|
||||
r.val.ull = v1.val.ull OP v2.val.sll; \
|
||||
r.val.sll = (wrc_sll_t) v1.val.ull OP v2.val.sll; \
|
||||
else \
|
||||
r.val.ull = v1.val.ull OP v2.val.ull;
|
||||
|
||||
|
@ -224,6 +224,9 @@ preprocessor
|
|||
case if_elsetrue:
|
||||
case if_elsefalse:
|
||||
ppy_error("#elif cannot follow #else");
|
||||
break;
|
||||
case if_error:
|
||||
break;
|
||||
default:
|
||||
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #elif directive", s);
|
||||
}
|
||||
|
@ -247,51 +250,62 @@ preprocessor
|
|||
case if_elsetrue:
|
||||
case if_elsefalse:
|
||||
ppy_error("#else clause already defined");
|
||||
break;
|
||||
case if_error:
|
||||
break;
|
||||
default:
|
||||
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d) in #else directive", s);
|
||||
}
|
||||
}
|
||||
| tENDIF tNL {
|
||||
pp_pop_if();
|
||||
if(pp_incl_state.ifdepth == pp_get_if_depth() && pp_incl_state.state == 1)
|
||||
if(pp_pop_if() != if_error)
|
||||
{
|
||||
pp_incl_state.state = 2;
|
||||
pp_incl_state.seen_junk = 0;
|
||||
if(pp_incl_state.ifdepth == pp_get_if_depth() && pp_incl_state.state == 1)
|
||||
{
|
||||
pp_incl_state.state = 2;
|
||||
pp_incl_state.seen_junk = 0;
|
||||
}
|
||||
else if(pp_incl_state.state != 1)
|
||||
{
|
||||
pp_incl_state.state = -1;
|
||||
}
|
||||
if(pp_status.debug)
|
||||
fprintf(stderr, "tENDIF: %s:%d: include_state=%d, include_ppp='%s', include_ifdepth=%d\n",
|
||||
pp_status.input, pp_status.line_number, pp_incl_state.state, pp_incl_state.ppp, pp_incl_state.ifdepth);
|
||||
}
|
||||
else if(pp_incl_state.state != 1)
|
||||
{
|
||||
pp_incl_state.state = -1;
|
||||
}
|
||||
if(pp_status.debug)
|
||||
fprintf(stderr, "tENDIF: %s:%d: include_state=%d, include_ppp='%s', include_ifdepth=%d\n",
|
||||
pp_status.input, pp_status.line_number, pp_incl_state.state, pp_incl_state.ppp, pp_incl_state.ifdepth);
|
||||
}
|
||||
| tUNDEF tIDENT tNL { pp_del_define($2); free($2); }
|
||||
| tDEFINE opt_text tNL { pp_add_define($1, $2); }
|
||||
| tDEFINE opt_text tNL { pp_add_define($1, $2); free($1); free($2); }
|
||||
| tMACRO res_arg allmargs tMACROEND opt_mtexts tNL {
|
||||
pp_add_macro($1, macro_args, nmacro_args, $5);
|
||||
}
|
||||
| tLINE tSINT tDQSTRING tNL { fprintf(ppy_out, "# %d %s\n", $2 , $3); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tNL { fprintf(ppy_out, "# %d %s\n", $2 , $3); free($3); }
|
||||
| tLINE tSINT tDQSTRING tNL { if($3) pp_writestring("# %d %s\n", $2 , $3); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tNL { if($3) pp_writestring("# %d %s\n", $2 , $3); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tSINT tNL
|
||||
{ fprintf(ppy_out, "# %d %s %d\n", $2, $3, $4); free($3); }
|
||||
{ if($3) pp_writestring("# %d %s %d\n", $2, $3, $4); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tSINT tSINT tNL
|
||||
{ fprintf(ppy_out, "# %d %s %d %d\n", $2 ,$3, $4, $5); free($3); }
|
||||
{ if($3) pp_writestring("# %d %s %d %d\n", $2 ,$3, $4, $5); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tSINT tSINT tSINT tNL
|
||||
{ fprintf(ppy_out, "# %d %s %d %d %d\n", $2 ,$3 ,$4 ,$5, $6); free($3); }
|
||||
{ if($3) pp_writestring("# %d %s %d %d %d\n", $2 ,$3 ,$4 ,$5, $6); free($3); }
|
||||
| tGCCLINE tSINT tDQSTRING tSINT tSINT tSINT tSINT tNL
|
||||
{ fprintf(ppy_out, "# %d %s %d %d %d %d\n", $2 ,$3 ,$4 ,$5, $6, $7); free($3); }
|
||||
{ if($3) pp_writestring("# %d %s %d %d %d %d\n", $2 ,$3 ,$4 ,$5, $6, $7); free($3); }
|
||||
| tGCCLINE tNL /* The null-token */
|
||||
| tERROR opt_text tNL { ppy_error("#error directive: '%s'", $2); free($2); }
|
||||
| tWARNING opt_text tNL { ppy_warning("#warning directive: '%s'", $2); free($2); }
|
||||
| tPRAGMA opt_text tNL { fprintf(ppy_out, "#pragma %s\n", $2 ? $2 : ""); free($2); }
|
||||
| tPRAGMA opt_text tNL { pp_writestring("#pragma %s\n", $2 ? $2 : ""); free($2); }
|
||||
| tPPIDENT opt_text tNL { if(pp_status.pedantic) ppy_warning("#ident ignored (arg: '%s')", $2); free($2); }
|
||||
| tRCINCLUDE tRCINCLUDEPATH {
|
||||
int nl=strlen($2) +3;
|
||||
char *fn=pp_xmalloc(nl);
|
||||
sprintf(fn,"\"%s\"",$2);
|
||||
free($2);
|
||||
pp_do_include(fn,1);
|
||||
if($2)
|
||||
{
|
||||
int nl=strlen($2) +3;
|
||||
char *fn=pp_xmalloc(nl);
|
||||
if(fn)
|
||||
{
|
||||
sprintf(fn,"\"%s\"",$2);
|
||||
pp_do_include(fn,1);
|
||||
}
|
||||
free($2);
|
||||
}
|
||||
}
|
||||
| tRCINCLUDE tDQSTRING {
|
||||
pp_do_include($2,1);
|
||||
|
@ -346,13 +360,14 @@ mtext : tLITERAL { $$ = new_mtext($1, 0, exp_text); }
|
|||
int mat = marg_index($2);
|
||||
if(mat < 0)
|
||||
ppy_error("Stringification identifier must be an argument parameter");
|
||||
$$ = new_mtext(NULL, mat, exp_stringize);
|
||||
else
|
||||
$$ = new_mtext(NULL, mat, exp_stringize);
|
||||
}
|
||||
| tIDENT {
|
||||
int mat = marg_index($1);
|
||||
if(mat >= 0)
|
||||
$$ = new_mtext(NULL, mat, exp_subst);
|
||||
else
|
||||
else if($1)
|
||||
$$ = new_mtext($1, 0, exp_text);
|
||||
}
|
||||
;
|
||||
|
@ -537,6 +552,8 @@ static int boolean(cval_t *v)
|
|||
static marg_t *new_marg(char *str, def_arg_t type)
|
||||
{
|
||||
marg_t *ma = pp_xmalloc(sizeof(marg_t));
|
||||
if(!ma)
|
||||
return NULL;
|
||||
ma->arg = str;
|
||||
ma->type = type;
|
||||
ma->nnl = 0;
|
||||
|
@ -545,16 +562,27 @@ static marg_t *new_marg(char *str, def_arg_t type)
|
|||
|
||||
static marg_t *add_new_marg(char *str, def_arg_t type)
|
||||
{
|
||||
marg_t *ma = new_marg(str, type);
|
||||
marg_t **new_macro_args;
|
||||
marg_t *ma;
|
||||
if(!str)
|
||||
return NULL;
|
||||
new_macro_args = pp_xrealloc(macro_args, (nmacro_args+1) * sizeof(macro_args[0]));
|
||||
if(!new_macro_args)
|
||||
return NULL;
|
||||
macro_args = new_macro_args;
|
||||
ma = new_marg(str, type);
|
||||
if(!ma)
|
||||
return NULL;
|
||||
macro_args[nmacro_args] = ma;
|
||||
nmacro_args++;
|
||||
macro_args = pp_xrealloc(macro_args, nmacro_args * sizeof(macro_args[0]));
|
||||
macro_args[nmacro_args-1] = ma;
|
||||
return ma;
|
||||
}
|
||||
|
||||
static int marg_index(char *id)
|
||||
{
|
||||
int t;
|
||||
if(!id)
|
||||
return -1;
|
||||
for(t = 0; t < nmacro_args; t++)
|
||||
{
|
||||
if(!strcmp(id, macro_args[t]->arg))
|
||||
|
@ -566,6 +594,8 @@ static int marg_index(char *id)
|
|||
static mtext_t *new_mtext(char *str, int idx, def_exp_t type)
|
||||
{
|
||||
mtext_t *mt = pp_xmalloc(sizeof(mtext_t));
|
||||
if(!mt)
|
||||
return NULL;
|
||||
if(str == NULL)
|
||||
mt->subst.argidx = idx;
|
||||
else
|
||||
|
@ -585,7 +615,11 @@ static mtext_t *combine_mtext(mtext_t *tail, mtext_t *mtp)
|
|||
|
||||
if(tail->type == exp_text && mtp->type == exp_text)
|
||||
{
|
||||
tail->subst.text = pp_xrealloc(tail->subst.text, strlen(tail->subst.text)+strlen(mtp->subst.text)+1);
|
||||
char *new_text;
|
||||
new_text = pp_xrealloc(tail->subst.text, strlen(tail->subst.text)+strlen(mtp->subst.text)+1);
|
||||
if(!new_text)
|
||||
return mtp;
|
||||
tail->subst.text = new_text;
|
||||
strcat(tail->subst.text, mtp->subst.text);
|
||||
free(mtp->subst.text);
|
||||
free(mtp);
|
||||
|
@ -649,9 +683,22 @@ static mtext_t *combine_mtext(mtext_t *tail, mtext_t *mtp)
|
|||
|
||||
static char *merge_text(char *s1, char *s2)
|
||||
{
|
||||
int l1 = strlen(s1);
|
||||
int l2 = strlen(s2);
|
||||
s1 = pp_xrealloc(s1, l1+l2+1);
|
||||
int l1;
|
||||
int l2;
|
||||
char *snew;
|
||||
if(!s1)
|
||||
return s2;
|
||||
if(!s2)
|
||||
return s1;
|
||||
l1 = strlen(s1);
|
||||
l2 = strlen(s2);
|
||||
snew = pp_xrealloc(s1, l1+l2+1);
|
||||
if(!snew)
|
||||
{
|
||||
free(s2);
|
||||
return s1;
|
||||
}
|
||||
s1 = snew;
|
||||
memcpy(s1+l1, s2, l2+1);
|
||||
free(s2);
|
||||
return s1;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "wine/port.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -81,8 +82,8 @@ void *pp_xmalloc(size_t size)
|
|||
res = malloc(size);
|
||||
if(res == NULL)
|
||||
{
|
||||
fprintf(stderr, "Virtual memory exhausted.\n");
|
||||
exit(2);
|
||||
/* Set the error flag */
|
||||
pp_status.state = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -95,8 +96,8 @@ void *pp_xrealloc(void *p, size_t size)
|
|||
res = realloc(p, size);
|
||||
if(res == NULL)
|
||||
{
|
||||
fprintf(stderr, "Virtual memory exhausted.\n");
|
||||
exit(2);
|
||||
/* Set the error flag */
|
||||
pp_status.state = 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -109,9 +110,105 @@ char *pp_xstrdup(const char *str)
|
|||
assert(str != NULL);
|
||||
len = strlen(str)+1;
|
||||
s = pp_xmalloc(len);
|
||||
if(!s)
|
||||
return NULL;
|
||||
return memcpy(s, str, len);
|
||||
}
|
||||
|
||||
static char *wpp_default_lookup(const char *name, const char *parent_name,
|
||||
char **include_path, int include_path_count)
|
||||
{
|
||||
char *cpy;
|
||||
char *cptr;
|
||||
char *path;
|
||||
const char *ccptr;
|
||||
int i, fd;
|
||||
|
||||
cpy = pp_xmalloc(strlen(name)+1);
|
||||
if(!cpy)
|
||||
return NULL;
|
||||
cptr = cpy;
|
||||
|
||||
for(ccptr = name; *ccptr; ccptr++)
|
||||
{
|
||||
/* Convert to forward slash */
|
||||
if(*ccptr == '\\') {
|
||||
/* kill double backslash */
|
||||
if(ccptr[1] == '\\')
|
||||
ccptr++;
|
||||
*cptr = '/';
|
||||
}else {
|
||||
*cptr = *ccptr;
|
||||
}
|
||||
cptr++;
|
||||
}
|
||||
*cptr = '\0';
|
||||
|
||||
if(parent_name)
|
||||
{
|
||||
/* Search directory of parent include and then -I path */
|
||||
const char *p;
|
||||
|
||||
if ((p = strrchr( parent_name, '/' ))) p++;
|
||||
else p = parent_name;
|
||||
path = pp_xmalloc( (p - parent_name) + strlen(cpy) + 1 );
|
||||
if(!path)
|
||||
{
|
||||
free(cpy);
|
||||
return NULL;
|
||||
}
|
||||
memcpy( path, parent_name, p - parent_name );
|
||||
strcpy( path + (p - parent_name), cpy );
|
||||
fd = open( path, O_RDONLY );
|
||||
if (fd != -1)
|
||||
{
|
||||
close( fd );
|
||||
free( cpy );
|
||||
return path;
|
||||
}
|
||||
free( path );
|
||||
}
|
||||
/* Search -I path */
|
||||
for(i = 0; i < include_path_count; i++)
|
||||
{
|
||||
path = pp_xmalloc(strlen(include_path[i]) + strlen(cpy) + 2);
|
||||
if(!path)
|
||||
{
|
||||
free(cpy);
|
||||
return NULL;
|
||||
}
|
||||
strcpy(path, include_path[i]);
|
||||
strcat(path, "/");
|
||||
strcat(path, cpy);
|
||||
fd = open( path, O_RDONLY );
|
||||
if (fd != -1)
|
||||
{
|
||||
close( fd );
|
||||
free( cpy );
|
||||
return path;
|
||||
}
|
||||
free( path );
|
||||
}
|
||||
free( cpy );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void *wpp_default_open(const char *filename, int type) {
|
||||
return fopen(filename,"rt");
|
||||
}
|
||||
|
||||
static void wpp_default_close(void *file) {
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
static int wpp_default_read(void *file, char *buffer, unsigned int len){
|
||||
return fread(buffer, 1, len, file);
|
||||
}
|
||||
|
||||
static void wpp_default_write( const char *buffer, unsigned int len ) {
|
||||
fwrite(buffer, 1, len, ppy_out);
|
||||
}
|
||||
|
||||
/* Don't comment on the hash, its primitive but functional... */
|
||||
static int pphash(const char *str)
|
||||
{
|
||||
|
@ -123,9 +220,12 @@ static int pphash(const char *str)
|
|||
|
||||
pp_entry_t *pplookup(const char *ident)
|
||||
{
|
||||
int idx = pphash(ident);
|
||||
int idx;
|
||||
pp_entry_t *ppp;
|
||||
|
||||
if(!ident)
|
||||
return NULL;
|
||||
idx = pphash(ident);
|
||||
for(ppp = pp_def_state->defines[idx]; ppp; ppp = ppp->next)
|
||||
{
|
||||
if(!strcmp(ident, ppp->ident))
|
||||
|
@ -171,13 +271,16 @@ static void free_pp_entry( pp_entry_t *ppp, int idx )
|
|||
}
|
||||
|
||||
/* push a new (empty) define state */
|
||||
void pp_push_define_state(void)
|
||||
int pp_push_define_state(void)
|
||||
{
|
||||
pp_def_state_t *state = pp_xmalloc( sizeof(*state) );
|
||||
if(!state)
|
||||
return 1;
|
||||
|
||||
memset( state->defines, 0, sizeof(state->defines) );
|
||||
state->next = pp_def_state;
|
||||
pp_def_state = state;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* pop the current define state */
|
||||
|
@ -207,19 +310,25 @@ void pp_del_define(const char *name)
|
|||
return;
|
||||
}
|
||||
|
||||
free( ppp->ident );
|
||||
free( ppp->subst.text );
|
||||
free( ppp->filename );
|
||||
free_pp_entry( ppp, pphash(name) );
|
||||
|
||||
if(pp_status.debug)
|
||||
printf("Deleted (%s, %d) <%s>\n", pp_status.input, pp_status.line_number, name);
|
||||
}
|
||||
|
||||
pp_entry_t *pp_add_define(char *def, char *text)
|
||||
pp_entry_t *pp_add_define(const char *def, const char *text)
|
||||
{
|
||||
int len;
|
||||
char *cptr;
|
||||
int idx = pphash(def);
|
||||
int idx;
|
||||
pp_entry_t *ppp;
|
||||
|
||||
if(!def)
|
||||
return NULL;
|
||||
idx = pphash(def);
|
||||
if((ppp = pplookup(def)) != NULL)
|
||||
{
|
||||
if(pp_status.pedantic)
|
||||
|
@ -227,41 +336,58 @@ pp_entry_t *pp_add_define(char *def, char *text)
|
|||
pp_del_define(def);
|
||||
}
|
||||
ppp = pp_xmalloc(sizeof(pp_entry_t));
|
||||
if(!ppp)
|
||||
return NULL;
|
||||
memset( ppp, 0, sizeof(*ppp) );
|
||||
ppp->ident = def;
|
||||
ppp->ident = pp_xstrdup(def);
|
||||
if(!ppp->ident)
|
||||
goto error;
|
||||
ppp->type = def_define;
|
||||
ppp->subst.text = text;
|
||||
ppp->subst.text = text ? pp_xstrdup(text) : NULL;
|
||||
if(text && !ppp->subst.text)
|
||||
goto error;
|
||||
ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
|
||||
if(!ppp->filename)
|
||||
goto error;
|
||||
ppp->linenumber = pp_status.input ? pp_status.line_number : 0;
|
||||
ppp->next = pp_def_state->defines[idx];
|
||||
pp_def_state->defines[idx] = ppp;
|
||||
if(ppp->next)
|
||||
ppp->next->prev = ppp;
|
||||
if(text)
|
||||
if(ppp->subst.text)
|
||||
{
|
||||
/* Strip trailing white space from subst text */
|
||||
len = strlen(text);
|
||||
while(len && strchr(" \t\r\n", text[len-1]))
|
||||
len = strlen(ppp->subst.text);
|
||||
while(len && strchr(" \t\r\n", ppp->subst.text[len-1]))
|
||||
{
|
||||
text[--len] = '\0';
|
||||
ppp->subst.text[--len] = '\0';
|
||||
}
|
||||
/* Strip leading white space from subst text */
|
||||
for(cptr = text; *cptr && strchr(" \t\r", *cptr); cptr++)
|
||||
for(cptr = ppp->subst.text; *cptr && strchr(" \t\r", *cptr); cptr++)
|
||||
;
|
||||
if(text != cptr)
|
||||
memmove(text, cptr, strlen(cptr)+1);
|
||||
if(ppp->subst.text != cptr)
|
||||
memmove(ppp->subst.text, cptr, strlen(cptr)+1);
|
||||
}
|
||||
if(pp_status.debug)
|
||||
printf("Added define (%s, %d) <%s> to <%s>\n", pp_status.input, pp_status.line_number, ppp->ident, text ? text : "(null)");
|
||||
printf("Added define (%s, %d) <%s> to <%s>\n", pp_status.input, pp_status.line_number, ppp->ident, ppp->subst.text ? ppp->subst.text : "(null)");
|
||||
|
||||
return ppp;
|
||||
|
||||
error:
|
||||
free(ppp->ident);
|
||||
free(ppp->subst.text);
|
||||
free(ppp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
|
||||
{
|
||||
int idx = pphash(id);
|
||||
int idx;
|
||||
pp_entry_t *ppp;
|
||||
|
||||
if(!id)
|
||||
return NULL;
|
||||
idx = pphash(id);
|
||||
if((ppp = pplookup(id)) != NULL)
|
||||
{
|
||||
if(pp_status.pedantic)
|
||||
|
@ -269,6 +395,8 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
|
|||
pp_del_define(id);
|
||||
}
|
||||
ppp = pp_xmalloc(sizeof(pp_entry_t));
|
||||
if(!ppp)
|
||||
return NULL;
|
||||
memset( ppp, 0, sizeof(*ppp) );
|
||||
ppp->ident = id;
|
||||
ppp->type = def_macro;
|
||||
|
@ -276,6 +404,11 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
|
|||
ppp->nargs = nargs;
|
||||
ppp->subst.mtext= exp;
|
||||
ppp->filename = pp_xstrdup(pp_status.input ? pp_status.input : "<internal or cmdline>");
|
||||
if(!ppp->filename)
|
||||
{
|
||||
free(ppp);
|
||||
return NULL;
|
||||
}
|
||||
ppp->linenumber = pp_status.input ? pp_status.line_number : 0;
|
||||
ppp->next = pp_def_state->defines[idx];
|
||||
pp_def_state->defines[idx] = ppp;
|
||||
|
@ -323,19 +456,12 @@ pp_entry_t *pp_add_macro(char *id, marg_t *args[], int nargs, mtext_t *exp)
|
|||
static char **includepath;
|
||||
static int nincludepath = 0;
|
||||
|
||||
void wpp_add_include_path(const char *path)
|
||||
int wpp_add_include_path(const char *path)
|
||||
{
|
||||
char *tok;
|
||||
char *cpy = pp_xstrdup(path);
|
||||
|
||||
/* check for absolute windows paths */
|
||||
if (strchr(cpy, ':') != NULL)
|
||||
{
|
||||
nincludepath++;
|
||||
includepath = pp_xrealloc(includepath, nincludepath * sizeof(*includepath));
|
||||
includepath[nincludepath-1] = cpy;
|
||||
return;
|
||||
}
|
||||
if(!cpy)
|
||||
return 1;
|
||||
|
||||
tok = strtok(cpy, INCLUDESEPARATOR);
|
||||
while(tok)
|
||||
|
@ -343,7 +469,14 @@ void wpp_add_include_path(const char *path)
|
|||
if(*tok) {
|
||||
char *dir;
|
||||
char *cptr;
|
||||
char **new_path;
|
||||
|
||||
dir = pp_xstrdup(tok);
|
||||
if(!dir)
|
||||
{
|
||||
free(cpy);
|
||||
return 1;
|
||||
}
|
||||
for(cptr = dir; *cptr; cptr++)
|
||||
{
|
||||
/* Convert to forward slash */
|
||||
|
@ -355,87 +488,36 @@ void wpp_add_include_path(const char *path)
|
|||
*cptr = '\0';
|
||||
|
||||
/* Add to list */
|
||||
new_path = pp_xrealloc(includepath, (nincludepath+1) * sizeof(*includepath));
|
||||
if(!new_path)
|
||||
{
|
||||
free(dir);
|
||||
free(cpy);
|
||||
return 1;
|
||||
}
|
||||
includepath = new_path;
|
||||
includepath[nincludepath] = dir;
|
||||
nincludepath++;
|
||||
includepath = pp_xrealloc(includepath, nincludepath * sizeof(*includepath));
|
||||
includepath[nincludepath-1] = dir;
|
||||
}
|
||||
tok = strtok(NULL, INCLUDESEPARATOR);
|
||||
}
|
||||
free(cpy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *wpp_find_include(const char *name, const char *parent_name)
|
||||
{
|
||||
char *cpy;
|
||||
char *cptr;
|
||||
char *path;
|
||||
const char *ccptr;
|
||||
int i, fd;
|
||||
|
||||
cpy = pp_xmalloc(strlen(name)+1);
|
||||
cptr = cpy;
|
||||
|
||||
for(ccptr = name; *ccptr; ccptr++)
|
||||
{
|
||||
/* Convert to forward slash */
|
||||
if(*ccptr == '\\') {
|
||||
/* kill double backslash */
|
||||
if(ccptr[1] == '\\')
|
||||
ccptr++;
|
||||
*cptr = '/';
|
||||
}else {
|
||||
*cptr = *ccptr;
|
||||
}
|
||||
cptr++;
|
||||
}
|
||||
*cptr = '\0';
|
||||
|
||||
if(parent_name)
|
||||
{
|
||||
/* Search directory of parent include and then -I path */
|
||||
const char *p;
|
||||
|
||||
if ((p = strrchr( parent_name, '/' ))) p++;
|
||||
else p = parent_name;
|
||||
path = pp_xmalloc( (p - parent_name) + strlen(cpy) + 1 );
|
||||
memcpy( path, parent_name, p - parent_name );
|
||||
strcpy( path + (p - parent_name), cpy );
|
||||
fd = open( path, O_RDONLY );
|
||||
if (fd != -1)
|
||||
{
|
||||
close( fd );
|
||||
free( cpy );
|
||||
return path;
|
||||
}
|
||||
free( path );
|
||||
}
|
||||
/* Search -I path */
|
||||
for(i = 0; i < nincludepath; i++)
|
||||
{
|
||||
path = pp_xmalloc(strlen(includepath[i]) + strlen(cpy) + 2);
|
||||
strcpy(path, includepath[i]);
|
||||
strcat(path, "/");
|
||||
strcat(path, cpy);
|
||||
fd = open( path, O_RDONLY );
|
||||
if (fd != -1)
|
||||
{
|
||||
close( fd );
|
||||
free( cpy );
|
||||
return path;
|
||||
}
|
||||
free( path );
|
||||
}
|
||||
free( cpy );
|
||||
return NULL;
|
||||
return wpp_default_lookup(name, parent_name, includepath, nincludepath);
|
||||
}
|
||||
|
||||
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath)
|
||||
void *pp_open_include(const char *name, const char *parent_name, char **newpath)
|
||||
{
|
||||
char *path;
|
||||
FILE *fp;
|
||||
void *fp;
|
||||
|
||||
if (!(path = wpp_find_include( name, parent_name ))) return NULL;
|
||||
fp = fopen(path, "rt");
|
||||
if (!(path = wpp_callbacks->lookup(name, parent_name, includepath,
|
||||
nincludepath))) return NULL;
|
||||
fp = wpp_callbacks->open(path, parent_name == NULL ? 1 : 0);
|
||||
|
||||
if (fp)
|
||||
{
|
||||
|
@ -527,13 +609,18 @@ void pp_push_if(pp_if_state_t s)
|
|||
case if_ignore:
|
||||
pp_push_ignore_state();
|
||||
break;
|
||||
default:
|
||||
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
|
||||
}
|
||||
}
|
||||
|
||||
pp_if_state_t pp_pop_if(void)
|
||||
{
|
||||
if(if_stack_idx <= 0)
|
||||
{
|
||||
ppy_error("#{endif,else,elif} without #{if,ifdef,ifndef} (#if-stack underflow)");
|
||||
return if_error;
|
||||
}
|
||||
|
||||
switch(pp_if_state())
|
||||
{
|
||||
|
@ -546,6 +633,8 @@ pp_if_state_t pp_pop_if(void)
|
|||
case if_ignore:
|
||||
pp_pop_ignore_state();
|
||||
break;
|
||||
default:
|
||||
pp_internal_error(__FILE__, __LINE__, "Invalid pp_if_state (%d)", (int)pp_if_state());
|
||||
}
|
||||
|
||||
if(pp_flex_debug)
|
||||
|
@ -606,22 +695,49 @@ static void generic_msg(const char *s, const char *t, const char *n, va_list ap)
|
|||
if(n)
|
||||
{
|
||||
cpy = pp_xstrdup(n);
|
||||
if(!cpy)
|
||||
goto end;
|
||||
for (p = cpy; *p; p++) if(!isprint(*p)) *p = ' ';
|
||||
fprintf(stderr, " near '%s'", cpy);
|
||||
free(cpy);
|
||||
}
|
||||
}
|
||||
end:
|
||||
#endif
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void wpp_default_error(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
|
||||
{
|
||||
generic_msg(msg, "Error", near, ap);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void wpp_default_warning(const char *file, int line, int col, const char *near, const char *msg, va_list ap)
|
||||
{
|
||||
generic_msg(msg, "Warning", near, ap);
|
||||
}
|
||||
|
||||
static const struct wpp_callbacks default_callbacks =
|
||||
{
|
||||
wpp_default_lookup,
|
||||
wpp_default_open,
|
||||
wpp_default_close,
|
||||
wpp_default_read,
|
||||
wpp_default_write,
|
||||
wpp_default_error,
|
||||
wpp_default_warning,
|
||||
};
|
||||
|
||||
struct wpp_callbacks *wpp_callbacks = &default_callbacks;
|
||||
|
||||
int ppy_error(const char *s, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(s, "Error", ppy_text, ap);
|
||||
wpp_callbacks->error(pp_status.input, pp_status.line_number, pp_status.char_number, ppy_text, s, ap);
|
||||
va_end(ap);
|
||||
exit(1);
|
||||
pp_status.state = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -629,7 +745,7 @@ int ppy_warning(const char *s, ...)
|
|||
{
|
||||
va_list ap;
|
||||
va_start(ap, s);
|
||||
generic_msg(s, "Warning", ppy_text, ap);
|
||||
wpp_callbacks->warning(pp_status.input, pp_status.line_number, pp_status.char_number, ppy_text, s, ap);
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ static void add_cmdline_defines(void)
|
|||
|
||||
for (def = cmdline_defines; def; def = def->next)
|
||||
{
|
||||
if (def->value) pp_add_define( pp_xstrdup(def->name), pp_xstrdup(def->value) );
|
||||
if (def->value) pp_add_define( def->name, def->value );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,21 +56,23 @@ static void add_special_defines(void)
|
|||
char buf[32];
|
||||
|
||||
strftime(buf, sizeof(buf), "\"%b %d %Y\"", localtime(&now));
|
||||
pp_add_define( pp_xstrdup("__DATE__"), pp_xstrdup(buf) );
|
||||
pp_add_define( "__DATE__", buf );
|
||||
|
||||
strftime(buf, sizeof(buf), "\"%H:%M:%S\"", localtime(&now));
|
||||
pp_add_define( pp_xstrdup("__TIME__"), pp_xstrdup(buf) );
|
||||
pp_add_define( "__TIME__", buf );
|
||||
|
||||
ppp = pp_add_define( pp_xstrdup("__FILE__"), pp_xstrdup("") );
|
||||
ppp->type = def_special;
|
||||
ppp = pp_add_define( "__FILE__", "" );
|
||||
if(ppp)
|
||||
ppp->type = def_special;
|
||||
|
||||
ppp = pp_add_define( pp_xstrdup("__LINE__"), pp_xstrdup("") );
|
||||
ppp->type = def_special;
|
||||
ppp = pp_add_define( "__LINE__", "" );
|
||||
if(ppp)
|
||||
ppp->type = def_special;
|
||||
}
|
||||
|
||||
|
||||
/* add a define to the preprocessor list */
|
||||
void wpp_add_define( const char *name, const char *value )
|
||||
int wpp_add_define( const char *name, const char *value )
|
||||
{
|
||||
struct define *def;
|
||||
|
||||
|
@ -80,17 +82,35 @@ void wpp_add_define( const char *name, const char *value )
|
|||
{
|
||||
if (!strcmp( def->name, name ))
|
||||
{
|
||||
char *new_value = pp_xstrdup(value);
|
||||
if(!new_value)
|
||||
return 1;
|
||||
free( def->value );
|
||||
def->value = pp_xstrdup(value);
|
||||
return;
|
||||
def->value = new_value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
def = pp_xmalloc( sizeof(*def) );
|
||||
if(!def)
|
||||
return 1;
|
||||
def->next = cmdline_defines;
|
||||
def->name = pp_xstrdup(name);
|
||||
if(!def->name)
|
||||
{
|
||||
free(def);
|
||||
return 1;
|
||||
}
|
||||
def->value = pp_xstrdup(value);
|
||||
if(!def->value)
|
||||
{
|
||||
free(def->name);
|
||||
free(def);
|
||||
return 1;
|
||||
}
|
||||
cmdline_defines = def;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,13 +132,17 @@ void wpp_del_define( const char *name )
|
|||
|
||||
|
||||
/* add a command-line define of the form NAME=VALUE */
|
||||
void wpp_add_cmdline_define( const char *value )
|
||||
int wpp_add_cmdline_define( const char *value )
|
||||
{
|
||||
char *p;
|
||||
char *str = pp_xstrdup(value);
|
||||
char *p = strchr( str, '=' );
|
||||
if(!str)
|
||||
return 1;
|
||||
p = strchr( str, '=' );
|
||||
if (p) *p++ = 0;
|
||||
wpp_add_define( str, p );
|
||||
free( str );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -144,58 +168,42 @@ int wpp_parse( const char *input, FILE *output )
|
|||
int ret;
|
||||
|
||||
pp_status.input = NULL;
|
||||
pp_status.line_number = 1;
|
||||
pp_status.char_number = 1;
|
||||
pp_status.state = 0;
|
||||
|
||||
pp_push_define_state();
|
||||
ret = pp_push_define_state();
|
||||
if(ret)
|
||||
return ret;
|
||||
add_cmdline_defines();
|
||||
add_special_defines();
|
||||
|
||||
if (!input) ppy_in = stdin;
|
||||
else if (!(ppy_in = fopen(input, "rt")))
|
||||
if (!input) pp_status.file = stdin;
|
||||
else if (!(pp_status.file = wpp_callbacks->open(input, 1)))
|
||||
{
|
||||
fprintf(stderr,"Could not open %s\n", input);
|
||||
exit(2);
|
||||
ppy_error("Could not open %s\n", input);
|
||||
pp_pop_define_state();
|
||||
return 2;
|
||||
}
|
||||
|
||||
pp_status.input = input;
|
||||
|
||||
ppy_out = output;
|
||||
fprintf(ppy_out, "# 1 \"%s\" 1\n", input ? input : "");
|
||||
pp_writestring("# 1 \"%s\" 1\n", input ? input : "");
|
||||
|
||||
ret = ppy_parse();
|
||||
/* If there were errors during processing, return an error code */
|
||||
if (!ret && pp_status.state) ret = pp_status.state;
|
||||
|
||||
if (input) fclose(ppy_in);
|
||||
if (input) wpp_callbacks->close(pp_status.file);
|
||||
/* Clean if_stack, it could remain dirty on errors */
|
||||
while (pp_get_if_depth()) pp_pop_if();
|
||||
pp_pop_define_state();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/* parse into a temporary file */
|
||||
int wpp_parse_temp( const char *input, const char *output_base, char **output_name )
|
||||
void wpp_set_callbacks( const struct wpp_callbacks *callbacks )
|
||||
{
|
||||
FILE *output;
|
||||
int ret, fd;
|
||||
char *temp_name;
|
||||
|
||||
if (!output_base || !output_base[0]) output_base = "wpptmp";
|
||||
|
||||
temp_name = pp_xmalloc( strlen(output_base) + 8 );
|
||||
strcpy( temp_name, output_base );
|
||||
strcat( temp_name, ".XXXXXX" );
|
||||
|
||||
if((fd = mkstemps( temp_name, 0 )) == -1)
|
||||
{
|
||||
fprintf(stderr, "Could not generate a temp name from %s\n", temp_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (!(output = fdopen(fd, "wt")))
|
||||
{
|
||||
fprintf(stderr,"Could not open fd %s for writing\n", temp_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
*output_name = temp_name;
|
||||
ret = wpp_parse( input, output );
|
||||
fclose( output );
|
||||
return ret;
|
||||
wpp_callbacks = callbacks;
|
||||
}
|
||||
|
|
|
@ -113,7 +113,8 @@ typedef enum {
|
|||
if_elif,
|
||||
if_elsefalse,
|
||||
if_elsetrue,
|
||||
if_ignore
|
||||
if_ignore,
|
||||
if_error
|
||||
} pp_if_state_t;
|
||||
|
||||
|
||||
|
@ -201,12 +202,12 @@ void *pp_xmalloc(size_t);
|
|||
void *pp_xrealloc(void *, size_t);
|
||||
char *pp_xstrdup(const char *str);
|
||||
pp_entry_t *pplookup(const char *ident);
|
||||
void pp_push_define_state(void);
|
||||
int pp_push_define_state(void);
|
||||
void pp_pop_define_state(void);
|
||||
pp_entry_t *pp_add_define(char *def, char *text);
|
||||
pp_entry_t *pp_add_define(const char *def, const char *text);
|
||||
pp_entry_t *pp_add_macro(char *ident, marg_t *args[], int nargs, mtext_t *exp);
|
||||
void pp_del_define(const char *name);
|
||||
FILE *pp_open_include(const char *name, const char *parent_name, char **newpath);
|
||||
void *pp_open_include(const char *name, const char *parent_name, char **newpath);
|
||||
void pp_push_if(pp_if_state_t s);
|
||||
void pp_next_if_state(int);
|
||||
pp_if_state_t pp_pop_if(void);
|
||||
|
@ -217,6 +218,8 @@ int pp_get_if_depth(void);
|
|||
#define __attribute__(x) /*nothing*/
|
||||
#endif
|
||||
|
||||
extern struct wpp_callbacks *wpp_callbacks;
|
||||
|
||||
int ppy_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
int ppy_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
void pp_internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
|
||||
|
@ -226,8 +229,10 @@ void pp_internal_error(const char *file, int line, const char *s, ...) __attribu
|
|||
struct pp_status
|
||||
{
|
||||
const char *input; /* current input file name */
|
||||
void *file; /* current input file descriptor */
|
||||
int line_number; /* current line number */
|
||||
int char_number; /* current char number in line */
|
||||
int state; /* current error state */
|
||||
int pedantic; /* pedantic option */
|
||||
int debug; /* debug messages flag */
|
||||
};
|
||||
|
@ -249,6 +254,7 @@ void pp_do_include(char *fname, int type);
|
|||
void pp_push_ignore_state(void);
|
||||
void pp_pop_ignore_state(void);
|
||||
|
||||
void pp_writestring(const char *format, ...) __attribute__((format (printf, 1, 2)));
|
||||
|
||||
/*
|
||||
* From ppy.y
|
||||
|
|
|
@ -3,6 +3,7 @@ list(APPEND SOURCE
|
|||
dumpres.c
|
||||
genres.c
|
||||
newstruc.c
|
||||
po.c
|
||||
readres.c
|
||||
translation.c
|
||||
utils.c
|
||||
|
|
|
@ -44,12 +44,10 @@ const char *get_typename(const resource_t* r)
|
|||
case res_cur: return "CURSOR";
|
||||
case res_curg: return "GROUP_CURSOR";
|
||||
case res_dlg: return "DIALOG";
|
||||
case res_dlgex: return "DIALOGEX";
|
||||
case res_fnt: return "FONT";
|
||||
case res_ico: return "ICON";
|
||||
case res_icog: return "GROUP_ICON";
|
||||
case res_men: return "MENU";
|
||||
case res_menex: return "MENUEX";
|
||||
case res_rdt: return "RCDATA";
|
||||
case res_stt: return "STRINGTABLE";
|
||||
case res_usr: return "UserResource";
|
||||
|
@ -605,61 +603,10 @@ static void dump_dialog(const dialog_t *dlg)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dump_dialogex
|
||||
* Syntax : void dump_dialogex(const dialogex_t *dlgex)
|
||||
* Input :
|
||||
* dlgex - DialogEx resource descriptor
|
||||
* Output :
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static void dump_dialogex(const dialogex_t *dlgex)
|
||||
{
|
||||
const control_t *c = dlgex->controls;
|
||||
|
||||
dump_memopt(dlgex->memopt);
|
||||
dump_lvc(&(dlgex->lvc));
|
||||
printf("x, y, w, h: %d, %d, %d, %d\n", dlgex->x, dlgex->y, dlgex->width, dlgex->height);
|
||||
if(dlgex->gotstyle)
|
||||
{
|
||||
assert(dlgex->style != NULL);
|
||||
assert(dlgex->style->and_mask == 0);
|
||||
printf("Style: %08x\n", dlgex->style->or_mask);
|
||||
}
|
||||
if(dlgex->gotexstyle)
|
||||
{
|
||||
assert(dlgex->exstyle != NULL);
|
||||
assert(dlgex->exstyle->and_mask == 0);
|
||||
printf("ExStyle: %08x\n", dlgex->exstyle->or_mask);
|
||||
}
|
||||
if(dlgex->gothelpid)
|
||||
printf("Helpid: %d\n", dlgex->helpid);
|
||||
printf("Menu: %s\n", get_nameid_str(dlgex->menu));
|
||||
printf("Class: %s\n", get_nameid_str(dlgex->dlgclass));
|
||||
printf("Title: "); print_string(dlgex->title); printf("\n");
|
||||
printf("Font: ");
|
||||
if(!dlgex->font)
|
||||
printf("<none>\n");
|
||||
else
|
||||
{
|
||||
printf("%d, ", dlgex->font->size);
|
||||
print_string(dlgex->font->name);
|
||||
printf(", %d, %d\n", dlgex->font->weight, dlgex->font->italic);
|
||||
}
|
||||
while(c)
|
||||
{
|
||||
dump_control(c);
|
||||
c = c->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dump_menu_item
|
||||
* Syntax : void dump_menu_item(const menu_item_t *item)
|
||||
* Syntax : void dump_menu_item(const menuex_item_t *item)
|
||||
* Input :
|
||||
* Output :
|
||||
* Description :
|
||||
|
@ -667,61 +614,6 @@ static void dump_dialogex(const dialogex_t *dlgex)
|
|||
*****************************************************************************
|
||||
*/
|
||||
static void dump_menu_item(const menu_item_t *item)
|
||||
{
|
||||
while(item)
|
||||
{
|
||||
if(item->popup)
|
||||
{
|
||||
printf("POPUP ");
|
||||
print_string(item->name);
|
||||
printf("\n");
|
||||
dump_menu_item(item->popup);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("MENUITEM ");
|
||||
if(item->name)
|
||||
{
|
||||
print_string(item->name);
|
||||
printf(", %d, %08x", item->id, item->state);
|
||||
}
|
||||
else
|
||||
printf("SEPARATOR");
|
||||
printf("\n");
|
||||
}
|
||||
item = item->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dump_menu
|
||||
* Syntax : void dump_menu(const menu_t *men)
|
||||
* Input :
|
||||
* men - Menu resource descriptor
|
||||
* Output :
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static void dump_menu(const menu_t *men)
|
||||
{
|
||||
dump_memopt(men->memopt);
|
||||
dump_lvc(&(men->lvc));
|
||||
dump_menu_item(men->items);
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dump_menuex_item
|
||||
* Syntax : void dump_menuex_item(const menuex_item_t *item)
|
||||
* Input :
|
||||
* Output :
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static void dump_menuex_item(const menuex_item_t *item)
|
||||
{
|
||||
while(item)
|
||||
{
|
||||
|
@ -738,7 +630,7 @@ static void dump_menuex_item(const menuex_item_t *item)
|
|||
if(item->gothelpid)
|
||||
printf(", HelpId=%d", item->helpid);
|
||||
printf("\n");
|
||||
dump_menuex_item(item->popup);
|
||||
dump_menu_item(item->popup);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -765,20 +657,20 @@ static void dump_menuex_item(const menuex_item_t *item)
|
|||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dump_menuex
|
||||
* Syntax : void dump_menuex(const menuex_t *menex)
|
||||
* Function : dump_menu
|
||||
* Syntax : void dump_menu(const menu_t *men)
|
||||
* Input :
|
||||
* menex - MenuEx resource descriptor
|
||||
* men - Menu resource descriptor
|
||||
* Output :
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static void dump_menuex(const menuex_t *menex)
|
||||
static void dump_menu(const menu_t *men)
|
||||
{
|
||||
dump_memopt(menex->memopt);
|
||||
dump_lvc(&(menex->lvc));
|
||||
dump_menuex_item(menex->items);
|
||||
dump_memopt(men->memopt);
|
||||
dump_lvc(&(men->lvc));
|
||||
dump_menu_item(men->items);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -986,9 +878,6 @@ void dump_resources(const resource_t *top)
|
|||
case res_dlg:
|
||||
dump_dialog(top->res.dlg);
|
||||
break;
|
||||
case res_dlgex:
|
||||
dump_dialogex(top->res.dlgex);
|
||||
break;
|
||||
case res_fnt:
|
||||
dump_font(top->res.fnt);
|
||||
break;
|
||||
|
@ -1001,9 +890,6 @@ void dump_resources(const resource_t *top)
|
|||
case res_men:
|
||||
dump_menu(top->res.men);
|
||||
break;
|
||||
case res_menex:
|
||||
dump_menuex(top->res.menex);
|
||||
break;
|
||||
case res_rdt:
|
||||
dump_rcdata(top->res.rdt);
|
||||
break;
|
||||
|
|
|
@ -33,18 +33,11 @@
|
|||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "wrc.h"
|
||||
#include "genres.h"
|
||||
#include "utils.h"
|
||||
#include "wine/unicode.h"
|
||||
|
||||
/* Fix 64-bit host, re: put_dword */
|
||||
#if defined(unix) && defined(__x86_64__)
|
||||
typedef unsigned int HOST_DWORD;
|
||||
#else
|
||||
typedef unsigned long HOST_DWORD;
|
||||
#endif
|
||||
#include "wine/unicode.h"
|
||||
|
||||
#define SetResSize(res, tag) set_dword((res), (tag), (res)->size - get_dword((res), (tag)))
|
||||
|
||||
|
@ -315,11 +308,17 @@ static void put_string(res_t *res, const string_t *str, enum str_e type, int ist
|
|||
if (str->type == str_char)
|
||||
{
|
||||
if (!check_unicode_conversion( str, newstr, codepage ))
|
||||
{
|
||||
print_location( &str->loc );
|
||||
error( "String %s does not convert identically to Unicode and back in codepage %d. "
|
||||
"Try using a Unicode string instead\n", str->str.cstr, codepage );
|
||||
}
|
||||
if (check_valid_utf8( str, codepage ))
|
||||
{
|
||||
print_location( &str->loc );
|
||||
warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.\n",
|
||||
str->str.cstr, codepage );
|
||||
}
|
||||
}
|
||||
if (!isterm) put_word(res, newstr->size);
|
||||
for(cnt = 0; cnt < newstr->size; cnt++)
|
||||
|
@ -563,8 +562,25 @@ static res_t *dialog2res(name_id_t *name, dialog_t *dlg)
|
|||
{
|
||||
restag = put_res_header(res, WRC_RT_DIALOG, NULL, name, dlg->memopt, &(dlg->lvc));
|
||||
|
||||
put_dword(res, dlg->style->or_mask);
|
||||
put_dword(res, dlg->gotexstyle ? dlg->exstyle->or_mask : 0);
|
||||
if (dlg->is_ex)
|
||||
{
|
||||
/* FIXME: MS doc says that the first word must contain 0xffff
|
||||
* and the second 0x0001 to signal a DLGTEMPLATEEX. Borland's
|
||||
* compiler reverses the two words.
|
||||
* I don't know which one to choose, but I write it as Mr. B
|
||||
* writes it.
|
||||
*/
|
||||
put_word(res, 1); /* Signature */
|
||||
put_word(res, 0xffff); /* DlgVer */
|
||||
put_dword(res, dlg->gothelpid ? dlg->helpid : 0);
|
||||
put_dword(res, dlg->gotexstyle ? dlg->exstyle->or_mask : 0);
|
||||
put_dword(res, dlg->gotstyle ? dlg->style->or_mask : WS_POPUPWINDOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
put_dword(res, dlg->style->or_mask);
|
||||
put_dword(res, dlg->gotexstyle ? dlg->exstyle->or_mask : 0);
|
||||
}
|
||||
tag_nctrl = res->size;
|
||||
put_word(res, 0); /* Number of controls */
|
||||
put_word(res, dlg->x);
|
||||
|
@ -586,20 +602,42 @@ static res_t *dialog2res(name_id_t *name, dialog_t *dlg)
|
|||
if(dlg->font)
|
||||
{
|
||||
put_word(res, dlg->font->size);
|
||||
if (dlg->is_ex)
|
||||
{
|
||||
put_word(res, dlg->font->weight);
|
||||
/* FIXME: ? TRUE should be sufficient to say that it's
|
||||
* italic, but Borland's compiler says it's 0x0101.
|
||||
* I just copy it here, and hope for the best.
|
||||
*/
|
||||
put_word(res, dlg->font->italic ? 0x0101 : 0);
|
||||
}
|
||||
put_string(res, dlg->font->name, str_unicode, TRUE, dlg->lvc.language);
|
||||
}
|
||||
|
||||
put_pad(res);
|
||||
while(ctrl)
|
||||
{
|
||||
/* FIXME: what is default control style? */
|
||||
put_dword(res, ctrl->gotstyle ? ctrl->style->or_mask: WS_CHILD);
|
||||
put_dword(res, ctrl->gotexstyle ? ctrl->exstyle->or_mask : 0);
|
||||
if (dlg->is_ex)
|
||||
{
|
||||
put_dword(res, ctrl->gothelpid ? ctrl->helpid : 0);
|
||||
put_dword(res, ctrl->gotexstyle ? ctrl->exstyle->or_mask : 0);
|
||||
/* FIXME: what is default control style? */
|
||||
put_dword(res, ctrl->gotstyle ? ctrl->style->or_mask : WS_CHILD | WS_VISIBLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME: what is default control style? */
|
||||
put_dword(res, ctrl->gotstyle ? ctrl->style->or_mask: WS_CHILD);
|
||||
put_dword(res, ctrl->gotexstyle ? ctrl->exstyle->or_mask : 0);
|
||||
}
|
||||
put_word(res, ctrl->x);
|
||||
put_word(res, ctrl->y);
|
||||
put_word(res, ctrl->width);
|
||||
put_word(res, ctrl->height);
|
||||
put_word(res, ctrl->id);
|
||||
if (dlg->is_ex)
|
||||
put_dword(res, ctrl->id);
|
||||
else
|
||||
put_word(res, ctrl->id);
|
||||
if(ctrl->ctlclass)
|
||||
put_name_id(res, ctrl->ctlclass, TRUE, dlg->lvc.language);
|
||||
else
|
||||
|
@ -694,124 +732,6 @@ static res_t *dialog2res(name_id_t *name, dialog_t *dlg)
|
|||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : dialogex2res
|
||||
* Syntax : res_t *dialogex2res(name_id_t *name, dialogex_t *dlgex)
|
||||
* Input :
|
||||
* name - Name/ordinal of the resource
|
||||
* dlgex - The dialogex descriptor
|
||||
* Output : New .res format structure
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static res_t *dialogex2res(name_id_t *name, dialogex_t *dlgex)
|
||||
{
|
||||
int restag;
|
||||
res_t *res;
|
||||
control_t *ctrl;
|
||||
int tag_nctrl;
|
||||
int nctrl = 0;
|
||||
assert(name != NULL);
|
||||
assert(dlgex != NULL);
|
||||
|
||||
ctrl = dlgex->controls;
|
||||
res = new_res();
|
||||
if(win32)
|
||||
{
|
||||
restag = put_res_header(res, WRC_RT_DIALOG, NULL, name, dlgex->memopt, &(dlgex->lvc));
|
||||
|
||||
/* FIXME: MS doc says that the first word must contain 0xffff
|
||||
* and the second 0x0001 to signal a DLGTEMPLATEEX. Borland's
|
||||
* compiler reverses the two words.
|
||||
* I don't know which one to choose, but I write it as Mr. B
|
||||
* writes it.
|
||||
*/
|
||||
put_word(res, 1); /* Signature */
|
||||
put_word(res, 0xffff); /* DlgVer */
|
||||
put_dword(res, dlgex->gothelpid ? dlgex->helpid : 0);
|
||||
put_dword(res, dlgex->gotexstyle ? dlgex->exstyle->or_mask : 0);
|
||||
put_dword(res, dlgex->gotstyle ? dlgex->style->or_mask : WS_POPUPWINDOW);
|
||||
tag_nctrl = res->size;
|
||||
put_word(res, 0); /* Number of controls */
|
||||
put_word(res, dlgex->x);
|
||||
put_word(res, dlgex->y);
|
||||
put_word(res, dlgex->width);
|
||||
put_word(res, dlgex->height);
|
||||
if(dlgex->menu)
|
||||
put_name_id(res, dlgex->menu, TRUE, dlgex->lvc.language);
|
||||
else
|
||||
put_word(res, 0);
|
||||
if(dlgex->dlgclass)
|
||||
put_name_id(res, dlgex->dlgclass, TRUE, dlgex->lvc.language);
|
||||
else
|
||||
put_word(res, 0);
|
||||
if(dlgex->title)
|
||||
put_string(res, dlgex->title, str_unicode, TRUE, dlgex->lvc.language);
|
||||
else
|
||||
put_word(res, 0);
|
||||
if(dlgex->font)
|
||||
{
|
||||
put_word(res, dlgex->font->size);
|
||||
put_word(res, dlgex->font->weight);
|
||||
/* FIXME: ? TRUE should be sufficient to say that it's
|
||||
* italic, but Borland's compiler says it's 0x0101.
|
||||
* I just copy it here, and hope for the best.
|
||||
*/
|
||||
put_word(res, dlgex->font->italic ? 0x0101 : 0);
|
||||
put_string(res, dlgex->font->name, str_unicode, TRUE, dlgex->lvc.language);
|
||||
}
|
||||
|
||||
put_pad(res);
|
||||
while(ctrl)
|
||||
{
|
||||
put_dword(res, ctrl->gothelpid ? ctrl->helpid : 0);
|
||||
put_dword(res, ctrl->gotexstyle ? ctrl->exstyle->or_mask : 0);
|
||||
/* FIXME: what is default control style? */
|
||||
put_dword(res, ctrl->gotstyle ? ctrl->style->or_mask : WS_CHILD | WS_VISIBLE);
|
||||
put_word(res, ctrl->x);
|
||||
put_word(res, ctrl->y);
|
||||
put_word(res, ctrl->width);
|
||||
put_word(res, ctrl->height);
|
||||
put_dword(res, ctrl->id);
|
||||
if(ctrl->ctlclass)
|
||||
put_name_id(res, ctrl->ctlclass, TRUE, dlgex->lvc.language);
|
||||
else
|
||||
internal_error(__FILE__, __LINE__, "Control has no control-class\n");
|
||||
if(ctrl->title)
|
||||
put_name_id(res, ctrl->title, FALSE, dlgex->lvc.language);
|
||||
else
|
||||
put_word(res, 0);
|
||||
if(ctrl->extra)
|
||||
{
|
||||
put_pad(res);
|
||||
put_word(res, ctrl->extra->size);
|
||||
put_raw_data(res, ctrl->extra, 0);
|
||||
}
|
||||
else
|
||||
put_word(res, 0);
|
||||
|
||||
put_pad(res);
|
||||
nctrl++;
|
||||
ctrl = ctrl->next;
|
||||
}
|
||||
/* Set number of controls */
|
||||
set_word(res, tag_nctrl, (WORD)nctrl);
|
||||
/* Set ResourceSize */
|
||||
SetResSize(res, restag);
|
||||
put_pad(res);
|
||||
}
|
||||
else /* win16 */
|
||||
{
|
||||
/* Do not generate anything in 16-bit mode */
|
||||
free(res->data);
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : menuitem2res
|
||||
|
@ -860,37 +780,6 @@ static void menuitem2res(res_t *res, menu_item_t *menitem, const language_t *lan
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : menu2res
|
||||
* Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
|
||||
* Input :
|
||||
* name - Name/ordinal of the resource
|
||||
* men - The menu descriptor
|
||||
* Output : New .res format structure
|
||||
* Description :
|
||||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static res_t *menu2res(name_id_t *name, menu_t *men)
|
||||
{
|
||||
int restag;
|
||||
res_t *res;
|
||||
assert(name != NULL);
|
||||
assert(men != NULL);
|
||||
|
||||
res = new_res();
|
||||
restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, win32 ? &(men->lvc) : NULL);
|
||||
|
||||
put_dword(res, 0); /* Menuheader: Version and HeaderSize */
|
||||
menuitem2res(res, men->items, win32 ? men->lvc.language : NULL);
|
||||
/* Set ResourceSize */
|
||||
SetResSize(res, restag);
|
||||
if(win32)
|
||||
put_pad(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : menuexitem2res
|
||||
|
@ -901,9 +790,9 @@ static res_t *menu2res(name_id_t *name, menu_t *men)
|
|||
* Remarks : Self recursive
|
||||
*****************************************************************************
|
||||
*/
|
||||
static void menuexitem2res(res_t *res, menuex_item_t *menitem, const language_t *lang)
|
||||
static void menuexitem2res(res_t *res, menu_item_t *menitem, const language_t *lang)
|
||||
{
|
||||
menuex_item_t *itm = menitem;
|
||||
menu_item_t *itm = menitem;
|
||||
assert(win32 != 0);
|
||||
while(itm)
|
||||
{
|
||||
|
@ -928,8 +817,8 @@ static void menuexitem2res(res_t *res, menuex_item_t *menitem, const language_t
|
|||
|
||||
/*
|
||||
*****************************************************************************
|
||||
* Function : menuex2res
|
||||
* Syntax : res_t *menuex2res(name_id_t *name, menuex_t *menex)
|
||||
* Function : menu2res
|
||||
* Syntax : res_t *menu2res(name_id_t *name, menu_t *men)
|
||||
* Input :
|
||||
* name - Name/ordinal of the resource
|
||||
* menex - The menuex descriptor
|
||||
|
@ -938,33 +827,43 @@ static void menuexitem2res(res_t *res, menuex_item_t *menitem, const language_t
|
|||
* Remarks :
|
||||
*****************************************************************************
|
||||
*/
|
||||
static res_t *menuex2res(name_id_t *name, menuex_t *menex)
|
||||
static res_t *menu2res(name_id_t *name, menu_t *men)
|
||||
{
|
||||
int restag;
|
||||
res_t *res;
|
||||
assert(name != NULL);
|
||||
assert(menex != NULL);
|
||||
assert(men != NULL);
|
||||
|
||||
res = new_res();
|
||||
if(win32)
|
||||
{
|
||||
restag = put_res_header(res, WRC_RT_MENU, NULL, name, menex->memopt, &(menex->lvc));
|
||||
restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, &(men->lvc));
|
||||
|
||||
put_word(res, 1); /* Menuheader: Version */
|
||||
put_word(res, 4); /* Offset */
|
||||
put_dword(res, 0); /* HelpId */
|
||||
put_pad(res);
|
||||
menuexitem2res(res, menex->items, menex->lvc.language);
|
||||
if (men->is_ex)
|
||||
{
|
||||
put_word(res, 1); /* Menuheader: Version */
|
||||
put_word(res, 4); /* Offset */
|
||||
put_dword(res, 0); /* HelpId */
|
||||
put_pad(res);
|
||||
menuexitem2res(res, men->items, men->lvc.language);
|
||||
}
|
||||
else
|
||||
{
|
||||
put_dword(res, 0); /* Menuheader: Version and HeaderSize */
|
||||
menuitem2res(res, men->items, men->lvc.language);
|
||||
}
|
||||
/* Set ResourceSize */
|
||||
SetResSize(res, restag);
|
||||
put_pad(res);
|
||||
}
|
||||
else /* win16 */
|
||||
{
|
||||
/* Do not generate anything in 16-bit mode */
|
||||
free(res->data);
|
||||
free(res);
|
||||
return NULL;
|
||||
restag = put_res_header(res, WRC_RT_MENU, NULL, name, men->memopt, NULL);
|
||||
|
||||
put_dword(res, 0); /* Menuheader: Version and HeaderSize */
|
||||
menuitem2res(res, men->items, NULL);
|
||||
/* Set ResourceSize */
|
||||
SetResSize(res, restag);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -1844,23 +1743,8 @@ char *prep_nid_for_label(const name_id_t *nid)
|
|||
*/
|
||||
char *make_c_name(const char *base, const name_id_t *nid, const language_t *lan)
|
||||
{
|
||||
int nlen;
|
||||
char *buf;
|
||||
char *ret;
|
||||
char lanbuf[6];
|
||||
|
||||
sprintf(lanbuf, "%d", lan ? MAKELANGID(lan->id, lan->sub) : 0);
|
||||
buf = prep_nid_for_label(nid);
|
||||
nlen = strlen(buf) + strlen(lanbuf);
|
||||
nlen += strlen(base) + 4; /* three time '_' and '\0' */
|
||||
ret = xmalloc(nlen);
|
||||
strcpy(ret, "_");
|
||||
strcat(ret, base);
|
||||
strcat(ret, "_");
|
||||
strcat(ret, buf);
|
||||
strcat(ret, "_");
|
||||
strcat(ret, lanbuf);
|
||||
return ret;
|
||||
char *buf = prep_nid_for_label(nid);
|
||||
return strmake( "_%s_%s_%d", base, buf, lan ? MAKELANGID(lan->id, lan->sub) : 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1884,14 +1768,12 @@ const char *get_c_typename(enum res_e type)
|
|||
case res_bmp: return "Bmp";
|
||||
case res_cur: return "Cur";
|
||||
case res_curg: return "CurGrp";
|
||||
case res_dlg:
|
||||
case res_dlgex: return "Dlg";
|
||||
case res_dlg: return "Dlg";
|
||||
case res_fnt: return "Fnt";
|
||||
case res_fntdir:return "FntDir";
|
||||
case res_ico: return "Ico";
|
||||
case res_icog: return "IcoGrp";
|
||||
case res_men:
|
||||
case res_menex: return "Men";
|
||||
case res_men: return "Men";
|
||||
case res_rdt: return "RCDat";
|
||||
case res_stt: return "StrTab";
|
||||
case res_usr: return "Usr";
|
||||
|
@ -1940,10 +1822,6 @@ void resources2res(resource_t *top)
|
|||
if(!top->binres)
|
||||
top->binres = dialog2res(top->name, top->res.dlg);
|
||||
break;
|
||||
case res_dlgex:
|
||||
if(!top->binres)
|
||||
top->binres = dialogex2res(top->name, top->res.dlgex);
|
||||
break;
|
||||
case res_fnt:
|
||||
if(!top->binres)
|
||||
top->binres = font2res(top->name, top->res.fnt);
|
||||
|
@ -1964,10 +1842,6 @@ void resources2res(resource_t *top)
|
|||
if(!top->binres)
|
||||
top->binres = menu2res(top->name, top->res.men);
|
||||
break;
|
||||
case res_menex:
|
||||
if(!top->binres)
|
||||
top->binres = menuex2res(top->name, top->res.menex);
|
||||
break;
|
||||
case res_html:
|
||||
if(!top->binres)
|
||||
top->binres = html2res(top->name, top->res.html);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,34 +43,145 @@ typedef struct
|
|||
} BITMAPOS2HEADER;
|
||||
#include <poppack.h>
|
||||
|
||||
/* Generate new_* functions that have no parameters (NOTE: no ';') */
|
||||
__NEW_STRUCT_FUNC(dialog)
|
||||
__NEW_STRUCT_FUNC(dialogex)
|
||||
__NEW_STRUCT_FUNC(name_id)
|
||||
__NEW_STRUCT_FUNC(menu)
|
||||
__NEW_STRUCT_FUNC(menuex)
|
||||
__NEW_STRUCT_FUNC(menu_item)
|
||||
__NEW_STRUCT_FUNC(menuex_item)
|
||||
__NEW_STRUCT_FUNC(control)
|
||||
__NEW_STRUCT_FUNC(icon)
|
||||
__NEW_STRUCT_FUNC(cursor)
|
||||
__NEW_STRUCT_FUNC(versioninfo)
|
||||
__NEW_STRUCT_FUNC(ver_value)
|
||||
__NEW_STRUCT_FUNC(ver_block)
|
||||
__NEW_STRUCT_FUNC(stt_entry)
|
||||
__NEW_STRUCT_FUNC(accelerator)
|
||||
__NEW_STRUCT_FUNC(event)
|
||||
__NEW_STRUCT_FUNC(raw_data)
|
||||
__NEW_STRUCT_FUNC(lvc)
|
||||
__NEW_STRUCT_FUNC(res_count)
|
||||
__NEW_STRUCT_FUNC(string)
|
||||
__NEW_STRUCT_FUNC(toolbar_item)
|
||||
__NEW_STRUCT_FUNC(ani_any)
|
||||
|
||||
/* New instances for all types of structures */
|
||||
/* Very inefficient (in size), but very functional :-]
|
||||
* Especially for type-checking.
|
||||
*/
|
||||
|
||||
dialog_t *new_dialog(void)
|
||||
{
|
||||
dialog_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
name_id_t *new_name_id(void)
|
||||
{
|
||||
name_id_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
menu_t *new_menu(void)
|
||||
{
|
||||
menu_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
menu_item_t *new_menu_item(void)
|
||||
{
|
||||
menu_item_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
control_t *new_control(void)
|
||||
{
|
||||
control_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
icon_t *new_icon(void)
|
||||
{
|
||||
icon_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
cursor_t *new_cursor(void)
|
||||
{
|
||||
cursor_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
versioninfo_t *new_versioninfo(void)
|
||||
{
|
||||
versioninfo_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
ver_value_t *new_ver_value(void)
|
||||
{
|
||||
ver_value_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
ver_block_t *new_ver_block(void)
|
||||
{
|
||||
ver_block_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
stt_entry_t *new_stt_entry(void)
|
||||
{
|
||||
stt_entry_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
accelerator_t *new_accelerator(void)
|
||||
{
|
||||
accelerator_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
event_t *new_event(void)
|
||||
{
|
||||
event_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
raw_data_t *new_raw_data(void)
|
||||
{
|
||||
raw_data_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
lvc_t *new_lvc(void)
|
||||
{
|
||||
lvc_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
res_count_t *new_res_count(void)
|
||||
{
|
||||
res_count_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
string_t *new_string(void)
|
||||
{
|
||||
string_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
set_location( &ret->loc );
|
||||
return ret;
|
||||
}
|
||||
|
||||
toolbar_item_t *new_toolbar_item(void)
|
||||
{
|
||||
toolbar_item_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
ani_any_t *new_ani_any(void)
|
||||
{
|
||||
ani_any_t *ret = xmalloc( sizeof(*ret) );
|
||||
memset( ret, 0, sizeof(*ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan)
|
||||
{
|
||||
resource_t *r = xmalloc(sizeof(resource_t));
|
||||
|
@ -207,41 +318,42 @@ fontdir_t *new_fontdir(raw_data_t *rd, int *memopt)
|
|||
/*
|
||||
* Convert bitmaps to proper endian
|
||||
*/
|
||||
static void convert_bitmap_swap_v3(BITMAPINFOHEADER *bih)
|
||||
static void convert_bitmap_swap(BITMAPV5HEADER *bh, DWORD size)
|
||||
{
|
||||
bih->biSize = BYTESWAP_DWORD(bih->biSize);
|
||||
bih->biWidth = BYTESWAP_DWORD(bih->biWidth);
|
||||
bih->biHeight = BYTESWAP_DWORD(bih->biHeight);
|
||||
bih->biPlanes = BYTESWAP_WORD(bih->biPlanes);
|
||||
bih->biBitCount = BYTESWAP_WORD(bih->biBitCount);
|
||||
bih->biCompression = BYTESWAP_DWORD(bih->biCompression);
|
||||
bih->biSizeImage = BYTESWAP_DWORD(bih->biSizeImage);
|
||||
bih->biXPelsPerMeter = BYTESWAP_DWORD(bih->biXPelsPerMeter);
|
||||
bih->biYPelsPerMeter = BYTESWAP_DWORD(bih->biYPelsPerMeter);
|
||||
bih->biClrUsed = BYTESWAP_DWORD(bih->biClrUsed);
|
||||
bih->biClrImportant = BYTESWAP_DWORD(bih->biClrImportant);
|
||||
}
|
||||
|
||||
static void convert_bitmap_swap_v4(BITMAPV4HEADER *b4h)
|
||||
{
|
||||
convert_bitmap_swap_v3((BITMAPINFOHEADER *)b4h);
|
||||
b4h->bV4RedMask = BYTESWAP_DWORD(b4h->bV4RedMask);
|
||||
b4h->bV4GreenMask = BYTESWAP_DWORD(b4h->bV4GreenMask);
|
||||
b4h->bV4BlueMask = BYTESWAP_DWORD(b4h->bV4BlueMask);
|
||||
b4h->bV4AlphaMask = BYTESWAP_DWORD(b4h->bV4AlphaMask);
|
||||
b4h->bV4CSType = BYTESWAP_DWORD(b4h->bV4CSType);
|
||||
b4h->bV4Endpoints.ciexyzRed.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzX);
|
||||
b4h->bV4Endpoints.ciexyzRed.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzY);
|
||||
b4h->bV4Endpoints.ciexyzRed.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzRed.ciexyzZ);
|
||||
b4h->bV4Endpoints.ciexyzGreen.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzX);
|
||||
b4h->bV4Endpoints.ciexyzGreen.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzY);
|
||||
b4h->bV4Endpoints.ciexyzGreen.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzGreen.ciexyzZ);
|
||||
b4h->bV4Endpoints.ciexyzBlue.ciexyzX = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzX);
|
||||
b4h->bV4Endpoints.ciexyzBlue.ciexyzY = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzY);
|
||||
b4h->bV4Endpoints.ciexyzBlue.ciexyzZ = BYTESWAP_DWORD(b4h->bV4Endpoints.ciexyzBlue.ciexyzZ);
|
||||
b4h->bV4GammaRed = BYTESWAP_DWORD(b4h->bV4GammaRed);
|
||||
b4h->bV4GammaGreen = BYTESWAP_DWORD(b4h->bV4GammaGreen);
|
||||
b4h->bV4GammaBlue = BYTESWAP_DWORD(b4h->bV4GammaBlue);
|
||||
bh->bV5Size = BYTESWAP_DWORD(bh->bV5Size);
|
||||
bh->bV5Width = BYTESWAP_DWORD(bh->bV5Width);
|
||||
bh->bV5Height = BYTESWAP_DWORD(bh->bV5Height);
|
||||
bh->bV5Planes = BYTESWAP_WORD(bh->bV5Planes);
|
||||
bh->bV5BitCount = BYTESWAP_WORD(bh->bV5BitCount);
|
||||
bh->bV5Compression = BYTESWAP_DWORD(bh->bV5Compression);
|
||||
bh->bV5SizeImage = BYTESWAP_DWORD(bh->bV5SizeImage);
|
||||
bh->bV5XPelsPerMeter = BYTESWAP_DWORD(bh->bV5XPelsPerMeter);
|
||||
bh->bV5YPelsPerMeter = BYTESWAP_DWORD(bh->bV5YPelsPerMeter);
|
||||
bh->bV5ClrUsed = BYTESWAP_DWORD(bh->bV5ClrUsed);
|
||||
bh->bV5ClrImportant = BYTESWAP_DWORD(bh->bV5ClrImportant);
|
||||
if (size == sizeof(BITMAPINFOHEADER)) return;
|
||||
bh->bV5RedMask = BYTESWAP_DWORD(bh->bV5RedMask);
|
||||
bh->bV5GreenMask = BYTESWAP_DWORD(bh->bV5GreenMask);
|
||||
bh->bV5BlueMask = BYTESWAP_DWORD(bh->bV5BlueMask);
|
||||
bh->bV5AlphaMask = BYTESWAP_DWORD(bh->bV5AlphaMask);
|
||||
bh->bV5CSType = BYTESWAP_DWORD(bh->bV5CSType);
|
||||
bh->bV5Endpoints.ciexyzRed.ciexyzX = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzRed.ciexyzX);
|
||||
bh->bV5Endpoints.ciexyzRed.ciexyzY = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzRed.ciexyzY);
|
||||
bh->bV5Endpoints.ciexyzRed.ciexyzZ = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzRed.ciexyzZ);
|
||||
bh->bV5Endpoints.ciexyzGreen.ciexyzX = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzGreen.ciexyzX);
|
||||
bh->bV5Endpoints.ciexyzGreen.ciexyzY = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzGreen.ciexyzY);
|
||||
bh->bV5Endpoints.ciexyzGreen.ciexyzZ = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzGreen.ciexyzZ);
|
||||
bh->bV5Endpoints.ciexyzBlue.ciexyzX = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzBlue.ciexyzX);
|
||||
bh->bV5Endpoints.ciexyzBlue.ciexyzY = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzBlue.ciexyzY);
|
||||
bh->bV5Endpoints.ciexyzBlue.ciexyzZ = BYTESWAP_DWORD(bh->bV5Endpoints.ciexyzBlue.ciexyzZ);
|
||||
bh->bV5GammaRed = BYTESWAP_DWORD(bh->bV5GammaRed);
|
||||
bh->bV5GammaGreen = BYTESWAP_DWORD(bh->bV5GammaGreen);
|
||||
bh->bV5GammaBlue = BYTESWAP_DWORD(bh->bV5GammaBlue);
|
||||
if (size == sizeof(BITMAPV4HEADER)) return;
|
||||
bh->bV5Intent = BYTESWAP_DWORD(bh->bV5Intent);
|
||||
bh->bV5ProfileData = BYTESWAP_DWORD(bh->bV5ProfileData);
|
||||
bh->bV5ProfileSize = BYTESWAP_DWORD(bh->bV5ProfileSize);
|
||||
bh->bV5Reserved = BYTESWAP_DWORD(bh->bV5Reserved);
|
||||
}
|
||||
|
||||
static void convert_bitmap_swap_os2(BITMAPOS2HEADER *boh)
|
||||
|
@ -255,31 +367,13 @@ static void convert_bitmap_swap_os2(BITMAPOS2HEADER *boh)
|
|||
|
||||
#define FL_SIGBE 0x01
|
||||
#define FL_SIZEBE 0x02
|
||||
#define FL_V4 0x04
|
||||
#define FL_OS2 0x08
|
||||
static int convert_bitmap(char *data, int size)
|
||||
{
|
||||
BITMAPINFOHEADER *bih = (BITMAPINFOHEADER *)data;
|
||||
BITMAPV4HEADER *b4h = (BITMAPV4HEADER *)data;
|
||||
BITMAPV5HEADER *bih = (BITMAPV5HEADER *)data;
|
||||
BITMAPOS2HEADER *boh = (BITMAPOS2HEADER *)data;
|
||||
DWORD bmsize;
|
||||
int type = 0;
|
||||
int returnSize = 0; /* size to be returned */
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
DWORD bisizel = BYTESWAP_DWORD(sizeof(BITMAPINFOHEADER));
|
||||
DWORD b4sizel = BYTESWAP_DWORD(sizeof(BITMAPV4HEADER));
|
||||
DWORD bosizel = BYTESWAP_DWORD(sizeof(BITMAPOS2HEADER));
|
||||
DWORD bisizeb = sizeof(BITMAPINFOHEADER);
|
||||
DWORD b4sizeb = sizeof(BITMAPV4HEADER);
|
||||
DWORD bosizeb = sizeof(BITMAPOS2HEADER);
|
||||
#else
|
||||
DWORD bisizel = sizeof(BITMAPINFOHEADER);
|
||||
DWORD b4sizel = sizeof(BITMAPV4HEADER);
|
||||
DWORD bosizel = sizeof(BITMAPOS2HEADER);
|
||||
DWORD bisizeb = BYTESWAP_DWORD(sizeof(BITMAPINFOHEADER));
|
||||
DWORD b4sizeb = BYTESWAP_DWORD(sizeof(BITMAPV4HEADER));
|
||||
DWORD bosizeb = BYTESWAP_DWORD(sizeof(BITMAPOS2HEADER));
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Originally the bih and b4h pointers were simply incremented here,
|
||||
|
@ -300,47 +394,40 @@ static int convert_bitmap(char *data, int size)
|
|||
|
||||
}
|
||||
|
||||
if(bih->biSize == bisizel)
|
||||
{
|
||||
/* Little endian */
|
||||
}
|
||||
else if(bih->biSize == bisizeb)
|
||||
{
|
||||
type |= FL_SIZEBE;
|
||||
}
|
||||
else if(bih->biSize == b4sizel)
|
||||
{
|
||||
type |= FL_V4;
|
||||
}
|
||||
else if(bih->biSize == b4sizeb)
|
||||
{
|
||||
type |= FL_SIZEBE | FL_V4;
|
||||
}
|
||||
else if(!bih->biSize || bih->biSize == bosizel)
|
||||
{
|
||||
type |= FL_OS2;
|
||||
}
|
||||
else if(bih->biSize == bosizeb)
|
||||
{
|
||||
type |= FL_SIZEBE | FL_OS2;
|
||||
}
|
||||
else
|
||||
parser_error("Invalid bitmap format, bih->biSize = %d", bih->biSize);
|
||||
bmsize = bih->bV5Size;
|
||||
if (bmsize >> 16) /* assume swapped */
|
||||
{
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
type |= FL_SIZEBE;
|
||||
#endif
|
||||
bmsize = BYTESWAP_DWORD( bmsize );
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
type |= FL_SIZEBE;
|
||||
#endif
|
||||
}
|
||||
|
||||
switch (bmsize)
|
||||
{
|
||||
case sizeof(BITMAPOS2HEADER):
|
||||
case sizeof(BITMAPINFOHEADER):
|
||||
case sizeof(BITMAPV4HEADER):
|
||||
case sizeof(BITMAPV5HEADER):
|
||||
break;
|
||||
default:
|
||||
parser_error("Invalid bitmap format, bih->biSize = %d", bih->bV5Size);
|
||||
}
|
||||
|
||||
switch(type)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
case FL_SIZEBE:
|
||||
case FL_SIZEBE | FL_V4:
|
||||
case FL_SIZEBE | FL_OS2:
|
||||
parser_warning("Bitmap v%c signature little-endian, but size big-endian\n", type & FL_V4 ? '4' : '3');
|
||||
break;
|
||||
parser_warning("Bitmap signature little-endian, but size big-endian\n");
|
||||
break;
|
||||
case FL_SIGBE:
|
||||
case FL_SIGBE | FL_V4:
|
||||
case FL_SIGBE | FL_OS2:
|
||||
parser_warning("Bitmap v%c signature big-endian, but size little-endian\n", type & FL_V4 ? '4' : '3');
|
||||
break;
|
||||
parser_warning("Bitmap signature big-endian, but size little-endian\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch(byteorder)
|
||||
|
@ -351,14 +438,10 @@ static int convert_bitmap(char *data, int size)
|
|||
case WRC_BO_BIG:
|
||||
if(!(type & FL_SIZEBE))
|
||||
{
|
||||
if(type & FL_V4)
|
||||
convert_bitmap_swap_v4(b4h);
|
||||
else if(type & FL_OS2)
|
||||
{
|
||||
convert_bitmap_swap_os2(boh);
|
||||
}
|
||||
else
|
||||
convert_bitmap_swap_v3(bih);
|
||||
if (bmsize == sizeof(BITMAPOS2HEADER))
|
||||
convert_bitmap_swap_os2(boh);
|
||||
else
|
||||
convert_bitmap_swap(bih, bmsize);
|
||||
}
|
||||
break;
|
||||
#ifndef WORDS_BIGENDIAN
|
||||
|
@ -367,14 +450,10 @@ static int convert_bitmap(char *data, int size)
|
|||
case WRC_BO_LITTLE:
|
||||
if(type & FL_SIZEBE)
|
||||
{
|
||||
if(type & FL_V4)
|
||||
convert_bitmap_swap_v4(b4h);
|
||||
else if(type & FL_OS2)
|
||||
{
|
||||
convert_bitmap_swap_os2(boh);
|
||||
}
|
||||
else
|
||||
convert_bitmap_swap_v3(bih);
|
||||
if (bmsize == sizeof(BITMAPOS2HEADER))
|
||||
convert_bitmap_swap_os2(boh);
|
||||
else
|
||||
convert_bitmap_swap(bih, bmsize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -389,7 +468,6 @@ static int convert_bitmap(char *data, int size)
|
|||
}
|
||||
#undef FL_SIGBE
|
||||
#undef FL_SIZEBE
|
||||
#undef FL_V4
|
||||
|
||||
/*
|
||||
* Cursor and icon splitter functions used when allocating
|
||||
|
|
|
@ -23,39 +23,25 @@
|
|||
|
||||
#include "wrctypes.h"
|
||||
|
||||
#define __NEW_STRUCT_FUNC(p) \
|
||||
p##_t *new_##p(void)\
|
||||
{\
|
||||
p##_t * ret = xmalloc(sizeof(*ret)); \
|
||||
memset( ret, 0, sizeof(*ret) ); \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define __NEW_STRUCT_PROTO(p) p##_t *new_##p(void)
|
||||
|
||||
__NEW_STRUCT_PROTO(dialog);
|
||||
__NEW_STRUCT_PROTO(dialogex);
|
||||
__NEW_STRUCT_PROTO(name_id);
|
||||
__NEW_STRUCT_PROTO(menu);
|
||||
__NEW_STRUCT_PROTO(menuex);
|
||||
__NEW_STRUCT_PROTO(menu_item);
|
||||
__NEW_STRUCT_PROTO(menuex_item);
|
||||
__NEW_STRUCT_PROTO(control);
|
||||
__NEW_STRUCT_PROTO(icon);
|
||||
__NEW_STRUCT_PROTO(cursor);
|
||||
__NEW_STRUCT_PROTO(versioninfo);
|
||||
__NEW_STRUCT_PROTO(ver_value);
|
||||
__NEW_STRUCT_PROTO(ver_block);
|
||||
__NEW_STRUCT_PROTO(stt_entry);
|
||||
__NEW_STRUCT_PROTO(accelerator);
|
||||
__NEW_STRUCT_PROTO(event);
|
||||
__NEW_STRUCT_PROTO(raw_data);
|
||||
__NEW_STRUCT_PROTO(lvc);
|
||||
__NEW_STRUCT_PROTO(res_count);
|
||||
__NEW_STRUCT_PROTO(string);
|
||||
__NEW_STRUCT_PROTO(toolbar_item);
|
||||
__NEW_STRUCT_PROTO(ani_any);
|
||||
|
||||
dialog_t *new_dialog(void);
|
||||
name_id_t *new_name_id(void);
|
||||
menu_t *new_menu(void);
|
||||
menu_item_t *new_menu_item(void);
|
||||
control_t *new_control(void);
|
||||
icon_t *new_icon(void);
|
||||
cursor_t *new_cursor(void);
|
||||
versioninfo_t *new_versioninfo(void);
|
||||
ver_value_t *new_ver_value(void);
|
||||
ver_block_t *new_ver_block(void);
|
||||
stt_entry_t *new_stt_entry(void);
|
||||
accelerator_t *new_accelerator(void);
|
||||
event_t *new_event(void);
|
||||
raw_data_t *new_raw_data(void);
|
||||
lvc_t *new_lvc(void);
|
||||
res_count_t *new_res_count(void);
|
||||
string_t *new_string(void);
|
||||
toolbar_item_t *new_toolbar_item(void);
|
||||
ani_any_t *new_ani_any(void);
|
||||
resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan);
|
||||
version_t *new_version(DWORD v);
|
||||
characts_t *new_characts(DWORD c);
|
||||
|
|
|
@ -34,5 +34,6 @@ extern char *parser_text;
|
|||
extern int yy_flex_debug;
|
||||
|
||||
int parser_lex(void);
|
||||
int parser_lex_destroy(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -106,7 +106,9 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
|
|||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifndef HAVE_UNISTD_H
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#define YY_NO_UNISTD_H
|
||||
#endif
|
||||
|
||||
|
@ -395,9 +397,12 @@ static unsigned long xstrtoul(const char *nptr, char **endptr, int base)
|
|||
\{ return tBEGIN;
|
||||
\} return tEND;
|
||||
|
||||
[0-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
|
||||
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 16); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
|
||||
0[oO][0-7]+[lL]? { parser_lval.num = xstrtoul(yytext+2, 0, 8); return toupper(yytext[yyleng-1]) == 'L' ? tLNUMBER : tNUMBER; }
|
||||
[0-9]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 10);
|
||||
return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
|
||||
0[xX][0-9A-Fa-f]+[lL]? { parser_lval.num = xstrtoul(yytext, 0, 16);
|
||||
return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
|
||||
0[oO][0-7]+[lL]? { parser_lval.num = xstrtoul(yytext+2, 0, 8);
|
||||
return (yytext[yyleng-1] == 'L' || yytext[yyleng-1] == 'l') ? tLNUMBER : tNUMBER; }
|
||||
|
||||
/*
|
||||
* The next two rules scan identifiers and filenames.
|
||||
|
@ -465,7 +470,11 @@ L\" {
|
|||
<tklstr>\\r addwchar('\r');
|
||||
<tklstr>\\t addwchar('\t');
|
||||
<tklstr>\\v addwchar('\v');
|
||||
<tklstr>\\. addwchar(yytext[1]);
|
||||
<tklstr>\\. {
|
||||
if (yytext[1] & 0x80)
|
||||
parser_error("Invalid char %u in wide string", (unsigned char)yytext[1]);
|
||||
addwchar(yytext[1]);
|
||||
}
|
||||
<tklstr>\\\r\n addwchar(yytext[2]); line_number++; char_number = 1;
|
||||
<tklstr>\"\" addwchar('\"'); /* "bla""bla" -> "bla\"bla" */
|
||||
<tklstr>\\\"\" addwchar('\"'); /* "bla\""bla" -> "bla\"bla" */
|
||||
|
@ -473,7 +482,11 @@ L\" {
|
|||
<tklstr>[^\\\n\"]+ {
|
||||
char *yptr = yytext;
|
||||
while(*yptr) /* FIXME: codepage translation */
|
||||
addwchar(*yptr++ & 0xff);
|
||||
{
|
||||
if (*yptr & 0x80)
|
||||
parser_error("Invalid char %u in wide string", (unsigned char)*yptr);
|
||||
addwchar(*yptr++ & 0xff);
|
||||
}
|
||||
}
|
||||
<tklstr>\n parser_error("Unterminated string");
|
||||
|
||||
|
@ -586,7 +599,6 @@ L\" {
|
|||
isprint((unsigned char)*yytext) ? *yytext : '.', *yytext, YY_START);
|
||||
}
|
||||
|
||||
<<EOF>> current_codepage = -1; yyterminate();
|
||||
%%
|
||||
|
||||
/* These dup functions copy the enclosed '\0' from
|
||||
|
@ -638,7 +650,7 @@ static string_t *get_buffered_cstring(void)
|
|||
parser_error("String %s does not convert identically to Unicode and back in codepage %d. "
|
||||
"Try using a Unicode string instead", str->str.cstr, current_codepage );
|
||||
if (check_valid_utf8( str, current_codepage ))
|
||||
parser_warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.",
|
||||
parser_warning( "string \"%s\" seems to be UTF-8 but codepage %u is in use.\n",
|
||||
str->str.cstr, current_codepage );
|
||||
free_string( str );
|
||||
return str_w;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,9 @@
|
|||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -131,8 +130,8 @@
|
|||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 238 "parser.y"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 228 "parser.y"
|
||||
|
||||
string_t *str;
|
||||
int num;
|
||||
|
@ -142,11 +141,9 @@ typedef union YYSTYPE
|
|||
accelerator_t *acc;
|
||||
bitmap_t *bmp;
|
||||
dialog_t *dlg;
|
||||
dialogex_t *dlgex;
|
||||
font_t *fnt;
|
||||
fontdir_t *fnd;
|
||||
menu_t *men;
|
||||
menuex_t *menex;
|
||||
html_t *html;
|
||||
rcdata_t *rdt;
|
||||
stringtable_t *stt;
|
||||
|
@ -162,7 +159,6 @@ typedef union YYSTYPE
|
|||
characts_t *chars;
|
||||
event_t *event;
|
||||
menu_item_t *menitm;
|
||||
menuex_item_t *menexitm;
|
||||
itemex_opt_t *exopt;
|
||||
raw_data_t *raw;
|
||||
lvc_t *lvc;
|
||||
|
@ -178,8 +174,8 @@ typedef union YYSTYPE
|
|||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 183 "parser.tab.h"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 179 "parser.tab.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
|
|
@ -192,7 +192,6 @@ static control_t *get_control_head(control_t *p);
|
|||
static ver_value_t *get_ver_value_head(ver_value_t *p);
|
||||
static ver_block_t *get_ver_block_head(ver_block_t *p);
|
||||
static resource_t *get_resource_head(resource_t *p);
|
||||
static menuex_item_t *get_itemex_head(menuex_item_t *p);
|
||||
static menu_item_t *get_item_head(menu_item_t *p);
|
||||
static raw_data_t *merge_raw_data_str(raw_data_t *r1, string_t *str);
|
||||
static raw_data_t *merge_raw_data_int(raw_data_t *r1, int i);
|
||||
|
@ -205,15 +204,6 @@ static raw_data_t *load_file(string_t *name, language_t *lang);
|
|||
static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid);
|
||||
static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev);
|
||||
static event_t *add_event(int key, int id, int flags, event_t *prev);
|
||||
static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_exstyle(style_t *st, dialogex_t *dlg);
|
||||
static dialogex_t *dialogex_style(style_t *st, dialogex_t *dlg);
|
||||
static name_id_t *convert_ctlclass(name_id_t *cls);
|
||||
static control_t *ins_ctrl(int type, int special_style, control_t *ctrl, control_t *prev);
|
||||
static dialog_t *dialog_version(version_t *v, dialog_t *dlg);
|
||||
|
@ -244,11 +234,9 @@ static int rsrcid_to_token(int lookahead);
|
|||
accelerator_t *acc;
|
||||
bitmap_t *bmp;
|
||||
dialog_t *dlg;
|
||||
dialogex_t *dlgex;
|
||||
font_t *fnt;
|
||||
fontdir_t *fnd;
|
||||
menu_t *men;
|
||||
menuex_t *menex;
|
||||
html_t *html;
|
||||
rcdata_t *rdt;
|
||||
stringtable_t *stt;
|
||||
|
@ -264,7 +252,6 @@ static int rsrcid_to_token(int lookahead);
|
|||
characts_t *chars;
|
||||
event_t *event;
|
||||
menu_item_t *menitm;
|
||||
menuex_item_t *menexitm;
|
||||
itemex_opt_t *exopt;
|
||||
raw_data_t *raw;
|
||||
lvc_t *lvc;
|
||||
|
@ -316,10 +303,9 @@ static int rsrcid_to_token(int lookahead);
|
|||
%type <event> events
|
||||
%type <bmp> bitmap
|
||||
%type <ani> cursor icon
|
||||
%type <dlg> dialog dlg_attributes
|
||||
%type <dlg> dialog dlg_attributes dialogex dlgex_attribs
|
||||
%type <ctl> ctrls gen_ctrl lab_ctrl ctrl_desc iconinfo
|
||||
%type <iptr> helpid
|
||||
%type <dlgex> dialogex dlgex_attribs
|
||||
%type <ctl> exctrls gen_exctrl lab_exctrl exctrl_desc
|
||||
%type <html> html
|
||||
%type <rdt> rcdata
|
||||
|
@ -328,10 +314,8 @@ static int rsrcid_to_token(int lookahead);
|
|||
%type <verw> ver_words
|
||||
%type <blk> ver_blocks ver_block
|
||||
%type <val> ver_values ver_value
|
||||
%type <men> menu
|
||||
%type <menitm> item_definitions menu_body
|
||||
%type <menex> menuex
|
||||
%type <menexitm> itemex_definitions menuex_body
|
||||
%type <men> menu menuex
|
||||
%type <menitm> item_definitions menu_body itemex_definitions menuex_body
|
||||
%type <exopt> itemex_p_options itemex_options
|
||||
%type <msg> messagetable
|
||||
%type <usr> userres
|
||||
|
@ -385,7 +369,7 @@ resource_file
|
|||
else
|
||||
$1 = rsc;
|
||||
|
||||
/* Final statements before were done */
|
||||
/* Final statements before we're done */
|
||||
if ((head = get_resource_head($1)) != NULL)
|
||||
{
|
||||
if (resource_top) /* append to existing resources */
|
||||
|
@ -616,7 +600,7 @@ resource_definition
|
|||
| dialog { $$ = new_resource(res_dlg, $1, $1->memopt, $1->lvc.language); }
|
||||
| dialogex {
|
||||
if(win32)
|
||||
$$ = new_resource(res_dlgex, $1, $1->memopt, $1->lvc.language);
|
||||
$$ = new_resource(res_dlg, $1, $1->memopt, $1->lvc.language);
|
||||
else
|
||||
$$ = NULL;
|
||||
}
|
||||
|
@ -650,7 +634,7 @@ resource_definition
|
|||
| menu { $$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language); }
|
||||
| menuex {
|
||||
if(win32)
|
||||
$$ = new_resource(res_menex, $1, $1->memopt, $1->lvc.language);
|
||||
$$ = new_resource(res_men, $1, $1->memopt, $1->lvc.language);
|
||||
else
|
||||
$$ = NULL;
|
||||
}
|
||||
|
@ -1078,17 +1062,17 @@ dialogex: tDIALOGEX loadmemopts expr ',' expr ',' expr ',' expr helpid dlgex_att
|
|||
;
|
||||
|
||||
dlgex_attribs
|
||||
: /* Empty */ { $$=new_dialogex(); }
|
||||
| dlgex_attribs tSTYLE style { $$=dialogex_style($3,$1); }
|
||||
| dlgex_attribs tEXSTYLE style { $$=dialogex_exstyle($3,$1); }
|
||||
| dlgex_attribs tCAPTION tSTRING { $$=dialogex_caption($3,$1); }
|
||||
| dlgex_attribs opt_font { $$=dialogex_font($2,$1); }
|
||||
| dlgex_attribs opt_exfont { $$=dialogex_font($2,$1); }
|
||||
| dlgex_attribs tCLASS nameid_s { $$=dialogex_class($3,$1); }
|
||||
| dlgex_attribs tMENU nameid { $$=dialogex_menu($3,$1); }
|
||||
| dlgex_attribs opt_language { $$=dialogex_language($2,$1); }
|
||||
| dlgex_attribs opt_characts { $$=dialogex_characteristics($2,$1); }
|
||||
| dlgex_attribs opt_version { $$=dialogex_version($2,$1); }
|
||||
: /* Empty */ { $$=new_dialog(); $$->is_ex = TRUE; }
|
||||
| dlgex_attribs tSTYLE style { $$=dialog_style($3,$1); }
|
||||
| dlgex_attribs tEXSTYLE style { $$=dialog_exstyle($3,$1); }
|
||||
| dlgex_attribs tCAPTION tSTRING { $$=dialog_caption($3,$1); }
|
||||
| dlgex_attribs opt_font { $$=dialog_font($2,$1); }
|
||||
| dlgex_attribs opt_exfont { $$=dialog_font($2,$1); }
|
||||
| dlgex_attribs tCLASS nameid_s { $$=dialog_class($3,$1); }
|
||||
| dlgex_attribs tMENU nameid { $$=dialog_menu($3,$1); }
|
||||
| dlgex_attribs opt_language { $$=dialog_language($2,$1); }
|
||||
| dlgex_attribs opt_characts { $$=dialog_characteristics($2,$1); }
|
||||
| dlgex_attribs opt_version { $$=dialog_version($2,$1); }
|
||||
;
|
||||
|
||||
exctrls : /* Empty */ { $$ = NULL; }
|
||||
|
@ -1294,13 +1278,14 @@ item_definitions
|
|||
* (who would want to specify a MF_x flag twice?).
|
||||
*/
|
||||
item_options
|
||||
: /* Empty */ { $$ = 0; }
|
||||
| opt_comma tCHECKED item_options { $$ = $3 | MF_CHECKED; }
|
||||
| opt_comma tGRAYED item_options { $$ = $3 | MF_GRAYED; }
|
||||
| opt_comma tHELP item_options { $$ = $3 | MF_HELP; }
|
||||
| opt_comma tINACTIVE item_options { $$ = $3 | MF_DISABLED; }
|
||||
| opt_comma tMENUBARBREAK item_options { $$ = $3 | MF_MENUBARBREAK; }
|
||||
| opt_comma tMENUBREAK item_options { $$ = $3 | MF_MENUBREAK; }
|
||||
: /* Empty */ { $$ = 0; }
|
||||
| ',' item_options { $$ = $2; }
|
||||
| tCHECKED item_options { $$ = $2 | MF_CHECKED; }
|
||||
| tGRAYED item_options { $$ = $2 | MF_GRAYED; }
|
||||
| tHELP item_options { $$ = $2 | MF_HELP; }
|
||||
| tINACTIVE item_options { $$ = $2 | MF_DISABLED; }
|
||||
| tMENUBARBREAK item_options { $$ = $2 | MF_MENUBARBREAK; }
|
||||
| tMENUBREAK item_options { $$ = $2 | MF_MENUBREAK; }
|
||||
;
|
||||
|
||||
/* ------------------------------ MenuEx ------------------------------ */
|
||||
|
@ -1309,7 +1294,8 @@ menuex : tMENUEX loadmemopts opt_lvc menuex_body {
|
|||
parser_warning("MENUEX not supported in 16-bit mode\n");
|
||||
if(!$4)
|
||||
yyerror("MenuEx must contain items");
|
||||
$$ = new_menuex();
|
||||
$$ = new_menu();
|
||||
$$->is_ex = TRUE;
|
||||
if($2)
|
||||
{
|
||||
$$->memopt = *($2);
|
||||
|
@ -1317,7 +1303,7 @@ menuex : tMENUEX loadmemopts opt_lvc menuex_body {
|
|||
}
|
||||
else
|
||||
$$->memopt = WRC_MO_MOVEABLE | WRC_MO_PURE | WRC_MO_DISCARDABLE;
|
||||
$$->items = get_itemex_head($4);
|
||||
$$->items = get_item_head($4);
|
||||
if($3)
|
||||
{
|
||||
$$->lvc = *($3);
|
||||
|
@ -1335,7 +1321,7 @@ menuex_body
|
|||
itemex_definitions
|
||||
: /* Empty */ {$$ = NULL; }
|
||||
| itemex_definitions tMENUITEM tSTRING itemex_options {
|
||||
$$ = new_menuex_item();
|
||||
$$ = new_menu_item();
|
||||
$$->prev = $1;
|
||||
if($1)
|
||||
$1->next = $$;
|
||||
|
@ -1351,17 +1337,17 @@ itemex_definitions
|
|||
free($4);
|
||||
}
|
||||
| itemex_definitions tMENUITEM tSEPARATOR {
|
||||
$$ = new_menuex_item();
|
||||
$$ = new_menu_item();
|
||||
$$->prev = $1;
|
||||
if($1)
|
||||
$1->next = $$;
|
||||
}
|
||||
| itemex_definitions tPOPUP tSTRING itemex_p_options menuex_body {
|
||||
$$ = new_menuex_item();
|
||||
$$ = new_menu_item();
|
||||
$$->prev = $1;
|
||||
if($1)
|
||||
$1->next = $$;
|
||||
$$->popup = get_itemex_head($5);
|
||||
$$->popup = get_item_head($5);
|
||||
$$->name = $3;
|
||||
$$->id = $4->id;
|
||||
$$->type = $4->type;
|
||||
|
@ -1723,15 +1709,22 @@ loadmemopts
|
|||
}
|
||||
;
|
||||
|
||||
lamo : tPRELOAD { $$ = new_int(WRC_MO_PRELOAD); }
|
||||
| tMOVEABLE { $$ = new_int(WRC_MO_MOVEABLE); }
|
||||
| tDISCARDABLE { $$ = new_int(WRC_MO_DISCARDABLE); }
|
||||
| tPURE { $$ = new_int(WRC_MO_PURE); }
|
||||
lamo : tPRELOAD { $$ = new_int(WRC_MO_PRELOAD);
|
||||
if (win32 && pedantic) parser_warning("PRELOAD is ignored in 32-bit mode\n"); }
|
||||
| tMOVEABLE { $$ = new_int(WRC_MO_MOVEABLE);
|
||||
if (win32 && pedantic) parser_warning("MOVEABLE is ignored in 32-bit mode\n"); }
|
||||
| tDISCARDABLE { $$ = new_int(WRC_MO_DISCARDABLE);
|
||||
if (win32 && pedantic) parser_warning("DISCARDABLE is ignored in 32-bit mode\n"); }
|
||||
| tPURE { $$ = new_int(WRC_MO_PURE);
|
||||
if (win32 && pedantic) parser_warning("PURE is ignored in 32-bit mode\n"); }
|
||||
;
|
||||
|
||||
lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD); }
|
||||
| tFIXED { $$ = new_int(~WRC_MO_MOVEABLE); }
|
||||
| tIMPURE { $$ = new_int(~WRC_MO_PURE); }
|
||||
lama : tLOADONCALL { $$ = new_int(~WRC_MO_PRELOAD);
|
||||
if (win32 && pedantic) parser_warning("LOADONCALL is ignored in 32-bit mode\n"); }
|
||||
| tFIXED { $$ = new_int(~WRC_MO_MOVEABLE);
|
||||
if (win32 && pedantic) parser_warning("FIXED is ignored in 32-bit mode\n"); }
|
||||
| tIMPURE { $$ = new_int(~WRC_MO_PURE);
|
||||
if (win32 && pedantic) parser_warning("IMPURE is ignored in 32-bit mode\n"); }
|
||||
;
|
||||
|
||||
/* ------------------------------ Win32 options ------------------------------ */
|
||||
|
@ -2163,118 +2156,6 @@ static name_id_t *convert_ctlclass(name_id_t *cls)
|
|||
return cls;
|
||||
}
|
||||
|
||||
/* DialogEx specific functions */
|
||||
static dialogex_t *dialogex_style(style_t * st, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->style == NULL)
|
||||
{
|
||||
dlg->style = new_style(0,0);
|
||||
}
|
||||
|
||||
if(dlg->gotstyle)
|
||||
{
|
||||
parser_warning("Style already defined, or-ing together\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg->style->or_mask = 0;
|
||||
dlg->style->and_mask = 0;
|
||||
}
|
||||
dlg->style->or_mask |= st->or_mask;
|
||||
dlg->style->and_mask |= st->and_mask;
|
||||
dlg->gotstyle = TRUE;
|
||||
free(st);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_exstyle(style_t * st, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->exstyle == NULL)
|
||||
{
|
||||
dlg->exstyle = new_style(0,0);
|
||||
}
|
||||
|
||||
if(dlg->gotexstyle)
|
||||
{
|
||||
parser_warning("ExStyle already defined, or-ing together\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
dlg->exstyle->or_mask = 0;
|
||||
dlg->exstyle->and_mask = 0;
|
||||
}
|
||||
dlg->exstyle->or_mask |= st->or_mask;
|
||||
dlg->exstyle->and_mask |= st->and_mask;
|
||||
dlg->gotexstyle = TRUE;
|
||||
free(st);
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_caption(string_t *s, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->title)
|
||||
yyerror("Caption already defined");
|
||||
dlg->title = s;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_font(font_id_t *f, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->font)
|
||||
yyerror("Font already defined");
|
||||
dlg->font = f;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_class(name_id_t *n, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->dlgclass)
|
||||
yyerror("Class already defined");
|
||||
dlg->dlgclass = n;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_menu(name_id_t *m, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->menu)
|
||||
yyerror("Menu already defined");
|
||||
dlg->menu = m;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_language(language_t *l, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->lvc.language)
|
||||
yyerror("Language already defined");
|
||||
dlg->lvc.language = l;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_characteristics(characts_t *c, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->lvc.characts)
|
||||
yyerror("Characteristics already defined");
|
||||
dlg->lvc.characts = c;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
static dialogex_t *dialogex_version(version_t *v, dialogex_t *dlg)
|
||||
{
|
||||
assert(dlg != NULL);
|
||||
if(dlg->lvc.version)
|
||||
yyerror("Version already defined");
|
||||
dlg->lvc.version = v;
|
||||
return dlg;
|
||||
}
|
||||
|
||||
/* Accelerator specific functions */
|
||||
static event_t *add_event(int key, int id, int flags, event_t *prev)
|
||||
{
|
||||
|
@ -2299,7 +2180,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
|
|||
|
||||
if(key->type == str_char)
|
||||
{
|
||||
if((flags & WRC_AF_VIRTKEY) && (!isupper(key->str.cstr[0] & 0xff) && !isdigit(key->str.cstr[0] & 0xff)))
|
||||
if((flags & WRC_AF_VIRTKEY) &&
|
||||
!((key->str.cstr[0] >= 'A' && key->str.cstr[0] <= 'Z') ||
|
||||
(key->str.cstr[0] >= '0' && key->str.cstr[0] <= '9')))
|
||||
yyerror("VIRTKEY code is not equal to ascii value");
|
||||
|
||||
if(key->str.cstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
|
||||
|
@ -2308,7 +2191,7 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
|
|||
}
|
||||
else if(key->str.cstr[0] == '^')
|
||||
{
|
||||
keycode = toupper(key->str.cstr[1]) - '@';
|
||||
keycode = toupper((unsigned char)key->str.cstr[1]) - '@';
|
||||
if(keycode >= ' ')
|
||||
yyerror("Control-code out of range");
|
||||
}
|
||||
|
@ -2317,7 +2200,9 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev
|
|||
}
|
||||
else
|
||||
{
|
||||
if((flags & WRC_AF_VIRTKEY) && !isupperW(key->str.wstr[0]) && !isdigitW(key->str.wstr[0]))
|
||||
if((flags & WRC_AF_VIRTKEY) &&
|
||||
!((key->str.wstr[0] >= 'A' && key->str.wstr[0] <= 'Z') ||
|
||||
(key->str.wstr[0] >= '0' && key->str.wstr[0] <= '9')))
|
||||
yyerror("VIRTKEY code is not equal to ascii value");
|
||||
|
||||
if(key->str.wstr[0] == '^' && (flags & WRC_AF_CONTROL) != 0)
|
||||
|
@ -2537,15 +2422,6 @@ static menu_item_t *get_item_head(menu_item_t *p)
|
|||
return p;
|
||||
}
|
||||
|
||||
static menuex_item_t *get_itemex_head(menuex_item_t *p)
|
||||
{
|
||||
if(!p)
|
||||
return NULL;
|
||||
while(p->prev)
|
||||
p = p->prev;
|
||||
return p;
|
||||
}
|
||||
|
||||
static resource_t *get_resource_head(resource_t *p)
|
||||
{
|
||||
if(!p)
|
||||
|
@ -3001,7 +2877,6 @@ clean:
|
|||
static int rsrcid_to_token(int lookahead)
|
||||
{
|
||||
int token;
|
||||
const char *type = "?";
|
||||
|
||||
/* Get a token if we don't have one yet */
|
||||
if(lookahead == YYEMPTY)
|
||||
|
@ -3022,64 +2897,49 @@ static int rsrcid_to_token(int lookahead)
|
|||
switch(yylval.num)
|
||||
{
|
||||
case WRC_RT_CURSOR:
|
||||
type = "CURSOR";
|
||||
token = tCURSOR;
|
||||
break;
|
||||
case WRC_RT_ICON:
|
||||
type = "ICON";
|
||||
token = tICON;
|
||||
break;
|
||||
case WRC_RT_BITMAP:
|
||||
type = "BITMAP";
|
||||
token = tBITMAP;
|
||||
break;
|
||||
case WRC_RT_FONT:
|
||||
type = "FONT";
|
||||
token = tFONT;
|
||||
break;
|
||||
case WRC_RT_FONTDIR:
|
||||
type = "FONTDIR";
|
||||
token = tFONTDIR;
|
||||
break;
|
||||
case WRC_RT_RCDATA:
|
||||
type = "RCDATA";
|
||||
token = tRCDATA;
|
||||
break;
|
||||
case WRC_RT_MESSAGETABLE:
|
||||
type = "MESSAGETABLE";
|
||||
token = tMESSAGETABLE;
|
||||
break;
|
||||
case WRC_RT_DLGINIT:
|
||||
type = "DLGINIT";
|
||||
token = tDLGINIT;
|
||||
break;
|
||||
case WRC_RT_ACCELERATOR:
|
||||
type = "ACCELERATOR";
|
||||
token = tACCELERATORS;
|
||||
break;
|
||||
case WRC_RT_MENU:
|
||||
type = "MENU";
|
||||
token = tMENU;
|
||||
break;
|
||||
case WRC_RT_DIALOG:
|
||||
type = "DIALOG";
|
||||
token = tDIALOG;
|
||||
break;
|
||||
case WRC_RT_VERSION:
|
||||
type = "VERSION";
|
||||
token = tVERSIONINFO;
|
||||
break;
|
||||
case WRC_RT_TOOLBAR:
|
||||
type = "TOOLBAR";
|
||||
token = tTOOLBAR;
|
||||
break;
|
||||
case WRC_RT_HTML:
|
||||
type = "HTML";
|
||||
token = tHTML;
|
||||
break;
|
||||
|
||||
case WRC_RT_STRING:
|
||||
type = "STRINGTABLE";
|
||||
break;
|
||||
|
||||
case WRC_RT_ANICURSOR:
|
||||
|
|
1016
reactos/tools/wrc/po.c
Normal file
1016
reactos/tools/wrc/po.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -47,8 +47,6 @@ static language_t get_language(resource_t *resource) {
|
|||
return *resource->res.curg->lvc.language;
|
||||
case res_dlg:
|
||||
return *resource->res.dlg->lvc.language;
|
||||
case res_dlgex:
|
||||
return *resource->res.dlgex->lvc.language;
|
||||
case res_fnt:
|
||||
return *resource->res.fnt->data->lvc.language;
|
||||
case res_fntdir:
|
||||
|
@ -59,8 +57,6 @@ static language_t get_language(resource_t *resource) {
|
|||
return *resource->res.icog->lvc.language;
|
||||
case res_men:
|
||||
return *resource->res.men->lvc.language;
|
||||
case res_menex:
|
||||
return *resource->res.menex->lvc.language;
|
||||
case res_rdt:
|
||||
return *resource->res.rdt->data->lvc.language;
|
||||
case res_stt:
|
||||
|
@ -358,6 +354,13 @@ static int compare_dialog(dialog_t *dialog1, dialog_t *dialog2) {
|
|||
((dialog1->gotexstyle && !dialog2->gotexstyle) ||
|
||||
(!dialog1->gotexstyle && dialog2->gotexstyle)))
|
||||
different = 1;
|
||||
if(!different && dialog1->gothelpid && dialog2->gothelpid) {
|
||||
if(dialog1->helpid != dialog2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((dialog1->gothelpid && !dialog2->gothelpid) ||
|
||||
(!dialog1->gothelpid && dialog2->gothelpid)))
|
||||
different = 1;
|
||||
nameid = strdup(get_nameid_str(dialog1->menu));
|
||||
if(!different && strcmp(nameid, get_nameid_str(dialog2->menu)))
|
||||
different = 1;
|
||||
|
@ -378,60 +381,6 @@ static int compare_dialog(dialog_t *dialog1, dialog_t *dialog2) {
|
|||
return different;
|
||||
}
|
||||
|
||||
static int compare_dialogex(dialogex_t *dialogex1, dialogex_t *dialogex2) {
|
||||
int different = 0;
|
||||
char *nameid = NULL;
|
||||
control_t *ctrl1, *ctrl2;
|
||||
if(!different &&
|
||||
((dialogex1->memopt != dialogex2->memopt) ||
|
||||
(dialogex1->lvc.version != dialogex2->lvc.version) ||
|
||||
(dialogex1->lvc.characts != dialogex2->lvc.characts)))
|
||||
different = 1;
|
||||
if(!different && dialogex1->gotstyle && dialogex2->gotstyle) {
|
||||
if((!dialogex1->style || !dialogex2->style) ||
|
||||
(dialogex1->style->and_mask || dialogex2->style->and_mask) ||
|
||||
(dialogex1->style->or_mask != dialogex2->style->or_mask))
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((dialogex1->gotstyle && !dialogex2->gotstyle) ||
|
||||
(!dialogex1->gotstyle && dialogex2->gotstyle)))
|
||||
different = 1;
|
||||
if(!different && dialogex1->gotexstyle && dialogex2->gotexstyle) {
|
||||
if((!dialogex1->exstyle || !dialogex2->exstyle) ||
|
||||
(dialogex1->exstyle->and_mask || dialogex2->exstyle->and_mask) ||
|
||||
(dialogex1->exstyle->or_mask != dialogex2->exstyle->or_mask))
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((dialogex1->gotexstyle && !dialogex2->gotexstyle) ||
|
||||
(!dialogex1->gotexstyle && dialogex2->gotexstyle)))
|
||||
different = 1;
|
||||
if(!different && dialogex1->gothelpid && dialogex2->gothelpid) {
|
||||
if(dialogex1->helpid != dialogex2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((dialogex1->gothelpid && !dialogex2->gothelpid) ||
|
||||
(!dialogex1->gothelpid && dialogex2->gothelpid)))
|
||||
different = 1;
|
||||
nameid = strdup(get_nameid_str(dialogex1->menu));
|
||||
if(!different && strcmp(nameid, get_nameid_str(dialogex2->menu)))
|
||||
different = 1;
|
||||
free(nameid);
|
||||
nameid = strdup(get_nameid_str(dialogex1->dlgclass));
|
||||
if(!different && strcmp(nameid, get_nameid_str(dialogex2->dlgclass)))
|
||||
different = 1;
|
||||
free(nameid);
|
||||
|
||||
ctrl1 = dialogex1->controls;
|
||||
ctrl2 = dialogex2->controls;
|
||||
while(!different && (ctrl1 || ctrl2))
|
||||
{
|
||||
different = compare_control(ctrl1, ctrl2);
|
||||
if (ctrl1) ctrl1 = ctrl1->next;
|
||||
if (ctrl2) ctrl2 = ctrl2->next;
|
||||
}
|
||||
return different;
|
||||
}
|
||||
|
||||
static int compare_font(font_t *font1, font_t *font2) {
|
||||
int different = 0;
|
||||
if(!different &&
|
||||
|
@ -496,13 +445,67 @@ static int compare_icon_group(icon_group_t *icon_group1, icon_group_t *icon_grou
|
|||
static int compare_menu_item(menu_item_t *menu_item1, menu_item_t *menu_item2) {
|
||||
int different = 0;
|
||||
while(!different && menu_item1 && menu_item2) {
|
||||
if(menu_item1->popup && menu_item2->popup)
|
||||
different = compare_menu_item(menu_item1->popup, menu_item2->popup);
|
||||
else if(!menu_item1->popup && !menu_item2->popup) {
|
||||
if(menu_item1->name && menu_item2->name) {
|
||||
if((menu_item1->id != menu_item2->id) ||
|
||||
(menu_item1->state != menu_item2->state))
|
||||
if(menu_item1->popup && menu_item2->popup) {
|
||||
if(!different && menu_item1->gotid && menu_item2->gotid) {
|
||||
if(menu_item1->id != menu_item2->id)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gotid && !menu_item2->gotid) ||
|
||||
(!menu_item1->gotid && menu_item2->gotid)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gottype && menu_item2->gottype) {
|
||||
if(menu_item1->type != menu_item2->type)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gottype && !menu_item2->gottype) ||
|
||||
(!menu_item1->gottype && menu_item2->gottype)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gotstate && menu_item2->gotstate) {
|
||||
if(menu_item1->state != menu_item2->state)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gotstate && !menu_item2->gotstate) ||
|
||||
(!menu_item1->gotstate && menu_item2->gotstate)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gothelpid && menu_item2->gothelpid) {
|
||||
if(menu_item1->helpid != menu_item2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gothelpid && !menu_item2->gothelpid) ||
|
||||
(!menu_item1->gothelpid && menu_item2->gothelpid)))
|
||||
different = 1;
|
||||
if(!different)
|
||||
different = compare_menu_item(menu_item1->popup, menu_item2->popup);
|
||||
} else if(!menu_item1->popup && !menu_item2->popup) {
|
||||
if(menu_item1->name && menu_item2->name) {
|
||||
if(!different && menu_item1->gotid && menu_item2->gotid) {
|
||||
if(menu_item1->id != menu_item2->id)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gotid && !menu_item2->gotid) ||
|
||||
(!menu_item1->gotid && menu_item2->gotid)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gottype && menu_item2->gottype) {
|
||||
if(menu_item1->type != menu_item2->type)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gottype && !menu_item2->gottype) ||
|
||||
(!menu_item1->gottype && menu_item2->gottype)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gotstate && menu_item2->gotstate) {
|
||||
if(menu_item1->state != menu_item2->state)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gotstate && !menu_item2->gotstate) ||
|
||||
(!menu_item1->gotstate && menu_item2->gotstate)))
|
||||
different = 1;
|
||||
if(!different && menu_item1->gothelpid && menu_item2->gothelpid) {
|
||||
if(menu_item1->helpid != menu_item2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menu_item1->gothelpid && !menu_item2->gothelpid) ||
|
||||
(!menu_item1->gothelpid && menu_item2->gothelpid)))
|
||||
different = 1;
|
||||
} else if((menu_item1->name && !menu_item2->name) ||
|
||||
(!menu_item1->name && menu_item2->name))
|
||||
different = 1;
|
||||
|
@ -530,97 +533,6 @@ static int compare_menu(menu_t *menu1, menu_t *menu2) {
|
|||
return different;
|
||||
}
|
||||
|
||||
static int compare_menuex_item(menuex_item_t *menuex_item1, menuex_item_t *menuex_item2) {
|
||||
int different = 0;
|
||||
while(!different && menuex_item1 && menuex_item2) {
|
||||
if(menuex_item1->popup && menuex_item2->popup) {
|
||||
if(!different && menuex_item1->gotid && menuex_item2->gotid) {
|
||||
if(menuex_item1->id != menuex_item2->id)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gotid && !menuex_item2->gotid) ||
|
||||
(!menuex_item2->gotid && menuex_item2->gotid)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gottype && menuex_item2->gottype) {
|
||||
if(menuex_item1->type != menuex_item2->type)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gottype && !menuex_item2->gottype) ||
|
||||
(!menuex_item2->gottype && menuex_item2->gottype)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gotstate && menuex_item2->gotstate) {
|
||||
if(menuex_item1->state != menuex_item2->state)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gotstate && !menuex_item2->gotstate) ||
|
||||
(!menuex_item2->gotstate && menuex_item2->gotstate)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gothelpid && menuex_item2->gothelpid) {
|
||||
if(menuex_item1->helpid != menuex_item2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gothelpid && !menuex_item2->gothelpid) ||
|
||||
(!menuex_item2->gothelpid && menuex_item2->gothelpid)))
|
||||
different = 1;
|
||||
if(!different)
|
||||
different = compare_menuex_item(menuex_item1->popup, menuex_item2->popup);
|
||||
} else if(!menuex_item1->popup && !menuex_item2->popup) {
|
||||
if(menuex_item1->name && menuex_item2->name) {
|
||||
if(!different && menuex_item1->gotid && menuex_item2->gotid) {
|
||||
if(menuex_item1->id != menuex_item2->id)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gotid && !menuex_item2->gotid) ||
|
||||
(!menuex_item2->gotid && menuex_item2->gotid)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gottype && menuex_item2->gottype) {
|
||||
if(menuex_item1->type != menuex_item2->type)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gottype && !menuex_item2->gottype) ||
|
||||
(!menuex_item2->gottype && menuex_item2->gottype)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gotstate && menuex_item2->gotstate) {
|
||||
if(menuex_item1->state != menuex_item2->state)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gotstate && !menuex_item2->gotstate) ||
|
||||
(!menuex_item2->gotstate && menuex_item2->gotstate)))
|
||||
different = 1;
|
||||
if(!different && menuex_item1->gothelpid && menuex_item2->gothelpid) {
|
||||
if(menuex_item1->helpid != menuex_item2->helpid)
|
||||
different = 1;
|
||||
} else if(!different &&
|
||||
((menuex_item1->gothelpid && !menuex_item2->gothelpid) ||
|
||||
(!menuex_item2->gothelpid && menuex_item2->gothelpid)))
|
||||
different = 1;
|
||||
} else if((menuex_item1->name && !menuex_item2->name) ||
|
||||
(!menuex_item1->name && menuex_item2->name))
|
||||
different = 1;
|
||||
} else
|
||||
different = 1;
|
||||
menuex_item1 = menuex_item1->next;
|
||||
menuex_item2 = menuex_item2->next;
|
||||
}
|
||||
if(!different &&
|
||||
((menuex_item1 && !menuex_item2) ||
|
||||
(!menuex_item1 && menuex_item2)))
|
||||
different = 1;
|
||||
return different;
|
||||
}
|
||||
|
||||
static int compare_menuex(menuex_t *menuex1, menuex_t *menuex2) {
|
||||
int different = 0;
|
||||
if(!different &&
|
||||
((menuex1->memopt != menuex2->memopt) ||
|
||||
(menuex1->lvc.version != menuex2->lvc.version) ||
|
||||
(menuex1->lvc.characts != menuex2->lvc.characts)))
|
||||
different = 1;
|
||||
if(!different)
|
||||
different = compare_menuex_item(menuex1->items, menuex2->items);
|
||||
return different;
|
||||
}
|
||||
|
||||
static int compare_rcdata(rcdata_t *rcdata1, rcdata_t *rcdata2) {
|
||||
int different = 0;
|
||||
if(!different &&
|
||||
|
@ -924,8 +836,6 @@ static int compare(resource_t *resource1, resource_t *resource2) {
|
|||
return compare_cursor_group(resource1->res.curg, resource2->res.curg);
|
||||
case res_dlg:
|
||||
return compare_dialog(resource1->res.dlg, resource2->res.dlg);
|
||||
case res_dlgex:
|
||||
return compare_dialogex(resource1->res.dlgex, resource2->res.dlgex);
|
||||
case res_fnt:
|
||||
return compare_font(resource1->res.fnt, resource2->res.fnt);
|
||||
case res_fntdir:
|
||||
|
@ -936,8 +846,6 @@ static int compare(resource_t *resource1, resource_t *resource2) {
|
|||
return compare_icon_group(resource1->res.icog, resource2->res.icog);
|
||||
case res_men:
|
||||
return compare_menu(resource1->res.men, resource2->res.men);
|
||||
case res_menex:
|
||||
return compare_menuex(resource1->res.menex, resource2->res.menex);
|
||||
case res_rdt:
|
||||
return compare_rcdata(resource1->res.rdt, resource2->res.rdt);
|
||||
case res_stt:
|
||||
|
@ -979,7 +887,7 @@ typedef struct resource_id_node
|
|||
struct resource_id_node *next;
|
||||
} resource_id_node_t;
|
||||
|
||||
struct
|
||||
static struct
|
||||
{
|
||||
int enabled;
|
||||
struct resource_id_node *ids;
|
||||
|
@ -1034,13 +942,11 @@ static void setup_tabs(void)
|
|||
case res_cur:
|
||||
case res_curg:
|
||||
case res_dlg:
|
||||
case res_dlgex:
|
||||
case res_fnt:
|
||||
case res_fntdir:
|
||||
case res_ico:
|
||||
case res_icog:
|
||||
case res_men:
|
||||
case res_menex:
|
||||
case res_rdt:
|
||||
case res_stt:
|
||||
case res_usr:
|
||||
|
@ -1077,7 +983,7 @@ static resource_t *find_main(int type, name_id_t *id, resource_lang_node_t *lang
|
|||
|
||||
if (neutral != NULL && (en != NULL || en_US != NULL))
|
||||
{
|
||||
fprintf(stderr, "INFO: Resource %04x/%s has both NEUTRAL and MASTER language translarion\n",
|
||||
fprintf(stderr, "INFO: Resource %04x/%s has both NEUTRAL and MASTER language translation\n",
|
||||
type, get_nameid_str(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -192,6 +192,25 @@ void *xrealloc(void *p, size_t size)
|
|||
return res;
|
||||
}
|
||||
|
||||
char *strmake( const char* fmt, ... )
|
||||
{
|
||||
int n;
|
||||
size_t size = 100;
|
||||
va_list ap;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
char *p = xmalloc( size );
|
||||
va_start( ap, fmt );
|
||||
n = vsnprintf( p, size, fmt, ap );
|
||||
va_end( ap );
|
||||
if (n == -1) size *= 2;
|
||||
else if ((size_t)n >= size) size = n + 1;
|
||||
else return p;
|
||||
free( p );
|
||||
}
|
||||
}
|
||||
|
||||
char *xstrdup(const char *str)
|
||||
{
|
||||
char *s;
|
||||
|
@ -252,6 +271,8 @@ string_t *convert_string(const string_t *str, enum str_e type, int codepage)
|
|||
string_t *ret = xmalloc(sizeof(*ret));
|
||||
int res;
|
||||
|
||||
ret->loc = str->loc;
|
||||
|
||||
if (!codepage && str->type != type)
|
||||
parser_error( "Current language is Unicode only, cannot convert string" );
|
||||
|
||||
|
@ -367,7 +388,7 @@ struct lang2cp
|
|||
unsigned short lang;
|
||||
unsigned short sublang;
|
||||
unsigned int cp;
|
||||
} lang2cp_t;
|
||||
};
|
||||
|
||||
/* language to codepage conversion table */
|
||||
/* specific sublanguages need only be specified if their codepage */
|
||||
|
@ -376,14 +397,19 @@ static const struct lang2cp lang2cps[] =
|
|||
{
|
||||
{ LANG_AFRIKAANS, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ALBANIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_ALSATIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_AMHARIC, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_ARABIC, SUBLANG_NEUTRAL, 1256 },
|
||||
{ LANG_ARMENIAN, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_ASSAMESE, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_AZERI, SUBLANG_NEUTRAL, 1254 },
|
||||
{ LANG_AZERI, SUBLANG_AZERI_CYRILLIC, 1251 },
|
||||
{ LANG_BASHKIR, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_BASQUE, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_BELARUSIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_BENGALI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_BOSNIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_BOSNIAN, SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC, 1251 },
|
||||
{ LANG_BRETON, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_BULGARIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_CATALAN, SUBLANG_NEUTRAL, 1252 },
|
||||
|
@ -393,9 +419,11 @@ static const struct lang2cp lang2cps[] =
|
|||
#ifdef LANG_CORNISH
|
||||
{ LANG_CORNISH, SUBLANG_NEUTRAL, 1252 },
|
||||
#endif /* LANG_CORNISH */
|
||||
{ LANG_CORSICAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_CROATIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_CZECH, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_DANISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_DARI, SUBLANG_NEUTRAL, 1256 },
|
||||
{ LANG_DIVEHI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_DUTCH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ENGLISH, SUBLANG_NEUTRAL, 1252 },
|
||||
|
@ -404,9 +432,10 @@ static const struct lang2cp lang2cps[] =
|
|||
#endif /* LANG_ESPERANTO */
|
||||
{ LANG_ESTONIAN, SUBLANG_NEUTRAL, 1257 },
|
||||
{ LANG_FAEROESE, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_FARSI, SUBLANG_NEUTRAL, 1256 },
|
||||
{ LANG_FILIPINO, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_FINNISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_FRENCH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_FRISIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
#ifdef LANG_GAELIC
|
||||
{ LANG_GAELIC, SUBLANG_NEUTRAL, 1252 },
|
||||
#endif /* LANG_GAELIC */
|
||||
|
@ -414,36 +443,53 @@ static const struct lang2cp lang2cps[] =
|
|||
{ LANG_GEORGIAN, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_GERMAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_GREEK, SUBLANG_NEUTRAL, 1253 },
|
||||
{ LANG_GREENLANDIC, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_GUJARATI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_HAUSA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_HEBREW, SUBLANG_NEUTRAL, 1255 },
|
||||
{ LANG_HINDI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_HUNGARIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_ICELANDIC, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_IGBO, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_INDONESIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_INUKTITUT, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_INUKTITUT, SUBLANG_INUKTITUT_CANADA_LATIN, 0 },
|
||||
{ LANG_IRISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ITALIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_JAPANESE, SUBLANG_NEUTRAL, 932 },
|
||||
{ LANG_KANNADA, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_KAZAK, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_KHMER, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_KICHE, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_KINYARWANDA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_KONKANI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_KOREAN, SUBLANG_NEUTRAL, 949 },
|
||||
{ LANG_KYRGYZ, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_LAO, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_LATVIAN, SUBLANG_NEUTRAL, 1257 },
|
||||
{ LANG_LITHUANIAN, SUBLANG_NEUTRAL, 1257 },
|
||||
{ LANG_LOWER_SORBIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_LUXEMBOURGISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_MACEDONIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_MALAY, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_MALAYALAM, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_MALTESE, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_MAORI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_MAPUDUNGUN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_MARATHI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_MOHAWK, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_MONGOLIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_NEPALI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_NEUTRAL, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_NORWEGIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_OCCITAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ORIYA, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_PASHTO, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_PERSIAN, SUBLANG_NEUTRAL, 1256 },
|
||||
{ LANG_POLISH, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_PORTUGUESE, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_PUNJABI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_QUECHUA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ROMANIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_ROMANSH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_RUSSIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
|
@ -451,19 +497,25 @@ static const struct lang2cp lang2cps[] =
|
|||
{ LANG_SANSKRIT, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_SERBIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_SERBIAN, SUBLANG_SERBIAN_CYRILLIC, 1251 },
|
||||
{ LANG_SINHALESE, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_SLOVAK, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_SLOVENIAN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_SOTHO, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_SPANISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_SWAHILI, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_SWEDISH, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_SYRIAC, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_TAJIK, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_TAMAZIGHT, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_TAMIL, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_TATAR, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_TELUGU, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_THAI, SUBLANG_NEUTRAL, 874 },
|
||||
{ LANG_TIBETAN, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_TSWANA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_TURKISH, SUBLANG_NEUTRAL, 1254 },
|
||||
{ LANG_TURKMEN, SUBLANG_NEUTRAL, 1250 },
|
||||
{ LANG_UIGHUR, SUBLANG_NEUTRAL, 1256 },
|
||||
{ LANG_UKRAINIAN, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_UPPER_SORBIAN, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_URDU, SUBLANG_NEUTRAL, 1256 },
|
||||
|
@ -473,10 +525,12 @@ static const struct lang2cp lang2cps[] =
|
|||
#ifdef LANG_WALON
|
||||
{ LANG_WALON, SUBLANG_NEUTRAL, 1252 },
|
||||
#endif /* LANG_WALON */
|
||||
#ifdef LANG_WELSH
|
||||
{ LANG_WELSH, SUBLANG_NEUTRAL, 1252 },
|
||||
#endif
|
||||
{ LANG_WOLOF, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_XHOSA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_YAKUT, SUBLANG_NEUTRAL, 1251 },
|
||||
{ LANG_YI, SUBLANG_NEUTRAL, 0 },
|
||||
{ LANG_YORUBA, SUBLANG_NEUTRAL, 1252 },
|
||||
{ LANG_ZULU, SUBLANG_NEUTRAL, 1252 }
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ char *xstrdup(const char *str);
|
|||
#define __attribute__(X)
|
||||
#endif
|
||||
|
||||
char *strmake(const char* fmt, ...) __attribute__((__format__ (__printf__, 1, 2 )));
|
||||
int parser_error(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
int parser_warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
|
||||
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn));
|
||||
|
|
|
@ -44,10 +44,6 @@
|
|||
#include "parser.h"
|
||||
#include "wine/wpp.h"
|
||||
|
||||
#ifndef INCLUDEDIR
|
||||
#define INCLUDEDIR "/usr/local/include/wine"
|
||||
#endif
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define ENDIAN "big"
|
||||
#else
|
||||
|
@ -56,41 +52,33 @@
|
|||
|
||||
static const char usage[] =
|
||||
"Usage: wrc [options...] [infile[.rc|.res]]\n"
|
||||
" -D id[=val] Define preprocessor identifier id=val\n"
|
||||
" -E Preprocess only\n"
|
||||
" -F target Ignored for compatibility with windres\n"
|
||||
" -h Prints this summary\n"
|
||||
" -i file The name of the input file\n"
|
||||
" -I path Set include search dir to path (multiple -I allowed)\n"
|
||||
" -J format The input format (either `rc' or `rc16')\n"
|
||||
" -l lan Set default language to lan (default is neutral {0, 0})\n"
|
||||
" -o file Output to file (default is infile.res)\n"
|
||||
" -O format The output format (either `res' or `res16`)\n"
|
||||
" -r Ignored for compatibility with rc\n"
|
||||
" -U id Undefine preprocessor identifier id\n"
|
||||
" -v Enable verbose mode\n"
|
||||
"The following long options are supported:\n"
|
||||
" --debug=nn Set debug level to 'nn'\n"
|
||||
" --define Synonym for -D\n"
|
||||
" --endianess=e Set output byte-order e={n[ative], l[ittle], b[ig]}\n"
|
||||
" (win32 only; default is " ENDIAN "-endian)\n"
|
||||
" --help Synonym for -h\n"
|
||||
" --include-dir Synonym for -I\n"
|
||||
" --input Synonym for -i\n"
|
||||
" --input-format Synonym for -J\n"
|
||||
" --language Synonym for -l\n"
|
||||
" --no-use-temp-file Ignored for compatibility with windres\n"
|
||||
" --nostdinc Disables searching the standard include path\n"
|
||||
" --output -fo Synonym for -o\n"
|
||||
" --output-format Synonym for -O\n"
|
||||
" --pedantic Enable pedantic warnings\n"
|
||||
" --preprocessor Specifies the preprocessor to use, including arguments\n"
|
||||
" --target Synonym for -F\n"
|
||||
" --undefine Synonym for -U\n"
|
||||
" --use-temp-file Ignored for compatibility with windres\n"
|
||||
" --verbose Synonym for -v\n"
|
||||
" --verify-translations Check the status of the various translations\n"
|
||||
" --version Print version and exit\n"
|
||||
" -b, --target=TARGET Specify target CPU and platform when cross-compiling\n"
|
||||
" -D, --define id[=val] Define preprocessor identifier id=val\n"
|
||||
" --debug=nn Set debug level to 'nn'\n"
|
||||
" -E Preprocess only\n"
|
||||
" --endianess=e Set output byte-order e={n[ative], l[ittle], b[ig]}\n"
|
||||
" (win32 only; default is " ENDIAN "-endian)\n"
|
||||
" -F TARGET Synonym for -b for compatibility with windres\n"
|
||||
" -fo FILE Synonym for -o for compatibility with windres\n"
|
||||
" -h, --help Prints this summary\n"
|
||||
" -i, --input=FILE The name of the input file\n"
|
||||
" -I, --include-dir=PATH Set include search dir to path (multiple -I allowed)\n"
|
||||
" -J, --input-format=FORMAT The input format (either `rc' or `rc16')\n"
|
||||
" -l, --language=LANG Set default language to LANG (default is neutral {0, 0})\n"
|
||||
" -m16, -m32, -m64 Build for 16-bit, 32-bit resp. 64-bit platforms\n"
|
||||
" --no-use-temp-file Ignored for compatibility with windres\n"
|
||||
" --nostdinc Disables searching the standard include path\n"
|
||||
" -o, --output=FILE Output to file (default is infile.res)\n"
|
||||
" -O, --output-format=FORMAT The output format (`po', `pot', `res', or `res16`)\n"
|
||||
" --pedantic Enable pedantic warnings\n"
|
||||
" --po-dir=DIR Directory containing po files for translations\n"
|
||||
" --preprocessor Specifies the preprocessor to use, including arguments\n"
|
||||
" -r Ignored for compatibility with rc\n"
|
||||
" -U, --undefine id Undefine preprocessor identifier id\n"
|
||||
" --use-temp-file Ignored for compatibility with windres\n"
|
||||
" -v, --verbose Enable verbose mode\n"
|
||||
" --verify-translations Check the status of the various translations\n"
|
||||
" --version Print version and exit\n"
|
||||
"Input is taken from stdin if no sourcefile specified.\n"
|
||||
"Debug level 'n' is a bitmask with following meaning:\n"
|
||||
" * 0x01 Tell which resource is parsed (verbose mode)\n"
|
||||
|
@ -157,11 +145,13 @@ int no_preprocess = 0;
|
|||
|
||||
int check_utf8 = 1; /* whether to check for valid utf8 */
|
||||
|
||||
static int pointer_size = sizeof(void *);
|
||||
|
||||
static int verify_translations_mode;
|
||||
|
||||
char *output_name = NULL; /* The name given by the -o option */
|
||||
static char *output_name; /* The name given by the -o option */
|
||||
char *input_name = NULL; /* The name given on the command-line */
|
||||
char *temp_name = NULL; /* Temporary file for preprocess pipe */
|
||||
static char *temp_name = NULL; /* Temporary file for preprocess pipe */
|
||||
|
||||
int line_number = 1; /* The current line */
|
||||
int char_number = 1; /* The current char pos within the line */
|
||||
|
@ -182,6 +172,7 @@ enum long_options_values
|
|||
LONG_OPT_NOSTDINC = 1,
|
||||
LONG_OPT_TMPFILE,
|
||||
LONG_OPT_NOTMPFILE,
|
||||
LONG_OPT_PO_DIR,
|
||||
LONG_OPT_PREPROCESSOR,
|
||||
LONG_OPT_VERSION,
|
||||
LONG_OPT_DEBUG,
|
||||
|
@ -191,29 +182,30 @@ enum long_options_values
|
|||
};
|
||||
|
||||
static const char short_options[] =
|
||||
"D:Ef:F:hi:I:J:l:o:O:rU:v";
|
||||
"b:D:Ef:F:hi:I:J:l:m:o:O:rU:v";
|
||||
static const struct option long_options[] = {
|
||||
{ "debug", 1, 0, LONG_OPT_DEBUG },
|
||||
{ "define", 1, 0, 'D' },
|
||||
{ "endianess", 1, 0, LONG_OPT_ENDIANESS },
|
||||
{ "help", 0, 0, 'h' },
|
||||
{ "include-dir", 1, 0, 'I' },
|
||||
{ "input", 1, 0, 'i' },
|
||||
{ "input-format", 1, 0, 'J' },
|
||||
{ "language", 1, 0, 'l' },
|
||||
{ "no-use-temp-file", 0, 0, LONG_OPT_NOTMPFILE },
|
||||
{ "nostdinc", 0, 0, LONG_OPT_NOSTDINC },
|
||||
{ "output", 1, 0, 'o' },
|
||||
{ "output-format", 1, 0, 'O' },
|
||||
{ "pedantic", 0, 0, LONG_OPT_PEDANTIC },
|
||||
{ "preprocessor", 1, 0, LONG_OPT_PREPROCESSOR },
|
||||
{ "target", 1, 0, 'F' },
|
||||
{ "undefine", 1, 0, 'U' },
|
||||
{ "use-temp-file", 0, 0, LONG_OPT_TMPFILE },
|
||||
{ "verbose", 0, 0, 'v' },
|
||||
{ "verify-translations", 0, 0, LONG_OPT_VERIFY_TRANSL },
|
||||
{ "version", 0, 0, LONG_OPT_VERSION },
|
||||
{ 0, 0, 0, 0 }
|
||||
{ "debug", 1, NULL, LONG_OPT_DEBUG },
|
||||
{ "define", 1, NULL, 'D' },
|
||||
{ "endianess", 1, NULL, LONG_OPT_ENDIANESS },
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "include-dir", 1, NULL, 'I' },
|
||||
{ "input", 1, NULL, 'i' },
|
||||
{ "input-format", 1, NULL, 'J' },
|
||||
{ "language", 1, NULL, 'l' },
|
||||
{ "no-use-temp-file", 0, NULL, LONG_OPT_NOTMPFILE },
|
||||
{ "nostdinc", 0, NULL, LONG_OPT_NOSTDINC },
|
||||
{ "output", 1, NULL, 'o' },
|
||||
{ "output-format", 1, NULL, 'O' },
|
||||
{ "pedantic", 0, NULL, LONG_OPT_PEDANTIC },
|
||||
{ "po-dir", 1, NULL, LONG_OPT_PO_DIR },
|
||||
{ "preprocessor", 1, NULL, LONG_OPT_PREPROCESSOR },
|
||||
{ "target", 1, NULL, 'F' },
|
||||
{ "undefine", 1, NULL, 'U' },
|
||||
{ "use-temp-file", 0, NULL, LONG_OPT_TMPFILE },
|
||||
{ "verbose", 0, NULL, 'v' },
|
||||
{ "verify-translations", 0, NULL, LONG_OPT_VERIFY_TRANSL },
|
||||
{ "version", 0, NULL, LONG_OPT_VERSION },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
static void set_version_defines(void)
|
||||
|
@ -256,40 +248,45 @@ static int load_file( const char *input_name, const char *output_name )
|
|||
/* Run the preprocessor on the input */
|
||||
if(!no_preprocess)
|
||||
{
|
||||
FILE *output;
|
||||
int ret, fd;
|
||||
char *name;
|
||||
|
||||
/*
|
||||
* Preprocess the input to a temp-file, or stdout if
|
||||
* no output was given.
|
||||
*/
|
||||
|
||||
chat("Starting preprocess\n");
|
||||
|
||||
if (!preprocess_only)
|
||||
if (preprocess_only)
|
||||
{
|
||||
ret = wpp_parse_temp( input_name, output_name, &temp_name );
|
||||
}
|
||||
else if (output_name)
|
||||
{
|
||||
FILE *output;
|
||||
if (output_name)
|
||||
{
|
||||
if (!(output = fopen( output_name, "w" )))
|
||||
fatal_perror( "Could not open %s for writing", output_name );
|
||||
ret = wpp_parse( input_name, output );
|
||||
fclose( output );
|
||||
}
|
||||
else ret = wpp_parse( input_name, stdout );
|
||||
|
||||
if (!(output = fopen( output_name, "w" )))
|
||||
fatal_perror( "Could not open %s for writing", output_name );
|
||||
ret = wpp_parse( input_name, output );
|
||||
fclose( output );
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = wpp_parse( input_name, stdout );
|
||||
}
|
||||
|
||||
if (ret) return ret;
|
||||
|
||||
if(preprocess_only)
|
||||
{
|
||||
if (ret) return ret;
|
||||
output_name = NULL;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
input_name = temp_name;
|
||||
if (output_name && output_name[0]) name = strmake( "%s.XXXXXX", output_name );
|
||||
else name = xstrdup( "wrc.XXXXXX" );
|
||||
|
||||
if ((fd = mkstemps( name, 0 )) == -1)
|
||||
error("Could not generate a temp name from %s\n", name);
|
||||
|
||||
temp_name = name;
|
||||
if (!(output = fdopen(fd, "wt")))
|
||||
error("Could not open fd %s for writing\n", name);
|
||||
|
||||
ret = wpp_parse( input_name, output );
|
||||
fclose( output );
|
||||
if (ret) return ret;
|
||||
input_name = name;
|
||||
}
|
||||
|
||||
/* Reset the language */
|
||||
|
@ -304,6 +301,7 @@ static int load_file( const char *input_name, const char *output_name )
|
|||
|
||||
ret = parser_parse();
|
||||
fclose(parser_in);
|
||||
parser_lex_destroy();
|
||||
if (temp_name)
|
||||
{
|
||||
unlink( temp_name );
|
||||
|
@ -313,6 +311,19 @@ static int load_file( const char *input_name, const char *output_name )
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void set_target( const char *target )
|
||||
{
|
||||
char *p, *cpu = xstrdup( target );
|
||||
|
||||
/* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */
|
||||
if (!(p = strchr( cpu, '-' ))) error( "Invalid target specification '%s'\n", target );
|
||||
*p = 0;
|
||||
if (!strcmp( cpu, "amd64" ) || !strcmp( cpu, "x86_64" ) || !strcmp( cpu, "ia64" ))
|
||||
pointer_size = 8;
|
||||
else
|
||||
pointer_size = 4;
|
||||
free( cpu );
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
|
@ -325,6 +336,8 @@ int main(int argc,char *argv[])
|
|||
int nb_files = 0;
|
||||
int i;
|
||||
int cmdlen;
|
||||
int po_mode = 0;
|
||||
char *po_dir = NULL;
|
||||
char **files = xmalloc( argc * sizeof(*files) );
|
||||
|
||||
signal(SIGSEGV, segvhandler);
|
||||
|
@ -339,8 +352,6 @@ int main(int argc,char *argv[])
|
|||
/* Set the default defined stuff */
|
||||
set_version_defines();
|
||||
wpp_add_cmdline_define("RC_INVOKED=1");
|
||||
wpp_add_cmdline_define("__WIN32__=1");
|
||||
wpp_add_cmdline_define("__FLAT__=1");
|
||||
/* Microsoft RC always searches current directory */
|
||||
wpp_add_include_path(".");
|
||||
|
||||
|
@ -371,6 +382,9 @@ int main(int argc,char *argv[])
|
|||
case LONG_OPT_NOTMPFILE:
|
||||
if (debuglevel) warning("--no-use-temp-file option not yet supported, ignored.\n");
|
||||
break;
|
||||
case LONG_OPT_PO_DIR:
|
||||
po_dir = xstrdup( optarg );
|
||||
break;
|
||||
case LONG_OPT_PREPROCESSOR:
|
||||
if (strcmp(optarg, "cat") == 0) no_preprocess = 1;
|
||||
else fprintf(stderr, "-P option not yet supported, ignored.\n");
|
||||
|
@ -415,8 +429,9 @@ int main(int argc,char *argv[])
|
|||
case 'E':
|
||||
preprocess_only = 1;
|
||||
break;
|
||||
case 'b':
|
||||
case 'F':
|
||||
/* ignored for compatibility with windres */
|
||||
set_target( optarg );
|
||||
break;
|
||||
case 'h':
|
||||
printf(usage);
|
||||
|
@ -440,6 +455,12 @@ int main(int argc,char *argv[])
|
|||
defaultlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
if (!strcmp( optarg, "16" )) win32 = 0;
|
||||
else if (!strcmp( optarg, "32" )) { win32 = 1; pointer_size = 4; }
|
||||
else if (!strcmp( optarg, "64" )) { win32 = 1; pointer_size = 8; }
|
||||
else error( "Invalid option: -m%s\n", optarg );
|
||||
break;
|
||||
case 'f':
|
||||
if (*optarg != 'o') error("Unknown option: -f%s\n", optarg);
|
||||
optarg++;
|
||||
|
@ -449,12 +470,9 @@ int main(int argc,char *argv[])
|
|||
else error("Too many output files.\n");
|
||||
break;
|
||||
case 'O':
|
||||
if (strcmp(optarg, "res16") == 0)
|
||||
{
|
||||
win32 = 0;
|
||||
wpp_del_define("__WIN32__");
|
||||
wpp_del_define("__FLAT__");
|
||||
}
|
||||
if (strcmp(optarg, "po") == 0) po_mode = 1;
|
||||
else if (strcmp(optarg, "pot") == 0) po_mode = 2;
|
||||
else if (strcmp(optarg, "res16") == 0) win32 = 0;
|
||||
else if (strcmp(optarg, "res")) warning("Output format %s not supported.\n", optarg);
|
||||
break;
|
||||
case 'r':
|
||||
|
@ -478,18 +496,26 @@ int main(int argc,char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (win32)
|
||||
{
|
||||
wpp_add_cmdline_define("_WIN32=1");
|
||||
if (pointer_size == 8) wpp_add_cmdline_define("_WIN64=1");
|
||||
}
|
||||
|
||||
/* If we do need to search standard includes, add them to the path */
|
||||
if (stdinc)
|
||||
{
|
||||
/* ReactOS doesn't use this feature
|
||||
wpp_add_include_path(INCLUDEDIR"/msvcrt");
|
||||
wpp_add_include_path(INCLUDEDIR"/windows");
|
||||
*/
|
||||
}
|
||||
|
||||
/* Kill io buffering when some kind of debuglevel is enabled */
|
||||
if(debuglevel)
|
||||
{
|
||||
setbuf(stdout,0);
|
||||
setbuf(stderr,0);
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
}
|
||||
|
||||
parser_debug = debuglevel & DEBUGLEVEL_TRACE ? 1 : 0;
|
||||
|
@ -510,20 +536,10 @@ int main(int argc,char *argv[])
|
|||
for (i = 0; i < nb_files; i++)
|
||||
{
|
||||
input_name = files[i];
|
||||
if(!output_name && !preprocess_only)
|
||||
{
|
||||
output_name = dup_basename(input_name, ".rc");
|
||||
strcat(output_name, ".res");
|
||||
}
|
||||
if (load_file( input_name, output_name )) exit(1);
|
||||
}
|
||||
/* stdin special case. NULL means "stdin" for wpp. */
|
||||
if (nb_files == 0)
|
||||
{
|
||||
if(!output_name && !preprocess_only)
|
||||
output_name = strdup("wrc.tab.res");
|
||||
if (load_file( NULL, output_name )) exit(1);
|
||||
}
|
||||
if (nb_files == 0 && load_file( NULL, output_name )) exit(1);
|
||||
|
||||
if(debuglevel & DEBUGLEVEL_DUMP)
|
||||
dump_resources(resource_top);
|
||||
|
@ -533,11 +549,32 @@ int main(int argc,char *argv[])
|
|||
verify_translations(resource_top);
|
||||
exit(0);
|
||||
}
|
||||
if (po_mode)
|
||||
{
|
||||
if (po_mode == 2) /* pot file */
|
||||
{
|
||||
if (!output_name)
|
||||
{
|
||||
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
|
||||
strcat( output_name, ".pot" );
|
||||
}
|
||||
write_pot_file( output_name );
|
||||
}
|
||||
else write_po_files( output_name );
|
||||
output_name = NULL;
|
||||
exit(0);
|
||||
}
|
||||
if (po_dir) add_translations( po_dir );
|
||||
|
||||
/* Convert the internal lists to binary data */
|
||||
resources2res(resource_top);
|
||||
|
||||
chat("Writing .res-file\n");
|
||||
if (!output_name)
|
||||
{
|
||||
output_name = dup_basename( nb_files ? files[0] : NULL, ".rc" );
|
||||
strcat(output_name, ".res");
|
||||
}
|
||||
write_resfile(output_name, resource_top);
|
||||
output_name = NULL;
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ extern int preprocess_only;
|
|||
extern int no_preprocess;
|
||||
extern int check_utf8;
|
||||
|
||||
extern char *output_name;
|
||||
extern char *input_name;
|
||||
extern char *cmdline;
|
||||
extern time_t now;
|
||||
|
@ -57,6 +56,21 @@ extern resource_t *resource_top;
|
|||
extern language_t *currentlanguage;
|
||||
|
||||
void verify_translations(resource_t *top);
|
||||
void write_pot_file( const char *outname );
|
||||
void write_po_files( const char *outname );
|
||||
void add_translations( const char *po_dir );
|
||||
void write_resfile(char *outname, resource_t *top);
|
||||
|
||||
static inline void set_location( location_t *loc )
|
||||
{
|
||||
loc->file = input_name;
|
||||
loc->line = line_number;
|
||||
loc->col = char_number;
|
||||
}
|
||||
|
||||
static inline void print_location( const location_t *loc )
|
||||
{
|
||||
if (loc->file) fprintf(stderr, "%s:%d:%d: ", loc->file, loc->line, loc->col );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<file>dumpres.c</file>
|
||||
<file>genres.c</file>
|
||||
<file>newstruc.c</file>
|
||||
<file>po.c</file>
|
||||
<file>readres.c</file>
|
||||
<file>translation.c</file>
|
||||
<file>utils.c</file>
|
||||
|
|
|
@ -115,4 +115,33 @@ typedef struct {
|
|||
DWORD bV4GammaBlue;
|
||||
} BITMAPV4HEADER,*LPBITMAPV4HEADER,*PBITMAPV4HEADER;
|
||||
|
||||
typedef struct {
|
||||
DWORD bV5Size;
|
||||
LONG bV5Width;
|
||||
LONG bV5Height;
|
||||
WORD bV5Planes;
|
||||
WORD bV5BitCount;
|
||||
DWORD bV5Compression;
|
||||
DWORD bV5SizeImage;
|
||||
LONG bV5XPelsPerMeter;
|
||||
LONG bV5YPelsPerMeter;
|
||||
DWORD bV5ClrUsed;
|
||||
DWORD bV5ClrImportant;
|
||||
DWORD bV5RedMask;
|
||||
DWORD bV5GreenMask;
|
||||
DWORD bV5BlueMask;
|
||||
DWORD bV5AlphaMask;
|
||||
DWORD bV5CSType;
|
||||
CIEXYZTRIPLE bV5Endpoints;
|
||||
DWORD bV5GammaRed;
|
||||
DWORD bV5GammaGreen;
|
||||
DWORD bV5GammaBlue;
|
||||
DWORD bV5Intent;
|
||||
DWORD bV5ProfileData;
|
||||
DWORD bV5ProfileSize;
|
||||
DWORD bV5Reserved;
|
||||
} BITMAPV5HEADER, *PBITMAPV5HEADER;
|
||||
|
||||
#define SS_TYPEMASK 0x0000001FL
|
||||
|
||||
#endif
|
||||
|
|
|
@ -74,6 +74,13 @@
|
|||
#define BYTESWAP_WORD(w) ((WORD)(((WORD)WRC_LOBYTE(w) << 8) + (WORD)WRC_HIBYTE(w)))
|
||||
#define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WRC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WRC_HIWORD(d)))))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *file;
|
||||
int line;
|
||||
int col;
|
||||
} location_t;
|
||||
|
||||
/* Binary resource structure */
|
||||
#define RES_BLOCKSIZE 512
|
||||
|
||||
|
@ -94,6 +101,7 @@ typedef struct string {
|
|||
char *cstr;
|
||||
WCHAR *wstr;
|
||||
} str;
|
||||
location_t loc;
|
||||
} string_t;
|
||||
|
||||
/* Resources are identified either by name or by number */
|
||||
|
@ -174,9 +182,7 @@ enum res_e {
|
|||
res_dlginit = WRC_RT_DLGINIT, /* 240 */
|
||||
res_toolbar = WRC_RT_TOOLBAR, /* 241 */
|
||||
|
||||
res_menex = 256 + 4,
|
||||
res_dlgex,
|
||||
res_usr
|
||||
res_usr = 256 + 6
|
||||
};
|
||||
|
||||
/* Raw bytes in a row... */
|
||||
|
@ -214,8 +220,11 @@ typedef struct dialog {
|
|||
int height;
|
||||
style_t *style; /* Style */
|
||||
style_t *exstyle;
|
||||
DWORD helpid; /* EX: */
|
||||
int gotstyle; /* Used to determine whether the default */
|
||||
int gotexstyle; /* styles must be set */
|
||||
int gothelpid;
|
||||
int is_ex;
|
||||
name_id_t *menu;
|
||||
name_id_t *dlgclass;
|
||||
string_t *title;
|
||||
|
@ -224,49 +233,12 @@ typedef struct dialog {
|
|||
control_t *controls;
|
||||
} dialog_t;
|
||||
|
||||
/* DialogEx structures */
|
||||
typedef struct dialogex {
|
||||
DWORD memopt;
|
||||
int x; /* Position */
|
||||
int y;
|
||||
int width; /* Size */
|
||||
int height;
|
||||
style_t *style; /* Style */
|
||||
style_t *exstyle;
|
||||
DWORD helpid; /* EX: */
|
||||
int gotstyle; /* Used to determine whether the default */
|
||||
int gotexstyle; /* styles must be set */
|
||||
int gothelpid;
|
||||
name_id_t *menu;
|
||||
name_id_t *dlgclass;
|
||||
string_t *title;
|
||||
font_id_t *font;
|
||||
lvc_t lvc;
|
||||
control_t *controls;
|
||||
} dialogex_t;
|
||||
|
||||
/* Menu structures */
|
||||
typedef struct menu_item {
|
||||
struct menu_item *next;
|
||||
struct menu_item *prev;
|
||||
struct menu_item *popup;
|
||||
int id;
|
||||
DWORD state;
|
||||
string_t *name;
|
||||
} menu_item_t;
|
||||
|
||||
typedef struct menu {
|
||||
DWORD memopt;
|
||||
lvc_t lvc;
|
||||
menu_item_t *items;
|
||||
} menu_t;
|
||||
|
||||
/* MenuEx structures */
|
||||
typedef struct menuex_item {
|
||||
struct menuex_item *next;
|
||||
struct menuex_item *prev;
|
||||
struct menuex_item *popup;
|
||||
int id;
|
||||
DWORD type;
|
||||
DWORD state;
|
||||
int helpid;
|
||||
|
@ -275,13 +247,14 @@ typedef struct menuex_item {
|
|||
int gottype;
|
||||
int gotstate;
|
||||
int gothelpid;
|
||||
} menuex_item_t;
|
||||
} menu_item_t;
|
||||
|
||||
typedef struct menuex {
|
||||
typedef struct menu {
|
||||
DWORD memopt;
|
||||
lvc_t lvc;
|
||||
menuex_item_t *items;
|
||||
} menuex_t;
|
||||
int is_ex;
|
||||
menu_item_t *items;
|
||||
} menu_t;
|
||||
|
||||
typedef struct itemex_opt
|
||||
{
|
||||
|
@ -602,14 +575,12 @@ typedef struct resource {
|
|||
cursor_t *cur;
|
||||
cursor_group_t *curg;
|
||||
dialog_t *dlg;
|
||||
dialogex_t *dlgex;
|
||||
dlginit_t *dlgi;
|
||||
font_t *fnt;
|
||||
fontdir_t *fnd;
|
||||
icon_t *ico;
|
||||
icon_group_t *icog;
|
||||
menu_t *men;
|
||||
menuex_t *menex;
|
||||
messagetable_t *msg;
|
||||
html_t *html;
|
||||
rcdata_t *rdt;
|
||||
|
|
Loading…
Reference in a new issue