ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2019
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
24 participants
322 discussions
Start a n
N
ew thread
[reactos] 01/06: [NTOS:KD] Whitespace fixes + fix helper function name.
by Hermès Bélusca-Maïto
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=ef5f034974c1850ab3fe1…
commit ef5f034974c1850ab3fe196e82231e2d7c9610b9 Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> AuthorDate: Sat Nov 2 01:02:35 2019 +0100 Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org> CommitDate: Sun Nov 3 05:07:32 2019 +0100 [NTOS:KD] Whitespace fixes + fix helper function name. --- ntoskrnl/kd/i386/kdmemsup.c | 8 ++++---- ntoskrnl/kd64/kdapi.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/kd/i386/kdmemsup.c b/ntoskrnl/kd/i386/kdmemsup.c index 3f14bcdc9c3..7616734ce53 100644 --- a/ntoskrnl/kd/i386/kdmemsup.c +++ b/ntoskrnl/kd/i386/kdmemsup.c @@ -118,7 +118,7 @@ KdpTranslateAddress(ULONG_PTR Addr, PULONG_PTR ResultAddr) { ULONG_PTR CR3Value = __readcr3(); ULONG_PTR CR4Value = __readcr4(); - ULONG_PTR PageDirectory = (CR3Value & ~(PAGE_SIZE-1)) + + ULONG_PTR PageDirectory = (CR3Value & ~(PAGE_SIZE-1)) + ((Addr >> 22) * sizeof(ULONG)); ULONG_PTR PageDirectoryEntry = KdpPhysRead(PageDirectory, sizeof(ULONG)); @@ -137,7 +137,7 @@ KdpTranslateAddress(ULONG_PTR Addr, PULONG_PTR ResultAddr) } else { - ULONG_PTR PageTableAddr = + ULONG_PTR PageTableAddr = (PageDirectoryEntry & ~(PAGE_SIZE-1)) + ((Addr >> PAGE_SHIFT) & PAGE_TABLE_MASK) * sizeof(ULONG); ULONG_PTR PageTableEntry = KdpPhysRead(PageTableAddr, sizeof(ULONG)); @@ -165,7 +165,7 @@ KdpSafeReadMemory(ULONG_PTR Addr, LONG Len, PVOID Value) } memset(Value, 0, Len); - + if (!KdpTranslateAddress(Addr, &ResultPhysAddr)) return FALSE; @@ -199,7 +199,7 @@ KdpSafeWriteMemory(ULONG_PTR Addr, LONG Len, ULONGLONG Value) memcpy((PVOID)Addr, &Value, Len); return TRUE; } - + if (!KdpTranslateAddress(Addr, &ResultPhysAddr)) return FALSE; diff --git a/ntoskrnl/kd64/kdapi.c b/ntoskrnl/kd64/kdapi.c index 9256225f94c..bfb7283ee1a 100644 --- a/ntoskrnl/kd64/kdapi.c +++ b/ntoskrnl/kd64/kdapi.c @@ -529,7 +529,7 @@ KdpWriteVirtualMemory(IN PDBGKD_MANIPULATE_STATE64 State, VOID NTAPI -KdpReadPhysicalmemory(IN PDBGKD_MANIPULATE_STATE64 State, +KdpReadPhysicalMemory(IN PDBGKD_MANIPULATE_STATE64 State, IN PSTRING Data, IN PCONTEXT Context) { @@ -592,7 +592,7 @@ KdpReadPhysicalmemory(IN PDBGKD_MANIPULATE_STATE64 State, VOID NTAPI -KdpWritePhysicalmemory(IN PDBGKD_MANIPULATE_STATE64 State, +KdpWritePhysicalMemory(IN PDBGKD_MANIPULATE_STATE64 State, IN PSTRING Data, IN PCONTEXT Context) { @@ -1395,13 +1395,13 @@ SendPacket: case DbgKdReadPhysicalMemoryApi: /* Read physical memory */ - KdpReadPhysicalmemory(&ManipulateState, &Data, Context); + KdpReadPhysicalMemory(&ManipulateState, &Data, Context); break; case DbgKdWritePhysicalMemoryApi: /* Write physical memory */ - KdpWritePhysicalmemory(&ManipulateState, &Data, Context); + KdpWritePhysicalMemory(&ManipulateState, &Data, Context); break; case DbgKdQuerySpecialCallsApi:
5 years, 1 month
1
0
0
0
[reactos] 01/01: [DNSAPI][PSDK] Implement GetCurrentTimeInSeconds() and fix DnsQuery_A/UTF8/W()
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=158fda5cdffe09626a097…
commit 158fda5cdffe09626a09730f9a0832b0d7ea9353 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sat Nov 2 23:59:06 2019 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sat Nov 2 23:59:06 2019 +0100 [DNSAPI][PSDK] Implement GetCurrentTimeInSeconds() and fix DnsQuery_A/UTF8/W() --- dll/win32/dnsapi/dnsapi/query.c | 44 +++++++++++++++++++++++--------------- dll/win32/dnsapi/dnsapi/stubs.c | 7 ------ sdk/include/psdk/windns.h | 6 +++--- sdk/include/reactos/windns_undoc.h | 4 ++++ 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/dll/win32/dnsapi/dnsapi/query.c b/dll/win32/dnsapi/dnsapi/query.c index 2daa2803663..f7de6ab96c8 100644 --- a/dll/win32/dnsapi/dnsapi/query.c +++ b/dll/win32/dnsapi/dnsapi/query.c @@ -16,6 +16,7 @@ #define NDEBUG #include <debug.h> + /* DnsQuery **************************** * Begin a DNS query, and allow the result to be placed in the application * supplied result pointer. The result can be manipulated with the record @@ -155,7 +156,7 @@ DnsQuery_CodePage(UINT CodePage, LPCSTR Name, WORD Type, DWORD Options, - PIP4_ARRAY Servers, + PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved) { @@ -163,7 +164,7 @@ DnsQuery_CodePage(UINT CodePage, PWCHAR Buffer; DNS_STATUS Status; PDNS_RECORD QueryResultWide; - PDNS_RECORD ConvertedRecord = 0, LastRecord = 0; + PDNS_RECORD ConvertedRecord = NULL, LastRecord = NULL; if (Name == NULL) return ERROR_INVALID_PARAMETER; @@ -184,7 +185,7 @@ DnsQuery_CodePage(UINT CodePage, return ERROR_INVALID_PARAMETER; } - Status = DnsQuery_W(Buffer, Type, Options, Servers, &QueryResultWide, Reserved); + Status = DnsQuery_W(Buffer, Type, Options, Extra, &QueryResultWide, Reserved); while (Status == ERROR_SUCCESS && QueryResultWide) { @@ -308,7 +309,7 @@ DnsQuery_CodePage(UINT CodePage, } if (LastRecord) - LastRecord->pNext = 0; + LastRecord->pNext = NULL; /* The name */ RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer); @@ -322,22 +323,22 @@ DNS_STATUS WINAPI DnsQuery_A(LPCSTR Name, WORD Type, DWORD Options, - PIP4_ARRAY Servers, + PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved) { - return DnsQuery_CodePage(CP_ACP, Name, Type, Options, Servers, QueryResultSet, Reserved); + return DnsQuery_CodePage(CP_ACP, Name, Type, Options, Extra, QueryResultSet, Reserved); } DNS_STATUS WINAPI DnsQuery_UTF8(LPCSTR Name, WORD Type, DWORD Options, - PIP4_ARRAY Servers, + PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved) { - return DnsQuery_CodePage(CP_UTF8, Name, Type, Options, Servers, QueryResultSet, Reserved); + return DnsQuery_CodePage(CP_UTF8, Name, Type, Options, Extra, QueryResultSet, Reserved); } WCHAR @@ -725,7 +726,7 @@ DNS_STATUS WINAPI DnsQuery_W(LPCWSTR Name, WORD Type, DWORD Options, - PIP4_ARRAY Servers, + PVOID Extra, PDNS_RECORD *QueryResultSet, PVOID *Reserved) { @@ -922,14 +923,6 @@ DnsQuery_W(LPCWSTR Name, } RtlFreeHeap(RtlGetProcessHeap(), 0, network_info); - if (Servers) - { - for (i = 0; i < Servers->AddrCount; i++) - { - adns_addserver(astate, *((struct in_addr *)&Servers->AddrArray[i])); - } - } - if (!adns_numservers(astate)) { /* There are no servers to query so bail out */ @@ -1095,3 +1088,20 @@ DnsFlushResolverCache(VOID) return (Status == ERROR_SUCCESS); } + +DNS_STATUS +WINAPI +GetCurrentTimeInSeconds(VOID) +{ + FILETIME Time; + FILETIME Adjustment; + ULARGE_INTEGER lTime, lAdj; + SYSTEMTIME st = {1970, 1, 0, 1, 0, 0, 0}; + + SystemTimeToFileTime(&st, &Adjustment); + memcpy(&lAdj, &Adjustment, sizeof(lAdj)); + GetSystemTimeAsFileTime(&Time); + memcpy(&lTime, &Time, sizeof(lTime)); + lTime.QuadPart -= lAdj.QuadPart; + return (DWORD)(lTime.QuadPart/10000000LLU); +} diff --git a/dll/win32/dnsapi/dnsapi/stubs.c b/dll/win32/dnsapi/dnsapi/stubs.c index f474f34695b..0a4bf59db55 100644 --- a/dll/win32/dnsapi/dnsapi/stubs.c +++ b/dll/win32/dnsapi/dnsapi/stubs.c @@ -807,13 +807,6 @@ DnsWriteReverseNameStringForIpAddress() return ERROR_OUTOFMEMORY; } -DNS_STATUS WINAPI -GetCurrentTimeInSeconds() -{ - UNIMPLEMENTED; - return ERROR_OUTOFMEMORY; -} - DNS_STATUS WINAPI DnsNotifyResolver() { diff --git a/sdk/include/psdk/windns.h b/sdk/include/psdk/windns.h index c989c9b4809..0c7433de660 100644 --- a/sdk/include/psdk/windns.h +++ b/sdk/include/psdk/windns.h @@ -741,7 +741,7 @@ DnsQuery_A( _In_ PCSTR pszName, _In_ WORD wType, _In_ DWORD Options, - _Inout_opt_ PIP4_ARRAY pExtra, + _Inout_opt_ PVOID pExtra, _Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults, _Outptr_opt_result_maybenull_ PVOID *pReserved); @@ -751,7 +751,7 @@ DnsQuery_W( _In_ PCWSTR pszName, _In_ WORD wType, _In_ DWORD Options, - _Inout_opt_ PIP4_ARRAY pExtra, + _Inout_opt_ PVOID pExtra, _Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults, _Outptr_opt_result_maybenull_ PVOID *pReserved); @@ -761,7 +761,7 @@ DnsQuery_UTF8( _In_ PCSTR pszName, _In_ WORD wType, _In_ DWORD Options, - _Inout_opt_ PIP4_ARRAY pExtra, + _Inout_opt_ PVOID pExtra, _Outptr_result_maybenull_ PDNS_RECORD *ppQueryResults, _Outptr_opt_result_maybenull_ PVOID *pReserved); diff --git a/sdk/include/reactos/windns_undoc.h b/sdk/include/reactos/windns_undoc.h index 01e6f412095..cb2e5abdbe4 100644 --- a/sdk/include/reactos/windns_undoc.h +++ b/sdk/include/reactos/windns_undoc.h @@ -27,6 +27,10 @@ WINAPI DnsGetCacheDataTable( _Out_ PDNS_CACHE_ENTRY *DnsCache); +DNS_STATUS +WINAPI +GetCurrentTimeInSeconds(VOID); + #endif /* __WIDL__ */ #ifdef __cplusplus
5 years, 1 month
1
0
0
0
[reactos] 01/01: [DNSAPI] Add missing exported functions
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=01bd090db0b1bc3439af3…
commit 01bd090db0b1bc3439af3b698a7285546f386233 Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Sat Nov 2 18:47:36 2019 +0100 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Sat Nov 2 18:48:31 2019 +0100 [DNSAPI] Add missing exported functions --- dll/win32/dnsapi/CMakeLists.txt | 1 + dll/win32/dnsapi/dnsapi.spec | 68 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/dll/win32/dnsapi/CMakeLists.txt b/dll/win32/dnsapi/CMakeLists.txt index a0edb35c99b..244e764e697 100644 --- a/dll/win32/dnsapi/CMakeLists.txt +++ b/dll/win32/dnsapi/CMakeLists.txt @@ -25,6 +25,7 @@ list(APPEND SOURCE add_library(dnsapi MODULE ${SOURCE} dnsapi.rc + ${CMAKE_CURRENT_BINARY_DIR}/dnsapi_stubs.c ${CMAKE_CURRENT_BINARY_DIR}/dnsapi.def) set_module_type(dnsapi win32dll) diff --git a/dll/win32/dnsapi/dnsapi.spec b/dll/win32/dnsapi/dnsapi.spec index 64ce27a4b3e..bb69e12d333 100644 --- a/dll/win32/dnsapi/dnsapi.spec +++ b/dll/win32/dnsapi/dnsapi.spec @@ -1,3 +1,5 @@ +@ stub BreakRecordsIntoBlob +@ stub CombineRecordsInBlob @ stdcall DnsAcquireContextHandle_A(long ptr ptr) @ stdcall DnsAcquireContextHandle_UTF8(long ptr ptr) @ stdcall DnsAcquireContextHandle_W(long ptr ptr) @@ -5,9 +7,11 @@ @ stdcall DnsAddRecordSet_UTF8() @ stdcall DnsAddRecordSet_W() @ stdcall DnsAllocateRecord() -@ stdcall DnsApiHeapReset() @ stdcall DnsApiAlloc(long) +@ stdcall DnsApiHeapReset() @ stdcall DnsApiFree(ptr) +@ stub DnsApiRealloc +@ stub DnsApiSetDebugGlobals @ stdcall DnsAsyncRegisterHostAddrs_A() @ stdcall DnsAsyncRegisterHostAddrs_UTF8() @ stdcall DnsAsyncRegisterHostAddrs_W() @@ -37,7 +41,9 @@ @ stdcall DnsFlushResolverCacheEntry_A(str) @ stdcall DnsFlushResolverCacheEntry_UTF8() @ stdcall DnsFlushResolverCacheEntry_W() +@ stdcall DnsFree(ptr long) @ stdcall DnsFreeAdapterInformation() +@ stub DnsFreeConfigStructure @ stdcall DnsFreeNetworkInformation() @ stdcall DnsFreeSearchInformation() @ stdcall DnsGetBufferLengthForStringCopy() @@ -56,6 +62,7 @@ @ stdcall DnsGetPrimaryDomainName_UTF8() @ stdcall DnsGetPrimaryDomainName_W() @ stdcall DnsGetSearchInformation() +@ stub DnsGlobals @ stdcall DnsIpv6AddressToString() @ stdcall DnsIpv6StringToAddress() @ stdcall DnsIsAdapterDomainNameRegistrationEnabled() @@ -70,17 +77,20 @@ @ stdcall DnsModifyRecordsInSet_A(ptr ptr long ptr ptr ptr) @ stdcall DnsModifyRecordsInSet_UTF8(ptr ptr long ptr ptr ptr) @ stdcall DnsModifyRecordsInSet_W(ptr ptr long ptr ptr ptr) -@ stdcall DnsNameCompare_A(str str) @ stdcall DnsNameCompareEx_A() @ stdcall DnsNameCompareEx_UTF8() @ stdcall DnsNameCompareEx_W() +@ stdcall DnsNameCompare_A(str str) @ stdcall DnsNameCompare_W(wstr wstr) + @ stdcall DnsNameCopy() @ stdcall DnsNameCopyAllocate() @ stdcall DnsNotifyResolver() -@ stdcall DnsQuery_A(str long long ptr ptr ptr) +@ stub DnsNotifyResolverClusterIp +@ stub DnsNotifyResolverEx @ stdcall DnsQueryConfig(long long wstr ptr ptr ptr) @ stdcall DnsQueryEx() +@ stdcall DnsQuery_A(str long long ptr ptr ptr) @ stdcall DnsQuery_UTF8(str long long ptr ptr ptr) @ stdcall DnsQuery_W(wstr long long ptr ptr ptr) @ stdcall DnsRecordBuild_UTF8() @@ -94,6 +104,7 @@ @ stdcall DnsRecordStringForType() @ stdcall DnsRecordStringForWritableType() @ stdcall DnsRecordTypeForName() +@ stub DnsRegisterClusterAddress @ stdcall DnsRelationalCompare_UTF8() @ stdcall DnsRelationalCompare_W() @ stdcall DnsReleaseContextHandle(ptr) @@ -128,5 +139,54 @@ @ stdcall DnsWriteQuestionToBuffer_UTF8(ptr ptr str long long long) @ stdcall DnsWriteQuestionToBuffer_W(ptr ptr wstr long long long) @ stdcall DnsWriteReverseNameStringForIpAddress() +@ stub Dns_AddRecordsToMessage +@ stub Dns_AllocateMsgBuf +@ stub Dns_BuildPacket +@ stub Dns_CacheSocketCleanup +@ stub Dns_CacheSocketInit +@ stub Dns_CleanupWinsock +@ stub Dns_CloseConnection +@ stub Dns_CloseHostFile +@ stub Dns_CloseSocket +@ stub Dns_CreateMulticastSocket +@ stub Dns_CreateSocket +@ stub Dns_CreateSocketEx +@ stub Dns_FindAuthoritativeZoneLib +@ stub Dns_GetIpAddresses +@ stub Dns_GetLocalIpAddressArray +@ stub Dns_GetRandomXid +@ stub Dns_InitializeMsgRemoteSockaddr +@ stub Dns_InitializeWinsock +@ stub Dns_InitQueryTimeouts +@ stub Dns_OpenHostFile +@ stub Dns_OpenTcpConnectionAndSend +@ stub Dns_ParseMessage +@ stub Dns_ParsePacketRecord +@ stub Dns_PingAdapterServers +@ stub Dns_ReadHostFileLine +@ stub Dns_ReadPacketName +@ stub Dns_ReadPacketNameAllocate +@ stub Dns_ReadRecordStructureFromPacket +@ stub Dns_RecvTcp +@ stub Dns_ResetNetworkInfo +@ stub Dns_SendAndRecvUdp +@ stub Dns_SendEx +@ stub Dns_SetRecordDatalength +@ stub Dns_SkipPacketName +@ stub Dns_SkipToRecord +@ stub Dns_UpdateLib +@ stub Dns_UpdateLibEx +@ stub Dns_WriteDottedNameToPacket +@ stub Dns_WriteQuestionToMessage +@ stub Dns_WriteRecordStructureToPacketEx @ stdcall GetCurrentTimeInSeconds() -@ stdcall DnsFree(ptr long) +@ stub GetRecordsForLocalName +@ stub NetInfo_Build +@ stub NetInfo_Clean +@ stub NetInfo_Copy +@ stub NetInfo_Free +@ stub NetInfo_IsForUpdate +@ stub NetInfo_ResetServerPriorities +@ stub QueryDirectEx +@ stub Query_Main +@ stub Reg_ReadGlobalsEx
5 years, 1 month
1
0
0
0
[reactos] 01/01: [LOADPERF] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=80b74aaec81d05b261728…
commit 80b74aaec81d05b2617289d1e5ba5b8337de02c7 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:40:10 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:40:10 2019 +0100 [LOADPERF] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/loadperf/loadperf_main.c | 1 - media/doc/README.WINE | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dll/win32/loadperf/loadperf_main.c b/dll/win32/loadperf/loadperf_main.c index 8f0da112ecf..54901a739af 100644 --- a/dll/win32/loadperf/loadperf_main.c +++ b/dll/win32/loadperf/loadperf_main.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" #include <stdarg.h> diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 6feca8d0c67..9e9c990334e 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -88,7 +88,7 @@ dll/win32/itircl # Synced to WineStaging-4.18 dll/win32/itss # Synced to WineStaging-4.18 dll/win32/jscript # Synced to WineStaging-4.18 dll/win32/jsproxy # Synced to WineStaging-4.18 -dll/win32/loadperf # Synced to WineStaging-3.3 +dll/win32/loadperf # Synced to WineStaging-4.18 dll/win32/lz32 # Synced to WineStaging-3.3 dll/win32/mapi32 # Synced to WineStaging-4.0 dll/win32/mciavi32 # Synced to WineStaging-3.3
5 years, 1 month
1
0
0
0
[reactos] 01/01: [JSPROXY] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=341a75bff38d75db7479a…
commit 341a75bff38d75db7479af03ac108bfd2597e80a Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:38:56 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:38:56 2019 +0100 [JSPROXY] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/jsproxy/main.c | 45 ++++++++++----------------------------------- media/doc/README.WINE | 2 +- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/dll/win32/jsproxy/main.c b/dll/win32/jsproxy/main.c index e58553f4fcd..54cb1be8753 100644 --- a/dll/win32/jsproxy/main.c +++ b/dll/win32/jsproxy/main.c @@ -16,37 +16,18 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" - #include <stdarg.h> -#include <sys/types.h> -#ifdef HAVE_SYS_SOCKET_H -# include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -# include <netinet/in.h> -#endif -#ifdef HAVE_NETDB_H -# include <netdb.h> -#endif #ifdef __REACTOS__ +#include <stdio.h> #define COBJMACROS #endif -#if defined(__MINGW32__) || defined (_MSC_VER) -# include <ws2tcpip.h> -#else -# define closesocket close -# define ioctlsocket ioctl -#endif +#include <sys/types.h> #include "windef.h" #include "winbase.h" -#ifndef __MINGW32__ -#define USE_WS_PREFIX -#endif #include "winsock2.h" #include "ws2ipdef.h" +#include "ws2tcpip.h" #include "winnls.h" #include "wininet.h" #ifndef __REACTOS__ @@ -57,7 +38,6 @@ #include "activscp.h" #include "wine/debug.h" #include "wine/heap.h" -#include "wine/unicode.h" static HINSTANCE instance; @@ -297,7 +277,7 @@ static HRESULT WINAPI dispex_GetNameSpaceParent( static HRESULT WINAPI dispex_GetDispID( IDispatchEx *iface, BSTR name, DWORD flags, DISPID *id ) { - if (!strcmpW( name, dns_resolveW )) + if (!lstrcmpW( name, dns_resolveW )) { *id = DISPID_GLOBAL_DNSRESOLVE; return S_OK; @@ -321,9 +301,9 @@ static char *get_computer_name( COMPUTER_NAME_FORMAT format ) return ret; } -static void printf_addr( const WCHAR *fmt, WCHAR *buf, struct sockaddr_in *addr ) +static void printf_addr( const WCHAR *fmt, WCHAR *buf, SIZE_T size, struct sockaddr_in *addr ) { - sprintfW( buf, fmt, + swprintf( buf, fmt, (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 24 & 0xff), (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 16 & 0xff), (unsigned int)(ntohl( addr->sin_addr.s_addr ) >> 8 & 0xff), @@ -332,7 +312,6 @@ static void printf_addr( const WCHAR *fmt, WCHAR *buf, struct sockaddr_in *addr static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result ) { -#ifdef HAVE_GETADDRINFO static const WCHAR fmtW[] = {'%','u','.','%','u','.','%','u','.','%','u',0}; WCHAR addr[16]; struct addrinfo *ai, *elem; @@ -356,15 +335,11 @@ static HRESULT dns_resolve( const WCHAR *hostname, VARIANT *result ) freeaddrinfo( ai ); return S_FALSE; } - printf_addr( fmtW, addr, (struct sockaddr_in *)elem->ai_addr ); + printf_addr( fmtW, addr, ARRAY_SIZE(addr), (struct sockaddr_in *)elem->ai_addr ); freeaddrinfo( ai ); V_VT( result ) = VT_BSTR; V_BSTR( result ) = SysAllocString( addr ); return S_OK; -#else - FIXME("getaddrinfo not found at build time\n"); - return S_FALSE; -#endif } static HRESULT WINAPI dispex_InvokeEx( @@ -439,7 +414,7 @@ static HRESULT WINAPI site_GetItemInfo( IActiveScriptSite *iface, LPCOLESTR name, DWORD mask, IUnknown **item, ITypeInfo **type_info ) { - if (!strcmpW( name, global_funcsW ) && mask == SCRIPTINFO_IUNKNOWN) + if (!lstrcmpW( name, global_funcsW ) && mask == SCRIPTINFO_IUNKNOWN) { *item = (IUnknown *)&global_dispex; return S_OK; @@ -515,9 +490,9 @@ static BSTR include_pac_utils( const WCHAR *script ) data = LoadResource( hmod, rsrc ); len = MultiByteToWideChar( CP_ACP, 0, data, size, NULL, 0 ); - if (!(ret = SysAllocStringLen( NULL, len + strlenW( script ) + 1 ))) return NULL; + if (!(ret = SysAllocStringLen( NULL, len + lstrlenW( script ) + 1 ))) return NULL; MultiByteToWideChar( CP_ACP, 0, data, size, ret, len ); - strcpyW( ret + len, script ); + lstrcpyW( ret + len, script ); return ret; } diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 8c3f6b16d3d..6feca8d0c67 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -87,7 +87,7 @@ dll/win32/iphlpapi # Out of sync dll/win32/itircl # Synced to WineStaging-4.18 dll/win32/itss # Synced to WineStaging-4.18 dll/win32/jscript # Synced to WineStaging-4.18 -dll/win32/jsproxy # Synced to WineStaging-4.0 +dll/win32/jsproxy # Synced to WineStaging-4.18 dll/win32/loadperf # Synced to WineStaging-3.3 dll/win32/lz32 # Synced to WineStaging-3.3 dll/win32/mapi32 # Synced to WineStaging-4.0
5 years, 1 month
1
0
0
0
[reactos] 01/01: [JSCRIPT_WINETEST] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=021b5c1f4daa93c06b0a9…
commit 021b5c1f4daa93c06b0a9f212a891b1e01b82431 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:38:32 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:38:32 2019 +0100 [JSCRIPT_WINETEST] Sync with Wine Staging 4.18. CORE-16441 --- modules/rostests/winetests/jscript/api.js | 71 ++++- modules/rostests/winetests/jscript/caller.c | 3 + modules/rostests/winetests/jscript/lang.js | 5 +- modules/rostests/winetests/jscript/run.c | 406 +++++++++++++++++++++++++++- 4 files changed, 476 insertions(+), 9 deletions(-) diff --git a/modules/rostests/winetests/jscript/api.js b/modules/rostests/winetests/jscript/api.js index ff6a6b781cf..d62a6434710 100644 --- a/modules/rostests/winetests/jscript/api.js +++ b/modules/rostests/winetests/jscript/api.js @@ -58,6 +58,8 @@ testNoEnumerables("Function"); testNoEnumerables("Function.prototype"); testNoEnumerables("testNoEnumerates"); testNoEnumerables("VBArray"); +testNoEnumerables("new Enumerator()"); +testNoEnumerables("Enumerator()"); ok(Object.propertyIsEnumerable("prototype") === false, "Object.prototype is enumerable"); ok(Math.propertyIsEnumerable("E") === false, "Math.E is enumerable"); @@ -154,6 +156,12 @@ i = parseInt("1", 37); ok(isNaN(i), "parseInt('1', 37) = " + i); i = parseInt("1", 36); ok(i === 1, "parseInt('1', 36) = " + i); +i = parseInt("0x1f", 16); +ok(i === 31, "parseInt('0xf', 16) = " + i); +i = parseInt("0x", 16); +ok(isNaN(i), "parseInt('0x', 16) = " + i); +i = parseInt("0x1f", 17); +ok(i === 0, "parseInt('0xf', 16) = " + i); tmp = encodeURI("abc"); ok(tmp === "abc", "encodeURI('abc') = " + tmp); @@ -341,6 +349,8 @@ ok(tmp === "[object Object]", "toString.call(this) = " + tmp); ok(tmp === "[object Object]", "toString.call(arguments) = " + tmp); tmp = Object.prototype.toString.call(new VBArray(createArray())); ok(tmp === "[object Object]", "toString.call(new VBArray()) = " + tmp); +(tmp = new Enumerator()).f = Object.prototype.toString; +ok(tmp.f() === "[object Object]", "tmp.f() = " + tmp.f()); function TSTestConstr() {} TSTestConstr.prototype = { toString: function() { return "test"; } }; @@ -640,6 +650,43 @@ ok(typeof(r) === "object", "typeof(r) = " + typeof(r)); ok(r.length === 1, "r.length = " + r.length); ok(r[0] === "", "r[0] = " + r[0]); +(function() { + function test(string, separator, result) { + var r = string.split(separator); + ok(r == result, "\"" + string + "\".split(" + separator + ") returned " + r + " expected " + result); + } + + test("test", /^|\s+/, "test"); + test("test", /$|\s+/, "test"); + test("test", /^|./, "t"); + test("test", /.*/, ""); + test("test", /x*/, "t,e,s,t"); + test("test", /$|x*/, "t,e,s,t"); + test("test", /^|x*/, "t,e,s,t"); + test("test", /t*/, "e,s"); + test("xaabaax", /a*|b*/, "x,b,x"); + test("xaabaax", /a+|b+/, "x,x"); + test("xaabaax", /a+|b*/, "x,x"); + test("xaaxbaax", /b+|a+/, "x,x,x"); + test("test", /^|t/, "tes"); + test("test", /^|t/, "tes"); + test("a,,b", /,/, "a,b"); + test("ab", /a*/, "b"); + test("aab", "a", ",,b"); + test("a", "a", ","); + + function test_length(string, separator, len) { + var r = string.split(separator); + ok(r.length === len, "\"" + string + "\".split(" + separator + ").length = " + + r.length + " expected " + len); + } + + test_length("", /a*/, 0); + test_length("", /a+/, 1); + test_length("", "", 0); + test_length("", "x", 1); +})(); + tmp = "abcd".indexOf("bc",0); ok(tmp === 1, "indexOf = " + tmp); tmp = "abcd".indexOf("bc",1); @@ -1870,11 +1917,11 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN"); s = JSON.stringify(testObj); ok(s === undefined || s === "undefined" /* broken on some old versions */, - "stringify(testObj) returned " + s + " expected undfined"); + "stringify(testObj) returned " + s + " expected undefined"); s = JSON.stringify(undefined); ok(s === undefined || s === "undefined" /* broken on some old versions */, - "stringify(undefined) returned " + s + " expected undfined"); + "stringify(undefined) returned " + s + " expected undefined"); var parse_tests = [ ["true", true], @@ -1887,7 +1934,10 @@ ok(isNaN(tmp), "Math.tan(-Infinity) is not NaN"); ["[false,{},{\"x\": []}]", [false,{},{x:[]}]], ["0", 0], ["- 1", -1], - ["1e2147483648", Infinity] + ["1e2147483648", Infinity], + ["0.5", 0.5], + ["0e5", 0], + [".5", 0.5] ]; function json_cmp(x, y) { @@ -2408,6 +2458,7 @@ var exception_array = { E_OBJECT_EXPECTED: { type: "TypeError", number: -2146823281 }, E_OBJECT_REQUIRED: { type: "TypeError", number: -2146827864 }, E_UNSUPPORTED_ACTION: { type: "TypeError", number: -2146827843 }, + E_NOT_ENUMERATOR: { type: "TypeError", number: -2146823273 }, E_NOT_VBARRAY: { type: "TypeError", number: -2146823275 }, E_INVALID_DELETE: { type: "TypeError", number: -2146823276 }, E_UNDEFINED: { type: "TypeError", number: -2146823279 }, @@ -2673,6 +2724,15 @@ testArrayHostThis("join"); testArrayHostThis("pop"); testArrayHostThis("sort"); +function testEnumeratorThis(func) { + testThisExcept(Enumerator.prototype[func], "E_NOT_ENUMERATOR"); +} + +testEnumeratorThis("atEnd"); +testEnumeratorThis("item"); +testEnumeratorThis("moveFirst"); +testEnumeratorThis("moveNext"); + function testObjectInherit(obj, constr, ts, tls, vo) { ok(obj instanceof Object, "obj is not instance of Object"); ok(obj instanceof constr, "obj is not instance of its constructor"); @@ -2965,4 +3025,9 @@ ok(tmp.toArray() == "2,3,12,13,22,23,32,33,42,43", "tmp.toArray() = " + tmp.toAr ok(createArray().toArray() == "2,3,12,13,22,23,32,33,42,43", "createArray.toArray()=" + createArray().toArray()); +obj = new Enumerator(); +ok(obj.atEnd(), "atEnd() = " + obj.atEnd()); +obj.moveFirst(); +ok(obj.atEnd(), "atEnd() = " + obj.atEnd()); + reportSuccess(); diff --git a/modules/rostests/winetests/jscript/caller.c b/modules/rostests/winetests/jscript/caller.c index f09ad90d718..dc97fb72681 100644 --- a/modules/rostests/winetests/jscript/caller.c +++ b/modules/rostests/winetests/jscript/caller.c @@ -136,6 +136,9 @@ static void test_change_type(IVariantChangeType *change_type, VARIANT *src, cons call_change_type(change_type, &v, src, VT_I4); ok(V_I4(&v) == ex->int_result, "V_I4(v) = %d, expected %d\n", V_I4(&v), ex->int_result); + call_change_type(change_type, &v, src, VT_UI2); + ok(V_UI2(&v) == (UINT16)ex->int_result, "V_UI2(v) = %u, expected %u\n", V_UI2(&v), (UINT16)ex->int_result); + call_change_type(change_type, &v, src, VT_BSTR); ok(!strcmp_wa(V_BSTR(&v), ex->str_result), "V_BSTR(v) = %s, expected %s\n", wine_dbgstr_w(V_BSTR(&v)), ex->str_result); VariantClear(&v); diff --git a/modules/rostests/winetests/jscript/lang.js b/modules/rostests/winetests/jscript/lang.js index 2a30ea35a71..4812a066d15 100644 --- a/modules/rostests/winetests/jscript/lang.js +++ b/modules/rostests/winetests/jscript/lang.js @@ -180,6 +180,9 @@ ok(tmp === "undefined", "typeof((new Object).doesnotexist = " + tmp); tmp = typeof(testObj.onlyDispID); ok(tmp === "unknown", "typeof(testObj.onlyDispID) = " + tmp); +ok("\0\0x\0\0".length === 5, "\"\\0\\0x\\0\\0\".length = " + "\0\0x\0\0".length); +ok("\0\0x\0\0" === String.fromCharCode(0) + "\0x\0" + String.fromCharCode(0), "\"\\0\\0x\\0\\0\" unexpected"); + ok(testFunc1(true, "test") === true, "testFunc1 not returned true"); ok(testFunc1.arguments === null, "testFunc1.arguments = " + testFunc1.arguments); @@ -1523,7 +1526,7 @@ deleteTest = 1; delete deleteTest; try { tmp = deleteTest; - ok(false, "deleteTest not throwed exception?"); + ok(false, "deleteTest did not throw an exception?"); }catch(ex) {} (function() { diff --git a/modules/rostests/winetests/jscript/run.c b/modules/rostests/winetests/jscript/run.c index 77cd74ebb39..e3f272d46ca 100644 --- a/modules/rostests/winetests/jscript/run.c +++ b/modules/rostests/winetests/jscript/run.c @@ -90,7 +90,11 @@ DEFINE_EXPECT(global_success_i); DEFINE_EXPECT(global_notexists_d); DEFINE_EXPECT(global_propargput_d); DEFINE_EXPECT(global_propargput_i); +DEFINE_EXPECT(global_propargputop_d); +DEFINE_EXPECT(global_propargputop_get_i); +DEFINE_EXPECT(global_propargputop_put_i); DEFINE_EXPECT(global_testargtypes_i); +DEFINE_EXPECT(global_calleval_i); DEFINE_EXPECT(puredisp_prop_d); DEFINE_EXPECT(puredisp_noprop_d); DEFINE_EXPECT(puredisp_value); @@ -106,6 +110,10 @@ DEFINE_EXPECT(testobj_noprop_d); DEFINE_EXPECT(testobj_onlydispid_d); DEFINE_EXPECT(testobj_onlydispid_i); DEFINE_EXPECT(testobj_notexists_d); +DEFINE_EXPECT(testobj_newenum); +DEFINE_EXPECT(enumvariant_next_0); +DEFINE_EXPECT(enumvariant_next_1); +DEFINE_EXPECT(enumvariant_reset); DEFINE_EXPECT(GetItemInfo_testVal); DEFINE_EXPECT(ActiveScriptSite_OnScriptError); DEFINE_EXPECT(invoke_func); @@ -144,6 +152,9 @@ DEFINE_EXPECT(BindHandler); #define DISPID_GLOBAL_TESTPROPPUTREF 0x101b #define DISPID_GLOBAL_GETSCRIPTSTATE 0x101c #define DISPID_GLOBAL_BINDEVENTHANDLER 0x101d +#define DISPID_GLOBAL_TESTENUMOBJ 0x101e +#define DISPID_GLOBAL_CALLEVAL 0x101f +#define DISPID_GLOBAL_PROPARGPUTOP 0x1020 #define DISPID_GLOBAL_TESTPROPDELETE 0x2000 #define DISPID_GLOBAL_TESTNOPROPDELETE 0x2001 @@ -219,6 +230,101 @@ static void _test_grfdex(unsigned line, DWORD grfdex, DWORD expect) ok_(__FILE__,line)(grfdex == expect, "grfdex = %x, expected %x\n", grfdex, expect); } +static HRESULT WINAPI EnumVARIANT_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv) +{ + *ppv = NULL; + + if (IsEqualGUID(riid, &IID_IEnumVARIANT)) + *ppv = iface; + else + return E_NOINTERFACE; + + return S_OK; +} + +static ULONG WINAPI EnumVARIANT_AddRef(IEnumVARIANT *iface) +{ + return 2; +} + +static ULONG WINAPI EnumVARIANT_Release(IEnumVARIANT *iface) +{ + return 1; +} + +static int EnumVARIANT_index = 0; +static int EnumVARIANT_next_0_count = 0; +static HRESULT WINAPI EnumVARIANT_Next( + IEnumVARIANT *This, + ULONG celt, + VARIANT *rgVar, + ULONG *pCeltFetched) +{ + ok(rgVar != NULL, "rgVar is NULL\n"); + ok(celt == 1, "celt = %d\n", celt); + ok(pCeltFetched == NULL, "pCeltFetched is not NULL\n"); + + if (!rgVar) + return S_FALSE; + + if (EnumVARIANT_index == 0) + { + EnumVARIANT_next_0_count--; + if (EnumVARIANT_next_0_count <= 0) + CHECK_EXPECT(enumvariant_next_0); + + V_VT(rgVar) = VT_I4; + V_I4(rgVar) = 123; + + if (pCeltFetched) + *pCeltFetched = 1; + EnumVARIANT_index++; + return S_OK; + } + + CHECK_EXPECT(enumvariant_next_1); + + if (pCeltFetched) + *pCeltFetched = 0; + return S_FALSE; + +} + +static HRESULT WINAPI EnumVARIANT_Skip( + IEnumVARIANT *This, + ULONG celt) +{ + ok(0, "EnumVariant_Skip: unexpected call\n"); + return E_NOTIMPL; +} +static HRESULT WINAPI EnumVARIANT_Reset( + IEnumVARIANT *This) +{ + CHECK_EXPECT(enumvariant_reset); + EnumVARIANT_index = 0; + return S_OK; +} + +static HRESULT WINAPI EnumVARIANT_Clone( + IEnumVARIANT *This, + IEnumVARIANT **ppEnum) +{ + ok(0, "EnumVariant_Clone: unexpected call\n"); + return E_NOTIMPL; +} + +static IEnumVARIANTVtbl testEnumVARIANTVtbl = { + EnumVARIANT_QueryInterface, + EnumVARIANT_AddRef, + EnumVARIANT_Release, + EnumVARIANT_Next, + EnumVARIANT_Skip, + EnumVARIANT_Reset, + EnumVARIANT_Clone +}; + +static IEnumVARIANT testEnumVARIANT = { &testEnumVARIANTVtbl }; + static HRESULT WINAPI DispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv) { *ppv = NULL; @@ -252,7 +358,6 @@ static HRESULT WINAPI DispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pcti static HRESULT WINAPI DispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo) { - ok(0, "unexpected call\n"); return E_NOTIMPL; } @@ -321,6 +426,28 @@ static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown return E_NOTIMPL; } +static HRESULT WINAPI testObj_Invoke(IDispatchEx *iface, DISPID id, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdp, + VARIANT *pvarRes, EXCEPINFO *pei, UINT *puArgErr) +{ + switch(id) { + case DISPID_NEWENUM: + ok(pdp != NULL, "pdp == NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pvarRes != NULL, "pvarRes == NULL\n"); + ok(pei == NULL, "pei != NULL\n"); + + CHECK_EXPECT(testobj_newenum); + V_VT(pvarRes) = VT_DISPATCH; + V_DISPATCH(pvarRes) = (IDispatch*)&testEnumVARIANT; + return S_OK; + } + + ok(0, "unexpected call %x\n", id); + return DISP_E_MEMBERNOTFOUND; +} + static HRESULT WINAPI testObj_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid) { if(!strcmp_wa(bstrName, "prop")) { @@ -454,7 +581,7 @@ static IDispatchExVtbl testObjVtbl = { DispatchEx_GetTypeInfoCount, DispatchEx_GetTypeInfo, DispatchEx_GetIDsOfNames, - DispatchEx_Invoke, + testObj_Invoke, testObj_GetDispID, testObj_InvokeEx, testObj_DeleteMemberByName, @@ -805,6 +932,13 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD return S_OK; } + if(!strcmp_wa(bstrName, "propArgPutOp")) { + CHECK_EXPECT(global_propargputop_d); + test_grfdex(grfdex, fdexNameCaseSensitive); + *pid = DISPID_GLOBAL_PROPARGPUTOP; + return S_OK; + } + if(!strcmp_wa(bstrName, "propArgPutO")) { CHECK_EXPECT(global_propargput_d); test_grfdex(grfdex, fdexNameEnsure|fdexNameCaseSensitive); @@ -862,6 +996,16 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD return S_OK; } + if(!strcmp_wa(bstrName, "testEnumObj")) { + *pid = DISPID_GLOBAL_TESTENUMOBJ; + return S_OK; + } + + if(!strcmp_wa(bstrName, "callEval")) { + *pid = DISPID_GLOBAL_CALLEVAL; + return S_OK; + } + if(strict_dispid_check && strcmp_wa(bstrName, "t")) ok(0, "unexpected call %s\n", wine_dbgstr_w(bstrName)); return DISP_E_UNKNOWNNAME; @@ -1253,6 +1397,55 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2)); return S_OK; + case DISPID_GLOBAL_PROPARGPUTOP: + ok(pdp != NULL, "pdp == NULL\n"); + ok(pdp->rgvarg != NULL, "rgvarg != NULL\n"); + ok(pei != NULL, "pei == NULL\n"); + + switch(wFlags) { + case INVOKE_PROPERTYGET | INVOKE_FUNC: + CHECK_EXPECT(global_propargputop_get_i); + + ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(pdp->cArgs == 2, "cArgs = %d\n", pdp->cArgs); + ok(pdp->cNamedArgs == 0, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pvarRes != NULL, "pvarRes = NULL\n"); + + ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg)); + ok(V_I4(pdp->rgvarg) == 1, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg)); + + ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1)); + ok(V_I4(pdp->rgvarg+1) == 0, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1)); + + V_VT(pvarRes) = VT_I4; + V_I4(pvarRes) = 6; + break; + case INVOKE_PROPERTYPUT: + CHECK_EXPECT(global_propargputop_put_i); + + ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pdp->rgdispidNamedArgs[0] == DISPID_PROPERTYPUT, "pdp->rgdispidNamedArgs[0] = %d\n", pdp->rgdispidNamedArgs[0]); + ok(pdp->rgdispidNamedArgs != NULL, "rgdispidNamedArgs == NULL\n"); + ok(pdp->cArgs == 3, "cArgs = %d\n", pdp->cArgs); + ok(pdp->cNamedArgs == 1, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(!pvarRes, "pvarRes != NULL\n"); + + ok(V_VT(pdp->rgvarg) == VT_I4, "V_VT(pdp->rgvarg) = %d\n", V_VT(pdp->rgvarg)); + ok(V_I4(pdp->rgvarg) == 8, "V_I4(pdp->rgvarg) = %d\n", V_I4(pdp->rgvarg)); + + ok(V_VT(pdp->rgvarg+1) == VT_I4, "V_VT(pdp->rgvarg+1) = %d\n", V_VT(pdp->rgvarg+1)); + ok(V_I4(pdp->rgvarg+1) == 1, "V_I4(pdp->rgvarg+1) = %d\n", V_I4(pdp->rgvarg+1)); + + ok(V_VT(pdp->rgvarg+2) == VT_I4, "V_VT(pdp->rgvarg+2) = %d\n", V_VT(pdp->rgvarg+2)); + ok(V_I4(pdp->rgvarg+2) == 0, "V_I4(pdp->rgvarg+2) = %d\n", V_I4(pdp->rgvarg+2)); + break; + default: + ok(0, "wFlags = %x\n", wFlags); + } + + return S_OK; + case DISPID_GLOBAL_OBJECT_FLAG: { IDispatchEx *dispex; BSTR str; @@ -1315,7 +1508,7 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, return S_OK; case DISPID_GLOBAL_TESTARGTYPES: { - VARIANT args[8], v; + VARIANT args[10], v; DISPPARAMS dp = {args, NULL, ARRAY_SIZE(args), 0}; HRESULT hres; @@ -1358,7 +1551,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, V_VT(args+6) = VT_R4; V_R4(args+6) = 0.5; V_VT(args+7) = VT_UI2; - V_R4(args+7) = 3; + V_UI2(args+7) = 3; + V_VT(args+8) = VT_UI1; + V_UI1(args+8) = 4; + V_VT(args+9) = VT_I1; + V_I1(args+9) = 5; V_VT(&v) = VT_I4; V_I4(&v) = 2; hres = IDispatch_Invoke(V_DISPATCH(pdp->rgvarg), DISPID_VALUE, &IID_NULL, 0, DISPATCH_METHOD, &dp, NULL, NULL, NULL); @@ -1366,6 +1563,43 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, return S_OK; } + + case DISPID_GLOBAL_CALLEVAL: { + IDispatchEx *eval_func; + DISPPARAMS params; + VARIANT arg, res; + HRESULT hres; + + CHECK_EXPECT(global_calleval_i); + + ok(pdp != NULL, "pdp == NULL\n"); + ok(pdp->rgvarg != NULL, "rgvarg == NULL\n"); + ok(!pdp->rgdispidNamedArgs, "rgdispidNamedArgs != NULL\n"); + ok(pdp->cArgs == 1, "cArgs = %d\n", pdp->cArgs); + ok(!pdp->cNamedArgs, "cNamedArgs = %d\n", pdp->cNamedArgs); + ok(pvarRes == NULL, "pvarRes != NULL\n"); + ok(pei != NULL, "pei == NULL\n"); + + ok(V_VT(pdp->rgvarg) == VT_DISPATCH, "V_VT(arg) = %d\n", V_VT(pdp->rgvarg)); + hres = IDispatch_QueryInterface(V_DISPATCH(pdp->rgvarg), &IID_IDispatchEx, (void**)&eval_func); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres); + + params.rgvarg = &arg; + params.rgdispidNamedArgs = NULL; + params.cArgs = 1; + params.cNamedArgs = 0; + V_VT(&arg) = VT_BSTR; + + V_BSTR(&arg) = a2bstr("var x = 5; v"); + V_VT(&res) = VT_ERROR; + hres = IDispatchEx_InvokeEx(eval_func, DISPID_VALUE, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res)); + ok(V_I4(&res) == 2, "eval returned %d\n", V_I4(&res)); + SysFreeString(V_BSTR(&arg)); + IDispatchEx_Release(eval_func); + return S_OK; + } } ok(0, "unexpected call %x\n", id); @@ -2366,6 +2600,107 @@ static void test_invokeex(void) IActiveScript_Release(script); } +static void test_eval(void) +{ + IActiveScriptParse *parser; + IDispatchEx *script_dispex; + IDispatch *script_disp; + IActiveScript *engine; + VARIANT arg, res; + DISPPARAMS params; + DISPID id, v_id; + BSTR str; + HRESULT hres; + + engine = create_script(); + + hres = IActiveScript_QueryInterface(engine, &IID_IActiveScriptParse, (void**)&parser); + ok(hres == S_OK, "Could not get IActiveScriptParse: %08x\n", hres); + + hres = IActiveScriptParse_InitNew(parser); + ok(hres == S_OK, "InitNew failed: %08x\n", hres); + + hres = IActiveScript_SetScriptSite(engine, &ActiveScriptSite); + ok(hres == S_OK, "SetScriptSite failed: %08x\n", hres); + + SET_EXPECT(GetItemInfo_testVal); + hres = IActiveScript_AddNamedItem(engine, test_valW, + SCRIPTITEM_ISVISIBLE|SCRIPTITEM_ISSOURCE|SCRIPTITEM_GLOBALMEMBERS); + ok(hres == S_OK, "AddNamedItem failed: %08x\n", hres); + CHECK_CALLED(GetItemInfo_testVal); + + hres = IActiveScript_SetScriptState(engine, SCRIPTSTATE_STARTED); + ok(hres == S_OK, "SetScriptState(SCRIPTSTATE_STARTED) failed: %08x\n", hres); + + hres = IActiveScript_GetScriptDispatch(engine, NULL, &script_disp); + ok(hres == S_OK, "GetScriptDispatch failed: %08x\n", hres); + ok(script_disp != NULL, "script_disp == NULL\n"); + + hres = IDispatch_QueryInterface(script_disp, &IID_IDispatchEx, (void**)&script_dispex); + ok(hres == S_OK, "Could not get IDispatchEx iface: %08x\n", hres); + IDispatch_Release(script_disp); + + str = a2bstr("eval"); + hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id); + ok(hres == S_OK, "Could not get eval dispid: %08x\n", hres); + SysFreeString(str); + + params.rgvarg = &arg; + params.rgdispidNamedArgs = NULL; + params.cArgs = 1; + params.cNamedArgs = 0; + V_VT(&arg) = VT_BSTR; + + V_BSTR(&arg) = a2bstr("var v = 1;"); + V_VT(&res) = VT_ERROR; + hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&res) == VT_EMPTY, "eval returned type %u\n", V_VT(&res)); + SysFreeString(V_BSTR(&arg)); + + V_BSTR(&arg) = a2bstr("v"); + V_VT(&res) = VT_ERROR; + hres = IDispatchEx_InvokeEx(script_dispex, id, 0, DISPATCH_METHOD, ¶ms, &res, NULL, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res)); + ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res)); + SysFreeString(V_BSTR(&arg)); + + str = a2bstr("v"); + hres = IDispatchEx_GetDispID(script_dispex, str, 0, &v_id); + ok(hres == S_OK, "Could not get v dispid: %08x\n", hres); + SysFreeString(str); + + params.rgvarg = NULL; + params.cArgs = 0; + V_VT(&res) = VT_ERROR; + hres = IDispatchEx_InvokeEx(script_dispex, v_id, 0, DISPATCH_PROPERTYGET, ¶ms, &res, NULL, NULL); + ok(hres == S_OK, "InvokeEx failed: %08x\n", hres); + ok(V_VT(&res) == VT_I4, "eval returned type %u\n", V_VT(&res)); + ok(V_I4(&res) == 1, "eval returned %d\n", V_I4(&res)); + + SET_EXPECT(global_calleval_i); + str = a2bstr("(function(){" + " var v = 2;" + " callEval(eval);" + " ok(x === 5, 'x = ' + x);" + "})();"); + hres = IActiveScriptParse_ParseScriptText(parser, str, NULL, NULL, NULL, 0, 0, 0, NULL, NULL); + ok(hres == S_OK, "ParseScriptText failed: %08x\n", hres); + SysFreeString(str); + CHECK_CALLED(global_calleval_i); + + str = a2bstr("x"); + hres = IDispatchEx_GetDispID(script_dispex, str, 0, &id); + ok(hres == DISP_E_UNKNOWNNAME, "GetDispID(x) returned %08x\n", hres); + SysFreeString(str); + + IDispatchEx_Release(script_dispex); + IActiveScriptParse_Release(parser); + IActiveScript_Close(engine); + IActiveScript_Release(engine); +} + struct bom_test { WCHAR str[1024]; @@ -2651,9 +2986,25 @@ static BOOL run_tests(void) CHECK_CALLED(global_propargput_d); CHECK_CALLED(global_propargput_i); + SET_EXPECT(global_propargputop_d); + SET_EXPECT(global_propargputop_get_i); + SET_EXPECT(global_propargputop_put_i); + parse_script_a("var t=0; propArgPutOp(t++, t++) += t++;"); + CHECK_CALLED(global_propargputop_d); + CHECK_CALLED(global_propargputop_get_i); + CHECK_CALLED(global_propargputop_put_i); + + SET_EXPECT(global_propargputop_d); + SET_EXPECT(global_propargputop_get_i); + SET_EXPECT(global_propargputop_put_i); + parse_script_a("var t=0; propArgPutOp(t++, t++) ^= 14;"); + CHECK_CALLED(global_propargputop_d); + CHECK_CALLED(global_propargputop_get_i); + CHECK_CALLED(global_propargputop_put_i); + SET_EXPECT(global_testargtypes_i); parse_script_a("testArgTypes(dispUnk, intProp(), intProp, getShort(), shortProp," - "function(ui2,r4,i4ref,ui4,nullunk,d,i,s) {" + "function(i1,ui1,ui2,r4,i4ref,ui4,nullunk,d,i,s) {" " ok(getVT(i) === 'VT_I4', 'getVT(i) = ' + getVT(i));" " ok(getVT(s) === 'VT_I4', 'getVT(s) = ' + getVT(s));" " ok(getVT(d) === 'VT_DISPATCH', 'getVT(d) = ' + getVT(d));" @@ -2666,6 +3017,10 @@ static BOOL run_tests(void) " ok(r4 === 0.5, 'r4 = ' + r4);" " ok(getVT(r4) === 'VT_R8', 'getVT(r4) = ' + getVT(r4));" " ok(getVT(ui2) === 'VT_I4', 'getVT(ui2) = ' + getVT(ui2));" + " ok(getVT(ui1) === 'VT_I4', 'getVT(ui1) = ' + getVT(ui1));" + " ok(ui1 === 4, 'ui1 = ' + ui1);" + " ok(getVT(i1) === 'VT_I4', 'getVT(i1) = ' + getVT(i1));" + " ok(i1 === 5, 'i1 = ' + i1);" "});"); CHECK_CALLED(global_testargtypes_i); @@ -2683,6 +3038,46 @@ static BOOL run_tests(void) CHECK_CALLED(global_success_d); CHECK_CALLED(global_success_i); + EnumVARIANT_index = 0; + EnumVARIANT_next_0_count = 1; + SET_EXPECT(testobj_newenum); + SET_EXPECT(enumvariant_next_0); + parse_script_a("new Enumerator(testObj);"); + CHECK_CALLED(testobj_newenum); + CHECK_CALLED(enumvariant_next_0); + + EnumVARIANT_index = 0; + EnumVARIANT_next_0_count = 2; + SET_EXPECT(testobj_newenum); + SET_EXPECT(enumvariant_next_0); + SET_EXPECT(enumvariant_reset); + parse_script_a("(function () {" + " var testEnumObj = new Enumerator(testObj);" + " var tmp = testEnumObj.moveFirst();" + " ok(tmp == undefined, \"testEnumObj.moveFirst() = \" + tmp);" + "})()"); + CHECK_CALLED(testobj_newenum); + CHECK_CALLED(enumvariant_next_0); + CHECK_CALLED(enumvariant_reset); + + EnumVARIANT_index = 0; + EnumVARIANT_next_0_count = 1; + SET_EXPECT(testobj_newenum); + SET_EXPECT(enumvariant_next_0); + SET_EXPECT(enumvariant_next_1); + parse_script_a("(function () {" + " var testEnumObj = new Enumerator(testObj);" + " while (!testEnumObj.atEnd())" + " {" + " ok(testEnumObj.item() == 123, " + " \"testEnumObj.item() = \"+testEnumObj.item());" + " testEnumObj.moveNext();" + " }" + "})()"); + CHECK_CALLED(testobj_newenum); + CHECK_CALLED(enumvariant_next_0); + CHECK_CALLED(enumvariant_next_1); + run_from_res("lang.js"); run_from_res("api.js"); run_from_res("regexp.js"); @@ -2711,6 +3106,7 @@ static BOOL run_tests(void) test_script_exprs(); test_invokeex(); + test_eval(); parse_script_with_error_a( "?",
5 years, 1 month
1
0
0
0
[reactos] 01/01: [JSCRIPT] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e2d6582b792e09696d1f…
commit 3e2d6582b792e09696d1f4ff693e58c78129f32c Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:38:06 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:38:06 2019 +0100 [JSCRIPT] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/jscript/activex.c | 2 - dll/win32/jscript/array.c | 97 ++- dll/win32/jscript/cc_parser.tab.c | 406 ++++++------ dll/win32/jscript/cc_parser.tab.h | 15 +- dll/win32/jscript/cc_parser.y | 2 +- dll/win32/jscript/compile.c | 133 ++-- dll/win32/jscript/date.c | 63 +- dll/win32/jscript/decode.c | 4 +- dll/win32/jscript/dispex.c | 69 +- dll/win32/jscript/engine.c | 22 +- dll/win32/jscript/engine.h | 2 +- dll/win32/jscript/enumerator.c | 4 +- dll/win32/jscript/error.c | 12 +- dll/win32/jscript/function.c | 483 +++++++++----- dll/win32/jscript/global.c | 43 +- dll/win32/jscript/jscript.h | 16 +- dll/win32/jscript/json.c | 24 +- dll/win32/jscript/jsregexp.c | 4 +- dll/win32/jscript/jsstr.h | 2 +- dll/win32/jscript/jsutils.c | 34 +- dll/win32/jscript/lex.c | 247 +++---- dll/win32/jscript/math.c | 6 +- dll/win32/jscript/number.c | 2 +- dll/win32/jscript/object.c | 144 ++++- dll/win32/jscript/parser.h | 12 +- dll/win32/jscript/parser.tab.c | 1272 +++++++++++++++++++------------------ dll/win32/jscript/parser.tab.h | 17 +- dll/win32/jscript/parser.y | 23 +- dll/win32/jscript/regexp.c | 28 +- dll/win32/jscript/string.c | 77 ++- media/doc/README.WINE | 2 +- 31 files changed, 1858 insertions(+), 1409 deletions(-) diff --git a/dll/win32/jscript/activex.c b/dll/win32/jscript/activex.c index c7d9a66911a..1c2631cc774 100644 --- a/dll/win32/jscript/activex.c +++ b/dll/win32/jscript/activex.c @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" #include "jscript.h" #include "objsafe.h" diff --git a/dll/win32/jscript/array.c b/dll/win32/jscript/array.c index 2dbb593bd68..fbd72e84be5 100644 --- a/dll/win32/jscript/array.c +++ b/dll/win32/jscript/array.c @@ -16,8 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> #include <assert.h> @@ -49,6 +51,7 @@ static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; static const WCHAR toLocaleStringW[] = {'t','o','L','o','c','a','l','e','S','t','r','i','n','g',0}; static const WCHAR unshiftW[] = {'u','n','s','h','i','f','t',0}; static const WCHAR indexOfW[] = {'i','n','d','e','x','O','f',0}; +static const WCHAR mapW[] = {'m','a','p',0}; static const WCHAR default_separatorW[] = {',',0}; @@ -355,7 +358,7 @@ static HRESULT Array_join(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigne jsstr_release(sep_str); }else { - hres = array_join(ctx, jsthis, length, default_separatorW, strlenW(default_separatorW), r); + hres = array_join(ctx, jsthis, length, default_separatorW, lstrlenW(default_separatorW), r); } return hres; @@ -941,7 +944,7 @@ static HRESULT Array_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un return throw_type_error(ctx, JS_E_ARRAY_EXPECTED, NULL); return array_join(ctx, &array->dispex, array->length, default_separatorW, - strlenW(default_separatorW), r); + lstrlenW(default_separatorW), r); } static HRESULT Array_toLocaleString(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, @@ -961,16 +964,21 @@ static HRESULT Array_forEach(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi TRACE("\n"); - /* FIXME: Check IsCallable */ - if(argc != 1 || !is_object_instance(argv[0])) { - FIXME("Unsupported arguments\n"); - return E_NOTIMPL; - } - hres = get_length(ctx, vthis, &jsthis, &length); if(FAILED(hres)) return hres; + /* Fixme check IsCallable */ + if(!argc || !is_object_instance(argv[0]) || !get_object(argv[0])) { + FIXME("Invalid arg %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined())); + return E_INVALIDARG; + } + + if(argc > 1 && !is_undefined(argv[1])) { + FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1])); + return E_NOTIMPL; + } + for(i = 0; i < length; i++) { hres = jsdisp_get_idx(jsthis, i, &value); if(hres == DISP_E_UNKNOWNNAME) @@ -1047,6 +1055,68 @@ static HRESULT Array_indexOf(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsi return S_OK; } +static HRESULT Array_map(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) +{ + IDispatch *context_this = NULL, *callback; + jsval_t callback_args[3], mapped_value; + jsdisp_t *jsthis, *array; + DWORD length, k; + HRESULT hres; + + TRACE("\n"); + + hres = get_length(ctx, vthis, &jsthis, &length); + if(FAILED(hres)) { + FIXME("Could not get length\n"); + return hres; + } + + /* Fixme check IsCallable */ + if(!argc || !is_object_instance(argv[0]) || !get_object(argv[0])) { + FIXME("Invalid arg %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined())); + return E_INVALIDARG; + } + callback = get_object(argv[0]); + + if(argc > 1) { + if(is_object_instance(argv[1]) && get_object(argv[1])) { + context_this = get_object(argv[1]); + }else if(!is_undefined(argv[1])) { + FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1])); + return E_NOTIMPL; + } + } + + hres = create_array(ctx, length, &array); + if(FAILED(hres)) + return hres; + + for(k = 0; k < length; k++) { + hres = jsdisp_get_idx(jsthis, k, &callback_args[0]); + if(hres == DISP_E_UNKNOWNNAME) + continue; + if(FAILED(hres)) + break; + + callback_args[1] = jsval_number(k); + callback_args[2] = jsval_obj(jsthis); + hres = disp_call_value(ctx, callback, context_this, DISPATCH_METHOD, 3, callback_args, &mapped_value); + jsval_release(callback_args[0]); + if(FAILED(hres)) + break; + + hres = jsdisp_propput_idx(array, k, mapped_value); + if(FAILED(hres)) + break; + } + + if(SUCCEEDED(hres) && r) + *r = jsval_obj(array); + else + jsdisp_release(array); + return hres; +} + /* ECMA-262 3rd Edition 15.4.4.13 */ static HRESULT Array_unshift(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) @@ -1114,7 +1184,7 @@ static HRESULT Array_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r) TRACE("\n"); return array_join(ctx, &array->dispex, array->length, default_separatorW, - strlenW(default_separatorW), r); + lstrlenW(default_separatorW), r); } static void Array_destructor(jsdisp_t *dispex) @@ -1128,10 +1198,10 @@ static void Array_on_put(jsdisp_t *dispex, const WCHAR *name) const WCHAR *ptr = name; DWORD id = 0; - if(!isdigitW(*ptr)) + if(!iswdigit(*ptr)) return; - while(*ptr && isdigitW(*ptr)) { + while(*ptr && iswdigit(*ptr)) { id = id*10 + (*ptr-'0'); ptr++; } @@ -1149,6 +1219,7 @@ static const builtin_prop_t Array_props[] = { {indexOfW, Array_indexOf, PROPF_METHOD|PROPF_ES5|1}, {joinW, Array_join, PROPF_METHOD|1}, {lengthW, NULL,0, Array_get_length, Array_set_length}, + {mapW, Array_map, PROPF_METHOD|PROPF_ES5|1}, {popW, Array_pop, PROPF_METHOD}, {pushW, Array_push, PROPF_METHOD|1}, {reverseW, Array_reverse, PROPF_METHOD}, diff --git a/dll/win32/jscript/cc_parser.tab.c b/dll/win32/jscript/cc_parser.tab.c index 2e46c119532..beafd15e5c2 100644 --- a/dll/win32/jscript/cc_parser.tab.c +++ b/dll/win32/jscript/cc_parser.tab.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0. */ +/* A Bison parser, made by GNU Bison 3.4.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0" +#define YYBISON_VERSION "3.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,8 +71,8 @@ #define yynerrs cc_parser_nerrs -/* Copy the first part of user declarations. */ -#line 19 "cc_parser.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 19 "cc_parser.y" #include "jscript.h" @@ -80,13 +84,17 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); -#line 84 "cc_parser.tab.c" /* yacc.c:339 */ +#line 88 "cc_parser.tab.c" -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULL 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -98,8 +106,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "cc_parser.tab.h". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_CC_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_CC_PARSER_TAB_H_INCLUDED # define YY_CC_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_CC_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -132,15 +140,16 @@ extern int cc_parser_debug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 36 "cc_parser.y" /* yacc.c:355 */ +#line 36 "cc_parser.y" ccval_t ccval; -#line 143 "cc_parser.tab.c" /* yacc.c:355 */ +#line 150 "cc_parser.tab.c" + }; +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif @@ -151,8 +160,8 @@ int cc_parser_parse (parser_ctx_t *ctx); #endif /* !YY_CC_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_CC_PARSER_TAB_H_INCLUDED */ -/* Copy the second part of user declarations. */ -#line 47 "cc_parser.y" /* yacc.c:358 */ +/* Second part of user prologue. */ +#line 47 "cc_parser.y" static int cc_parser_error(parser_ctx_t *ctx, const char *str) @@ -246,7 +255,8 @@ static int cc_parser_lex(void *lval, parser_ctx_t *ctx) } -#line 250 "cc_parser.tab.c" /* yacc.c:358 */ +#line 259 "cc_parser.tab.c" + #ifdef short # undef short @@ -267,13 +277,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -285,7 +295,7 @@ typedef short int yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -303,14 +313,24 @@ typedef short int yytype_int16; # endif #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -318,7 +338,7 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -338,6 +358,8 @@ typedef short int yytype_int16; #endif +#define YY_ASSERT(E) ((void) (0 && (E))) + #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -480,16 +502,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 69 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 269 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -545,7 +567,7 @@ static const char *const yytname[] = "CCBitwiseORExpression", "CCBitwiseXORExpression", "CCBitwiseANDExpression", "CCEqualityExpression", "CCRelationalExpression", "CCShiftExpression", "CCAdditiveExpression", - "CCMultiplicativeExpression", YY_NULL + "CCMultiplicativeExpression", YY_NULLPTR }; #endif @@ -678,22 +700,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (ctx, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (ctx, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -733,38 +755,38 @@ do { \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); YYUSE (ctx); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep, ctx); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -798,7 +820,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_ctx_t *ctx) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -809,7 +831,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_ctx_t * YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] , ctx); YYFPRINTF (stderr, "\n"); } @@ -913,7 +935,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -931,7 +956,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -947,11 +972,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1008,11 +1033,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1024,6 +1049,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1035,9 +1061,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1168,23 +1195,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1200,14 +1237,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1223,35 +1256,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1309,7 +1340,6 @@ yybackup: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END - goto yynewstate; @@ -1324,7 +1354,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1344,236 +1374,237 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 146 "cc_parser.y" /* yacc.c:1646 */ + case 2: +#line 146 "cc_parser.y" { ctx->ccval = (yyvsp[0].ccval); YYACCEPT; } -#line 1351 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1381 "cc_parser.tab.c" break; case 3: -#line 149 "cc_parser.y" /* yacc.c:1646 */ +#line 149 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1357 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1387 "cc_parser.tab.c" break; case 4: -#line 150 "cc_parser.y" /* yacc.c:1646 */ +#line 150 "cc_parser.y" { (yyval.ccval) = (yyvsp[-1].ccval); } -#line 1363 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1393 "cc_parser.tab.c" break; case 5: -#line 151 "cc_parser.y" /* yacc.c:1646 */ +#line 151 "cc_parser.y" { (yyval.ccval) = ccval_bool(!get_ccbool((yyvsp[0].ccval))); } -#line 1369 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1399 "cc_parser.tab.c" break; case 6: -#line 152 "cc_parser.y" /* yacc.c:1646 */ +#line 152 "cc_parser.y" { FIXME("'~' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1375 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1405 "cc_parser.tab.c" break; case 7: -#line 153 "cc_parser.y" /* yacc.c:1646 */ +#line 153 "cc_parser.y" { FIXME("'+' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1381 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1411 "cc_parser.tab.c" break; case 8: -#line 154 "cc_parser.y" /* yacc.c:1646 */ +#line 154 "cc_parser.y" { FIXME("'-' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1387 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1417 "cc_parser.tab.c" break; case 9: -#line 157 "cc_parser.y" /* yacc.c:1646 */ +#line 157 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1393 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1423 "cc_parser.tab.c" break; case 10: -#line 159 "cc_parser.y" /* yacc.c:1646 */ +#line 159 "cc_parser.y" { FIXME("'||' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1399 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1429 "cc_parser.tab.c" break; case 11: -#line 162 "cc_parser.y" /* yacc.c:1646 */ +#line 162 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1405 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1435 "cc_parser.tab.c" break; case 12: -#line 164 "cc_parser.y" /* yacc.c:1646 */ +#line 164 "cc_parser.y" { FIXME("'&&' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1411 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1441 "cc_parser.tab.c" break; case 13: -#line 167 "cc_parser.y" /* yacc.c:1646 */ +#line 167 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1417 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1447 "cc_parser.tab.c" break; case 14: -#line 169 "cc_parser.y" /* yacc.c:1646 */ +#line 169 "cc_parser.y" { FIXME("'|' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1423 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1453 "cc_parser.tab.c" break; case 15: -#line 172 "cc_parser.y" /* yacc.c:1646 */ +#line 172 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1429 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1459 "cc_parser.tab.c" break; case 16: -#line 174 "cc_parser.y" /* yacc.c:1646 */ +#line 174 "cc_parser.y" { FIXME("'^' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1435 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1465 "cc_parser.tab.c" break; case 17: -#line 177 "cc_parser.y" /* yacc.c:1646 */ +#line 177 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1441 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1471 "cc_parser.tab.c" break; case 18: -#line 179 "cc_parser.y" /* yacc.c:1646 */ +#line 179 "cc_parser.y" { FIXME("'&' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1447 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1477 "cc_parser.tab.c" break; case 19: -#line 182 "cc_parser.y" /* yacc.c:1646 */ +#line 182 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1453 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1483 "cc_parser.tab.c" break; case 20: -#line 184 "cc_parser.y" /* yacc.c:1646 */ +#line 184 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) == get_ccnum((yyvsp[0].ccval))); } -#line 1459 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1489 "cc_parser.tab.c" break; case 21: -#line 186 "cc_parser.y" /* yacc.c:1646 */ +#line 186 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) != get_ccnum((yyvsp[0].ccval))); } -#line 1465 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1495 "cc_parser.tab.c" break; case 22: -#line 188 "cc_parser.y" /* yacc.c:1646 */ +#line 188 "cc_parser.y" { FIXME("'===' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1471 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1501 "cc_parser.tab.c" break; case 23: -#line 190 "cc_parser.y" /* yacc.c:1646 */ +#line 190 "cc_parser.y" { FIXME("'!==' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1477 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1507 "cc_parser.tab.c" break; case 24: -#line 193 "cc_parser.y" /* yacc.c:1646 */ +#line 193 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1483 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1513 "cc_parser.tab.c" break; case 25: -#line 195 "cc_parser.y" /* yacc.c:1646 */ +#line 195 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) < get_ccnum((yyvsp[0].ccval))); } -#line 1489 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1519 "cc_parser.tab.c" break; case 26: -#line 197 "cc_parser.y" /* yacc.c:1646 */ +#line 197 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) <= get_ccnum((yyvsp[0].ccval))); } -#line 1495 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1525 "cc_parser.tab.c" break; case 27: -#line 199 "cc_parser.y" /* yacc.c:1646 */ +#line 199 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) > get_ccnum((yyvsp[0].ccval))); } -#line 1501 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1531 "cc_parser.tab.c" break; case 28: -#line 201 "cc_parser.y" /* yacc.c:1646 */ +#line 201 "cc_parser.y" { (yyval.ccval) = ccval_bool(get_ccnum((yyvsp[-2].ccval)) >= get_ccnum((yyvsp[0].ccval))); } -#line 1507 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1537 "cc_parser.tab.c" break; case 29: -#line 204 "cc_parser.y" /* yacc.c:1646 */ +#line 204 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1513 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1543 "cc_parser.tab.c" break; case 30: -#line 206 "cc_parser.y" /* yacc.c:1646 */ +#line 206 "cc_parser.y" { FIXME("'<<' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1519 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1549 "cc_parser.tab.c" break; case 31: -#line 208 "cc_parser.y" /* yacc.c:1646 */ +#line 208 "cc_parser.y" { FIXME("'>>' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1525 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1555 "cc_parser.tab.c" break; case 32: -#line 210 "cc_parser.y" /* yacc.c:1646 */ +#line 210 "cc_parser.y" { FIXME("'>>>' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1531 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1561 "cc_parser.tab.c" break; case 33: -#line 213 "cc_parser.y" /* yacc.c:1646 */ +#line 213 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1537 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1567 "cc_parser.tab.c" break; case 34: -#line 215 "cc_parser.y" /* yacc.c:1646 */ +#line 215 "cc_parser.y" { (yyval.ccval) = ccval_num(get_ccnum((yyvsp[-2].ccval)) + get_ccnum((yyvsp[0].ccval))); } -#line 1543 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1573 "cc_parser.tab.c" break; case 35: -#line 217 "cc_parser.y" /* yacc.c:1646 */ +#line 217 "cc_parser.y" { (yyval.ccval) = ccval_num(get_ccnum((yyvsp[-2].ccval)) - get_ccnum((yyvsp[0].ccval))); } -#line 1549 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1579 "cc_parser.tab.c" break; case 36: -#line 220 "cc_parser.y" /* yacc.c:1646 */ +#line 220 "cc_parser.y" { (yyval.ccval) = (yyvsp[0].ccval); } -#line 1555 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1585 "cc_parser.tab.c" break; case 37: -#line 222 "cc_parser.y" /* yacc.c:1646 */ +#line 222 "cc_parser.y" { (yyval.ccval) = ccval_num(get_ccnum((yyvsp[-2].ccval)) * get_ccnum((yyvsp[0].ccval))); } -#line 1561 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1591 "cc_parser.tab.c" break; case 38: -#line 224 "cc_parser.y" /* yacc.c:1646 */ +#line 224 "cc_parser.y" { (yyval.ccval) = ccval_num(get_ccnum((yyvsp[-2].ccval)) / get_ccnum((yyvsp[0].ccval))); } -#line 1567 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1597 "cc_parser.tab.c" break; case 39: -#line 226 "cc_parser.y" /* yacc.c:1646 */ +#line 226 "cc_parser.y" { FIXME("'%%' expression not implemented\n"); ctx->hres = E_NOTIMPL; YYABORT; } -#line 1573 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1603 "cc_parser.tab.c" break; -#line 1577 "cc_parser.tab.c" /* yacc.c:1646 */ +#line 1607 "cc_parser.tab.c" + default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1598,14 +1629,13 @@ yyreduce: /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; - if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTOKENS]; + { + const int yylhs = yyr1[yyn] - YYNTOKENS; + const int yyi = yypgoto[yylhs] + *yyssp; + yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp + ? yytable[yyi] + : yydefgoto[yylhs]); + } goto yynewstate; @@ -1688,12 +1718,10 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - - /* Pacify compilers like GCC when the user code never invokes - YYERROR and the label yyerrorlab therefore never appears in user - code. */ - if (/*CONSTCOND*/ 0) - goto yyerrorlab; + /* Pacify compilers when the user code never invokes YYERROR and the + label yyerrorlab therefore never appears in user code. */ + if (0) + YYERROR; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -1755,6 +1783,7 @@ yyacceptlab: yyresult = 0; goto yyreturn; + /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -1762,6 +1791,7 @@ yyabortlab: yyresult = 1; goto yyreturn; + #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -1772,6 +1802,10 @@ yyexhaustedlab: /* Fall through. */ #endif + +/*-----------------------------------------------------. +| yyreturn -- parsing is finished, return the result. | +`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -1801,7 +1835,7 @@ yyreturn: #endif return yyresult; } -#line 228 "cc_parser.y" /* yacc.c:1906 */ +#line 228 "cc_parser.y" BOOL parse_cc_expr(parser_ctx_t *ctx) diff --git a/dll/win32/jscript/cc_parser.tab.h b/dll/win32/jscript/cc_parser.tab.h index 275e13edfa0..d09ec5e3e0a 100644 --- a/dll/win32/jscript/cc_parser.tab.h +++ b/dll/win32/jscript/cc_parser.tab.h @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0. */ +/* A Bison parser, made by GNU Bison 3.4.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -30,6 +31,9 @@ This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + #ifndef YY_CC_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_CC_PARSER_TAB_H_INCLUDED # define YY_CC_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_CC_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -62,15 +66,16 @@ extern int cc_parser_debug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 36 "cc_parser.y" /* yacc.c:1909 */ +#line 36 "cc_parser.y" ccval_t ccval; -#line 73 "cc_parser.tab.h" /* yacc.c:1909 */ +#line 76 "cc_parser.tab.h" + }; +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif diff --git a/dll/win32/jscript/cc_parser.y b/dll/win32/jscript/cc_parser.y index 18c1cb1c38e..4bc6260f194 100644 --- a/dll/win32/jscript/cc_parser.y +++ b/dll/win32/jscript/cc_parser.y @@ -30,7 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); %lex-param { parser_ctx_t *ctx } %parse-param { parser_ctx_t *ctx } -%pure-parser +%define api.pure %start CCExpr %union { diff --git a/dll/win32/jscript/compile.c b/dll/win32/jscript/compile.c index 006386a4e99..db05d3c3600 100644 --- a/dll/win32/jscript/compile.c +++ b/dll/win32/jscript/compile.c @@ -48,7 +48,7 @@ typedef struct { int ref; } function_local_t; -typedef struct { +typedef struct _compiler_ctx_t { parser_ctx_t *parser; bytecode_t *code; @@ -130,7 +130,7 @@ static inline void *compiler_alloc(bytecode_t *code, size_t size) return heap_pool_alloc(&code->heap, size); } -static jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len) +jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, unsigned len) { jsstr_t *new_str; @@ -160,7 +160,7 @@ static jsstr_t *compiler_alloc_string_len(compiler_ctx_t *ctx, const WCHAR *str, static jsstr_t *compiler_alloc_string(compiler_ctx_t *ctx, const WCHAR *str) { - return compiler_alloc_string_len(ctx, str, strlenW(str)); + return compiler_alloc_string_len(ctx, str, lstrlenW(str)); } static BOOL ensure_bstr_slot(compiler_ctx_t *ctx) @@ -245,20 +245,28 @@ static HRESULT push_instr_int(compiler_ctx_t *ctx, jsop_t op, LONG arg) return S_OK; } -static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, const WCHAR *arg) +static HRESULT push_instr_str(compiler_ctx_t *ctx, jsop_t op, jsstr_t *str) { unsigned instr; - jsstr_t *str; - str = compiler_alloc_string(ctx, arg); - if(!str) + instr = push_instr(ctx, op); + if(!instr) return E_OUTOFMEMORY; + instr_ptr(ctx, instr)->u.arg->str = str; + return S_OK; +} + +static HRESULT push_instr_str_uint(compiler_ctx_t *ctx, jsop_t op, jsstr_t *str, unsigned arg2) +{ + unsigned instr; + instr = push_instr(ctx, op); if(!instr) return E_OUTOFMEMORY; - instr_ptr(ctx, instr)->u.arg->str = str; + instr_ptr(ctx, instr)->u.arg[0].str = str; + instr_ptr(ctx, instr)->u.arg[1].uint = arg2; return S_OK; } @@ -477,13 +485,18 @@ static HRESULT compile_memberid_expression(compiler_ctx_t *ctx, expression_t *ex } case EXPR_MEMBER: { member_expression_t *member_expr = (member_expression_t*)expr; + jsstr_t *jsstr; hres = compile_expression(ctx, member_expr->expression, TRUE); if(FAILED(hres)) return hres; /* FIXME: Potential optimization */ - hres = push_instr_str(ctx, OP_str, member_expr->identifier); + jsstr = compiler_alloc_string(ctx, member_expr->identifier); + if(!jsstr) + return E_OUTOFMEMORY; + + hres = push_instr_str(ctx, OP_str, jsstr); if(FAILED(hres)) return hres; @@ -676,13 +689,18 @@ static HRESULT compile_delete_expression(compiler_ctx_t *ctx, unary_expression_t } case EXPR_MEMBER: { member_expression_t *member_expr = (member_expression_t*)expr->expression; + jsstr_t *jsstr; hres = compile_expression(ctx, member_expr->expression, TRUE); if(FAILED(hres)) return hres; /* FIXME: Potential optimization */ - hres = push_instr_str(ctx, OP_str, member_expr->identifier); + jsstr = compiler_alloc_string(ctx, member_expr->identifier); + if(!jsstr) + return E_OUTOFMEMORY; + + hres = push_instr_str(ctx, OP_str, jsstr); if(FAILED(hres)) return hres; @@ -718,11 +736,6 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_ call_expression_t *call_expr = (call_expression_t*)expr->expression1; argument_t *arg; - if(op != OP_LAST) { - FIXME("op %d not supported on parametrized assign expressions\n", op); - return E_NOTIMPL; - } - if(is_memberid_expr(call_expr->expression->type) && call_expr->argument_list) { hres = compile_memberid_expression(ctx, call_expr->expression, fdexNameEnsure); if(FAILED(hres)) @@ -734,6 +747,23 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_ return hres; arg_cnt++; } + + if(op != OP_LAST) { + unsigned instr; + + /* We need to call the functions twice: to get the value and to set it. + * JavaScript interpreted functions may to modify value on the stack, + * but assignment calls are allowed only on external functions, so we + * may reuse the stack here. */ + instr = push_instr(ctx, OP_call_member); + if(!instr) + return E_OUTOFMEMORY; + instr_ptr(ctx, instr)->u.arg[0].uint = arg_cnt; + instr_ptr(ctx, instr)->u.arg[1].lng = 1; + + if(!push_instr(ctx, OP_push_acc)) + return E_OUTOFMEMORY; + } }else { use_throw_path = TRUE; } @@ -741,6 +771,8 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_ hres = compile_memberid_expression(ctx, expr->expression1, fdexNameEnsure); if(FAILED(hres)) return hres; + if(op != OP_LAST && !push_instr(ctx, OP_refval)) + return E_OUTOFMEMORY; }else { use_throw_path = TRUE; } @@ -761,9 +793,6 @@ static HRESULT compile_assign_expression(compiler_ctx_t *ctx, binary_expression_ return push_instr_uint(ctx, OP_throw_ref, JS_E_ILLEGAL_ASSIGN); } - if(op != OP_LAST && !push_instr(ctx, OP_refval)) - return E_OUTOFMEMORY; - hres = compile_expression(ctx, expr->expression2, TRUE); if(FAILED(hres)) return hres; @@ -811,48 +840,22 @@ static HRESULT compile_literal(compiler_ctx_t *ctx, literal_t *literal) case LT_NULL: return push_instr(ctx, OP_null) ? S_OK : E_OUTOFMEMORY; case LT_STRING: - return push_instr_str(ctx, OP_str, literal->u.wstr); - case LT_REGEXP: { - unsigned instr; - jsstr_t *str; - - str = compiler_alloc_string_len(ctx, literal->u.regexp.str, literal->u.regexp.str_len); - if(!str) - return E_OUTOFMEMORY; - - instr = push_instr(ctx, OP_regexp); - if(!instr) - return E_OUTOFMEMORY; - - instr_ptr(ctx, instr)->u.arg[0].str = str; - instr_ptr(ctx, instr)->u.arg[1].uint = literal->u.regexp.flags; - return S_OK; - } + return push_instr_str(ctx, OP_str, literal->u.str); + case LT_REGEXP: + return push_instr_str_uint(ctx, OP_regexp, literal->u.regexp.str, literal->u.regexp.flags); DEFAULT_UNREACHABLE; } return E_FAIL; } -static HRESULT literal_as_bstr(compiler_ctx_t *ctx, literal_t *literal, BSTR *str) +static HRESULT literal_as_string(compiler_ctx_t *ctx, literal_t *literal, jsstr_t **str) { switch(literal->type) { case LT_STRING: - *str = compiler_alloc_bstr(ctx, literal->u.wstr); - break; - case LT_DOUBLE: { - jsstr_t *jsstr; - HRESULT hres; - - hres = double_to_string(literal->u.dval, &jsstr); - if(FAILED(hres)) - return hres; - - *str = compiler_alloc_bstr_len(ctx, NULL, jsstr_length(jsstr)); - if(*str) - jsstr_flush(jsstr, *str); - jsstr_release(jsstr); + *str = literal->u.str; break; - } + case LT_DOUBLE: + return double_to_string(literal->u.dval, str); DEFAULT_UNREACHABLE; } @@ -889,14 +892,14 @@ static HRESULT compile_array_literal(compiler_ctx_t *ctx, array_literal_expressi static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expression_t *expr) { property_definition_t *iter; - BSTR name; + jsstr_t *name; HRESULT hres; if(!push_instr(ctx, OP_new_obj)) return E_OUTOFMEMORY; for(iter = expr->property_list; iter; iter = iter->next) { - hres = literal_as_bstr(ctx, iter->name, &name); + hres = literal_as_string(ctx, iter->name, &name); if(FAILED(hres)) return hres; @@ -904,7 +907,7 @@ static HRESULT compile_object_literal(compiler_ctx_t *ctx, property_value_expres if(FAILED(hres)) return hres; - hres = push_instr_bstr_uint(ctx, OP_obj_prop, name, iter->type); + hres = push_instr_str_uint(ctx, OP_obj_prop, name, iter->type); if(FAILED(hres)) return hres; } @@ -1427,7 +1430,7 @@ static HRESULT compile_continue_statement(compiler_ctx_t *ctx, branch_statement_ for(iter = ctx->stat_ctx; iter; iter = iter->next) { if(iter->continue_label) pop_ctx = iter; - if(iter->labelled_stat && !strcmpW(iter->labelled_stat->identifier, stat->identifier)) + if(iter->labelled_stat && !wcscmp(iter->labelled_stat->identifier, stat->identifier)) break; } @@ -1473,7 +1476,7 @@ static HRESULT compile_break_statement(compiler_ctx_t *ctx, branch_statement_t * if(stat->identifier) { for(pop_ctx = ctx->stat_ctx; pop_ctx; pop_ctx = pop_ctx->next) { - if(pop_ctx->labelled_stat && !strcmpW(pop_ctx->labelled_stat->identifier, stat->identifier)) { + if(pop_ctx->labelled_stat && !wcscmp(pop_ctx->labelled_stat->identifier, stat->identifier)) { assert(pop_ctx->break_label); break; } @@ -1557,7 +1560,7 @@ static HRESULT compile_labelled_statement(compiler_ctx_t *ctx, labelled_statemen HRESULT hres; for(iter = ctx->stat_ctx; iter; iter = iter->next) { - if(iter->labelled_stat && !strcmpW(iter->labelled_stat->identifier, stat->identifier)) { + if(iter->labelled_stat && !wcscmp(iter->labelled_stat->identifier, stat->identifier)) { WARN("Label %s redefined\n", debugstr_w(stat->identifier)); return JS_E_LABEL_REDEFINED; } @@ -1833,7 +1836,7 @@ static HRESULT compile_statement(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx, static int function_local_cmp(const void *key, const struct wine_rb_entry *entry) { function_local_t *local = WINE_RB_ENTRY_VALUE(entry, function_local_t, entry); - return strcmpW(key, local->name); + return wcscmp(key, local->name); } static inline function_local_t *find_local(compiler_ctx_t *ctx, const WCHAR *name) @@ -2390,7 +2393,7 @@ static HRESULT parse_arguments(compiler_ctx_t *ctx, const WCHAR *args, BSTR *arg const WCHAR *ptr = args, *ptr2; unsigned arg_cnt = 0; - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; if(!*ptr) { if(args_size) @@ -2399,16 +2402,16 @@ static HRESULT parse_arguments(compiler_ctx_t *ctx, const WCHAR *args, BSTR *arg } while(1) { - if(!isalphaW(*ptr) && *ptr != '_') { + if(!iswalpha(*ptr) && *ptr != '_') { FIXME("expected alpha or '_': %s\n", debugstr_w(ptr)); return E_FAIL; } ptr2 = ptr; - while(isalnumW(*ptr) || *ptr == '_') + while(iswalnum(*ptr) || *ptr == '_') ptr++; - if(*ptr && *ptr != ',' && !isspaceW(*ptr)) { + if(*ptr && *ptr != ',' && !iswspace(*ptr)) { FIXME("unexpected har %s\n", debugstr_w(ptr)); return E_FAIL; } @@ -2420,7 +2423,7 @@ static HRESULT parse_arguments(compiler_ctx_t *ctx, const WCHAR *args, BSTR *arg } arg_cnt++; - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; if(!*ptr) break; @@ -2430,7 +2433,7 @@ static HRESULT parse_arguments(compiler_ctx_t *ctx, const WCHAR *args, BSTR *arg } ptr++; - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; } @@ -2479,7 +2482,7 @@ HRESULT compile_script(script_ctx_t *ctx, const WCHAR *code, const WCHAR *args, } } - hres = script_parse(ctx, compiler.code->source, delimiter, from_eval, &compiler.parser); + hres = script_parse(ctx, &compiler, compiler.code->source, delimiter, from_eval, &compiler.parser); if(FAILED(hres)) { release_bytecode(compiler.code); return hres; diff --git a/dll/win32/jscript/date.c b/dll/win32/jscript/date.c index 2676cd1cb1c..74d436f447d 100644 --- a/dll/win32/jscript/date.c +++ b/dll/win32/jscript/date.c @@ -17,8 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <limits.h> #include <math.h> @@ -542,16 +544,16 @@ static inline HRESULT date_to_string(DOUBLE time, BOOL show_offset, int offset, } if(!show_offset) - sprintfW(buf, formatNoOffsetW, week, month, day, + swprintf(buf, formatNoOffsetW, week, month, day, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), year, formatAD?ADW:BCW); else if(offset) - sprintfW(buf, formatW, week, month, day, + swprintf(buf, formatW, week, month, day, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), sign, offset/60, offset%60, year, formatAD?ADW:BCW); else - sprintfW(buf, formatUTCW, week, month, day, + swprintf(buf, formatUTCW, week, month, day, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), year, formatAD?ADW:BCW); @@ -658,15 +660,16 @@ static HRESULT Date_toISOString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(year < 0) { *p++ = '-'; - p += sprintfW(p, long_year_formatW, -(int)year); + p += swprintf(p, long_year_formatW, -(int)year); }else if(year > 9999) { *p++ = '+'; - p += sprintfW(p, long_year_formatW, (int)year); + p += swprintf(p, long_year_formatW, (int)year); }else { - p += sprintfW(p, short_year_formatW, (int)year); + p += swprintf(p, short_year_formatW, (int)year); } - sprintfW(p, formatW, (int)month_from_time(date->time) + 1, (int)date_from_time(date->time), + swprintf(p, formatW, + (int)month_from_time(date->time) + 1, (int)date_from_time(date->time), (int)hour_from_time(date->time), (int)min_from_time(date->time), (int)sec_from_time(date->time), (int)ms_from_time(date->time)); @@ -745,7 +748,7 @@ static inline HRESULT create_utc_string(script_ctx_t *ctx, vdisp_t *jsthis, jsva day = date_from_time(date->time); - sprintfW(buf, formatAD ? formatADW : formatBCW, week, day, month, year, + swprintf(buf, formatAD ? formatADW : formatBCW, week, day, month, year, (int)hour_from_time(date->time), (int)min_from_time(date->time), (int)sec_from_time(date->time)); @@ -822,7 +825,7 @@ static HRESULT dateobj_to_date_string(DateInstance *date, jsval_t *r) day = date_from_time(time); - sprintfW(buf, formatAD ? formatADW : formatBCW, week, month, day, year); + swprintf(buf, formatAD ? formatADW : formatBCW, week, month, day, year); date_str = jsstr_alloc(buf); if(!date_str) @@ -883,11 +886,11 @@ static HRESULT Date_toTimeString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, else sign = '-'; if(offset) - sprintfW(buf, formatW, (int)hour_from_time(time), + swprintf(buf, formatW, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time), sign, offset/60, offset%60); else - sprintfW(buf, formatUTCW, (int)hour_from_time(time), + swprintf(buf, formatUTCW, (int)hour_from_time(time), (int)min_from_time(time), (int)sec_from_time(time)); date_str = jsstr_alloc(buf); @@ -2075,7 +2078,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { for(i=0; i<input_len; i++) { if(input[i] == '(') nest_level++; else if(input[i] == ')') nest_level--; - else if(!nest_level) parse[parse_len++] = toupperW(input[i]); + else if(!nest_level) parse[parse_len++] = towupper(input[i]); } parse[parse_len] = 0; @@ -2102,16 +2105,16 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { } for(i=0; i<parse_len;) { - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i] == ',') { while(parse[i] == ',') i++; continue; } if(parse[i]>='0' && parse[i]<='9') { - int tmp = atoiW(&parse[i]); + int tmp = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i] == ':') { /* Time */ @@ -2121,17 +2124,17 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { hour = tmp; while(parse[i] == ':') i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i]>='0' && parse[i]<='9') { - min = atoiW(&parse[i]); + min = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; } - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; while(parse[i] == ':') i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i]>='0' && parse[i]<='9') { - sec = atoiW(&parse[i]); + sec = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; } } @@ -2144,17 +2147,17 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { month = tmp-1; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; while(parse[i]=='-' || parse[i]=='/') i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i]<'0' || parse[i]>'9') break; - day = atoiW(&parse[i]); + day = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; while(parse[i]=='-' || parse[i]=='/') i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i]<'0' || parse[i]>'9') break; - year = atoiW(&parse[i]); + year = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; if(tmp >= 70){ @@ -2189,9 +2192,9 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { if(parse[i] == '-') positive = FALSE; i++; - while(isspaceW(parse[i])) i++; + while(iswspace(parse[i])) i++; if(parse[i]<'0' || parse[i]>'9') break; - offset = atoiW(&parse[i]); + offset = wcstol(&parse[i], NULL, 10); while(parse[i]>='0' && parse[i]<='9') i++; if(offset<24) offset *= 60; @@ -2270,7 +2273,7 @@ static inline HRESULT date_parse(jsstr_t *input_str, double *ret) { size -= i; for(j=0; j<ARRAY_SIZE(string_ids); j++) - if(!strncmpiW(&parse[i], strings[j], size)) break; + if(!_wcsnicmp(&parse[i], strings[j], size)) break; if(j < 12) { if(set_month) break; diff --git a/dll/win32/jscript/decode.c b/dll/win32/jscript/decode.c index ccbd04c05b9..283aa2ed947 100644 --- a/dll/win32/jscript/decode.c +++ b/dll/win32/jscript/decode.c @@ -117,7 +117,7 @@ HRESULT decode_source(WCHAR *code) static const WCHAR decode_endW[] = {'^','#','~','@'}; while(*src) { - if(!strncmpW(src, decode_beginW, ARRAY_SIZE(decode_beginW))) { + if(!wcsncmp(src, decode_beginW, ARRAY_SIZE(decode_beginW))) { DWORD len, i, j=0, csum, s=0; src += ARRAY_SIZE(decode_beginW); @@ -165,7 +165,7 @@ HRESULT decode_source(WCHAR *code) return JS_E_INVALID_CHAR; src += 8; - if(strncmpW(src, decode_endW, ARRAY_SIZE(decode_endW))) + if(wcsncmp(src, decode_endW, ARRAY_SIZE(decode_endW))) return JS_E_INVALID_CHAR; src += ARRAY_SIZE(decode_endW); }else { diff --git a/dll/win32/jscript/dispex.c b/dll/win32/jscript/dispex.c index bc02aa4d67f..8b45bebb082 100644 --- a/dll/win32/jscript/dispex.c +++ b/dll/win32/jscript/dispex.c @@ -20,7 +20,6 @@ #include "jscript.h" -#include "wine/unicode.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(jscript); @@ -94,7 +93,7 @@ static const builtin_prop_t *find_builtin_prop(jsdisp_t *This, const WCHAR *name while(min <= max) { i = (min+max)/2; - r = strcmpW(name, This->builtin_info->props[i].name); + r = wcscmp(name, This->builtin_info->props[i].name); if(!r) { /* Skip prop if it's available only in higher compatibility mode. */ unsigned version = (This->builtin_info->props[i].flags & PROPF_VERSION_MASK) @@ -122,7 +121,7 @@ static inline unsigned string_hash(const WCHAR *name) { unsigned h = 0; for(; *name; name++) - h = (h>>(sizeof(unsigned)*8-4)) ^ (h<<4) ^ tolowerW(*name); + h = (h>>(sizeof(unsigned)*8-4)) ^ (h<<4) ^ towlower(*name); return h; } @@ -204,7 +203,7 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name, bucket = get_props_idx(This, hash); pos = This->props[bucket].bucket_head; while(pos != 0) { - if(!strcmpW(name, This->props[pos].name)) { + if(!wcscmp(name, This->props[pos].name)) { if(prev != 0) { This->props[prev].bucket_next = This->props[pos].bucket_next; This->props[pos].bucket_next = This->props[bucket].bucket_head; @@ -240,7 +239,7 @@ static HRESULT find_prop_name(jsdisp_t *This, unsigned hash, const WCHAR *name, const WCHAR *ptr; unsigned idx = 0; - for(ptr = name; isdigitW(*ptr) && idx < 0x10000; ptr++) + for(ptr = name; iswdigit(*ptr) && idx < 0x10000; ptr++) idx = idx*10 + (*ptr-'0'); if(!*ptr && idx < This->builtin_info->idx_length(This)) { prop = alloc_prop(This, name, PROP_IDX, This->builtin_info->idx_put ? PROPF_WRITABLE : 0); @@ -871,34 +870,14 @@ static HRESULT WINAPI DispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BS static HRESULT WINAPI DispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid) { jsdisp_t *This = impl_from_IDispatchEx(iface); - dispex_prop_t *iter; HRESULT hres; TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid); - if(id == DISPID_STARTENUM) { - hres = fill_protrefs(This); - if(FAILED(hres)) - return hres; - } - - if(id+1>=0 && id+1<This->prop_cnt) { - iter = &This->props[id+1]; - }else { + hres = jsdisp_next_prop(This, id, FALSE, pid); + if(hres == S_FALSE) *pid = DISPID_STARTENUM; - return S_FALSE; - } - - while(iter < This->props + This->prop_cnt) { - if(iter->name && (get_flags(This, iter) & PROPF_ENUMERABLE) && iter->type!=PROP_DELETED) { - *pid = prop_to_id(This, iter); - return S_OK; - } - iter++; - } - - *pid = DISPID_STARTENUM; - return S_FALSE; + return hres; } static HRESULT WINAPI DispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk) @@ -1373,7 +1352,7 @@ HRESULT jsdisp_propput_idx(jsdisp_t *obj, DWORD idx, jsval_t val) static const WCHAR formatW[] = {'%','d',0}; - sprintfW(buf, formatW, idx); + swprintf(buf, formatW, idx); return jsdisp_propput_name(obj, buf, val); } @@ -1451,7 +1430,7 @@ HRESULT jsdisp_get_idx(jsdisp_t *obj, DWORD idx, jsval_t *r) static const WCHAR formatW[] = {'%','d',0}; - sprintfW(name, formatW, idx); + swprintf(name, formatW, idx); hres = find_prop_name_prot(obj, string_hash(name), name, &prop); if(FAILED(hres)) @@ -1520,7 +1499,7 @@ HRESULT jsdisp_delete_idx(jsdisp_t *obj, DWORD idx) BOOL b; HRESULT hres; - sprintfW(buf, formatW, idx); + swprintf(buf, formatW, idx); hres = find_prop_name(obj, string_hash(buf), buf, &prop); if(FAILED(hres) || !prop) @@ -1564,6 +1543,34 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret) return S_OK; } +HRESULT jsdisp_next_prop(jsdisp_t *obj, DISPID id, BOOL own_only, DISPID *ret) +{ + dispex_prop_t *iter; + HRESULT hres; + + if(id == DISPID_STARTENUM && !own_only) { + hres = fill_protrefs(obj); + if(FAILED(hres)) + return hres; + } + + if(id + 1 < 0 || id+1 >= obj->prop_cnt) + return S_FALSE; + + for(iter = &obj->props[id + 1]; iter < obj->props + obj->prop_cnt; iter++) { + if(!iter->name || iter->type == PROP_DELETED) + continue; + if(own_only && iter->type == PROP_PROTREF) + continue; + if(!(get_flags(obj, iter) & PROPF_ENUMERABLE)) + continue; + *ret = prop_to_id(obj, iter); + return S_OK; + } + + return S_FALSE; +} + HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret) { IDispatchEx *dispex; diff --git a/dll/win32/jscript/engine.c b/dll/win32/jscript/engine.c index bed8c64a052..4d11db981eb 100644 --- a/dll/win32/jscript/engine.c +++ b/dll/win32/jscript/engine.c @@ -16,8 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> #include <assert.h> @@ -619,9 +621,9 @@ static BOOL lookup_global_members(script_ctx_t *ctx, BSTR identifier, exprval_t return FALSE; } -static int local_ref_cmp(const void *key, const void *ref) +static int __cdecl local_ref_cmp(const void *key, const void *ref) { - return strcmpW((const WCHAR*)key, ((const local_ref_t*)ref)->name); + return wcscmp((const WCHAR*)key, ((const local_ref_t*)ref)->name); } local_ref_t *lookup_local(const function_code_t *function, const WCHAR *identifier) @@ -653,7 +655,7 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re return S_OK; } - if(!strcmpW(identifier, argumentsW)) { + if(!wcscmp(identifier, argumentsW)) { hres = detach_variable_object(ctx, scope->frame, FALSE); if(FAILED(hres)) return hres; @@ -677,7 +679,7 @@ static HRESULT identifier_eval(script_ctx_t *ctx, BSTR identifier, exprval_t *re } for(item = ctx->named_items; item; item = item->next) { - if((item->flags & SCRIPTITEM_ISVISIBLE) && !strcmpW(item->name, identifier)) { + if((item->flags & SCRIPTITEM_ISVISIBLE) && !wcscmp(item->name, identifier)) { if(!item->disp) { IUnknown *unk; @@ -1449,16 +1451,20 @@ static HRESULT interp_new_obj(script_ctx_t *ctx) /* ECMA-262 3rd Edition 11.1.5 */ static HRESULT interp_obj_prop(script_ctx_t *ctx) { - const BSTR name = get_op_bstr(ctx, 0); + jsstr_t *name_arg = get_op_str(ctx, 0); unsigned type = get_op_uint(ctx, 1); + const WCHAR *name; jsdisp_t *obj; jsval_t val; HRESULT hres; - TRACE("%s\n", debugstr_w(name)); + TRACE("%s\n", debugstr_jsstr(name_arg)); val = stack_pop(ctx); + /* FIXME: we should pass it as jsstr_t */ + name = jsstr_flatten(name_arg); + assert(is_object_instance(stack_top(ctx))); obj = as_jsdisp(get_object(stack_top(ctx))); diff --git a/dll/win32/jscript/engine.h b/dll/win32/jscript/engine.h index 6ee8f062df9..0920f6f1d5f 100644 --- a/dll/win32/jscript/engine.h +++ b/dll/win32/jscript/engine.h @@ -68,7 +68,7 @@ X(new, 1, ARG_UINT, 0) \ X(new_obj, 1, 0,0) \ X(null, 1, 0,0) \ - X(obj_prop, 1, ARG_BSTR, ARG_UINT) \ + X(obj_prop, 1, ARG_STR, ARG_UINT) \ X(or, 1, 0,0) \ X(pop, 1, ARG_UINT, 0) \ X(pop_except, 0, ARG_ADDR, 0) \ diff --git a/dll/win32/jscript/enumerator.c b/dll/win32/jscript/enumerator.c index 5c06efd1f9b..5f5b135cb50 100644 --- a/dll/win32/jscript/enumerator.c +++ b/dll/win32/jscript/enumerator.c @@ -61,7 +61,7 @@ static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This) if (This->atend) return S_OK; - /* dont leak pervious value */ + /* don't leak previous value */ jsval_release(This->item); /* not at end ... get next item */ @@ -73,7 +73,7 @@ static inline HRESULT enumvar_get_next_item(EnumeratorInstance *This) VariantClear(&nextitem); if (FAILED(hres)) { - WARN("failed to convert jsval to variant!"); + WARN("failed to convert jsval to variant!\n"); This->item = jsval_undefined(); return hres; } diff --git a/dll/win32/jscript/error.c b/dll/win32/jscript/error.c index ef855dce309..fcdeddbfd90 100644 --- a/dll/win32/jscript/error.c +++ b/dll/win32/jscript/error.c @@ -16,8 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> @@ -387,10 +389,10 @@ static HRESULT throw_error(script_ctx_t *ctx, HRESULT error, const WCHAR *str, j buf[0] = '\0'; LoadStringW(jscript_hinstance, HRESULT_CODE(error), buf, ARRAY_SIZE(buf)); - if(str) pos = strchrW(buf, '|'); + if(str) pos = wcschr(buf, '|'); if(pos) { - int len = strlenW(str); - memmove(pos+len, pos+1, (strlenW(pos+1)+1)*sizeof(WCHAR)); + int len = lstrlenW(str); + memmove(pos+len, pos+1, (lstrlenW(pos+1)+1)*sizeof(WCHAR)); memcpy(pos, str, len*sizeof(WCHAR)); } diff --git a/dll/win32/jscript/function.c b/dll/win32/jscript/function.c index 9795f77e904..7a44f5092b8 100644 --- a/dll/win32/jscript/function.c +++ b/dll/win32/jscript/function.c @@ -25,25 +25,52 @@ WINE_DEFAULT_DEBUG_CHANNEL(jscript); +typedef struct _function_vtbl_t function_vtbl_t; + typedef struct { jsdisp_t dispex; - builtin_invoke_t value_proc; - const WCHAR *name; + const function_vtbl_t *vtbl; DWORD flags; + DWORD length; +} FunctionInstance; + +struct _function_vtbl_t { + HRESULT (*call)(script_ctx_t*,FunctionInstance*,IDispatch*,unsigned,unsigned,jsval_t*,jsval_t*); + HRESULT (*toString)(FunctionInstance*,jsstr_t**); + void (*destructor)(FunctionInstance*); +}; + +typedef struct { + FunctionInstance function; scope_chain_t *scope_chain; bytecode_t *code; function_code_t *func_code; - DWORD length; -} FunctionInstance; +} InterpretedFunction; + +typedef struct { + FunctionInstance function; + builtin_invoke_t proc; + const WCHAR *name; +} NativeFunction; + +typedef struct { + FunctionInstance function; + FunctionInstance *target; + IDispatch *this; + unsigned argc; + jsval_t args[1]; +} BindFunction; typedef struct { jsdisp_t jsdisp; - FunctionInstance *function; + InterpretedFunction *function; jsval_t *buf; call_frame_t *frame; unsigned argc; } ArgumentsInstance; +static HRESULT create_bind_function(script_ctx_t*,FunctionInstance*,IDispatch*,unsigned,jsval_t*,jsdisp_t**r); + static inline FunctionInstance *function_from_jsdisp(jsdisp_t *jsdisp) { return CONTAINING_RECORD(jsdisp, FunctionInstance, dispex); @@ -69,6 +96,7 @@ static const WCHAR prototypeW[] = {'p','r','o','t','o','t', 'y', 'p','e',0}; static const WCHAR lengthW[] = {'l','e','n','g','t','h',0}; static const WCHAR toStringW[] = {'t','o','S','t','r','i','n','g',0}; static const WCHAR applyW[] = {'a','p','p','l','y',0}; +static const WCHAR bindW[] = {'b','i','n','d',0}; static const WCHAR callW[] = {'c','a','l','l',0}; static const WCHAR argumentsW[] = {'a','r','g','u','m','e','n','t','s',0}; @@ -92,7 +120,7 @@ static void Arguments_destructor(jsdisp_t *jsdisp) heap_free(arguments->buf); } - jsdisp_release(&arguments->function->dispex); + jsdisp_release(&arguments->function->function.dispex); heap_free(arguments); } @@ -122,7 +150,8 @@ static HRESULT Arguments_idx_get(jsdisp_t *jsdisp, unsigned idx, jsval_t *r) return jsval_copy(*ref, r); /* FIXME: Accessing by name won't work for duplicated argument names */ - return jsdisp_propget_name(arguments->frame->base_scope->jsobj, arguments->function->func_code->params[idx], r); + return jsdisp_propget_name(arguments->frame->base_scope->jsobj, + arguments->function->func_code->params[idx], r); } static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val) @@ -145,7 +174,8 @@ static HRESULT Arguments_idx_put(jsdisp_t *jsdisp, unsigned idx, jsval_t val) } /* FIXME: Accessing by name won't work for duplicated argument names */ - return jsdisp_propput_name(arguments->frame->base_scope->jsobj, arguments->function->func_code->params[idx], val); + return jsdisp_propput_name(arguments->frame->base_scope->jsobj, + arguments->function->func_code->params[idx], val); } static const builtin_info_t Arguments_info = { @@ -176,7 +206,7 @@ HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame) return hres; } - args->function = function_from_jsdisp(jsdisp_addref(frame->function_instance)); + args->function = (InterpretedFunction*)function_from_jsdisp(jsdisp_addref(frame->function_instance)); args->argc = frame->argc; args->frame = frame; @@ -184,7 +214,7 @@ HRESULT setup_arguments_object(script_ctx_t *ctx, call_frame_t *frame) jsval_number(args->argc)); if(SUCCEEDED(hres)) hres = jsdisp_define_data_property(&args->jsdisp, caleeW, PROPF_WRITABLE | PROPF_CONFIGURABLE, - jsval_obj(&args->function->dispex)); + jsval_obj(&args->function->function.dispex)); if(SUCCEEDED(hres)) hres = jsdisp_propput(frame->base_scope->jsobj, argumentsW, PROPF_WRITABLE, jsval_obj(&args->jsdisp)); if(FAILED(hres)) { @@ -231,99 +261,8 @@ void detach_arguments_object(jsdisp_t *args_disp) jsdisp_release(frame->arguments_obj); } -static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, unsigned argc, jsval_t *argv, - BOOL is_constructor, BOOL caller_execs_source, jsval_t *r) -{ - jsdisp_t *var_disp; - DWORD exec_flags = 0; - HRESULT hres; - - if(ctx->state == SCRIPTSTATE_UNINITIALIZED || ctx->state == SCRIPTSTATE_CLOSED) { - WARN("Script engine state does not allow running code.\n"); - return E_UNEXPECTED; - } - - if(!function->func_code) { - FIXME("no source\n"); - return E_FAIL; - } - - hres = create_dispex(ctx, NULL, NULL, &var_disp); - if(FAILED(hres)) - return hres; - - if(caller_execs_source) - exec_flags |= EXEC_RETURN_TO_INTERP; - if(is_constructor) - exec_flags |= EXEC_CONSTRUCTOR; - hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj, - &function->dispex, var_disp, argc, argv, r); - - jsdisp_release(var_disp); - return hres; -} - -static HRESULT invoke_value_proc(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_disp, WORD flags, - unsigned argc, jsval_t *argv, jsval_t *r) -{ - vdisp_t vthis; - HRESULT hres; - - if(this_disp) - set_disp(&vthis, this_disp); - else if(ctx->host_global) - set_disp(&vthis, ctx->host_global); - else - set_jsdisp(&vthis, ctx->global); - - hres = function->value_proc(ctx, &vthis, flags, argc, argv, r); - - vdisp_release(&vthis); - return hres; -} - -static HRESULT call_function(script_ctx_t *ctx, FunctionInstance *function, IDispatch *this_obj, - unsigned argc, jsval_t *argv, BOOL caller_execs_source, jsval_t *r) -{ - if(function->value_proc) - return invoke_value_proc(ctx, function, this_obj, DISPATCH_METHOD, argc, argv, r); - - return invoke_source(ctx, function, this_obj, argc, argv, FALSE, caller_execs_source, r); -} - -static HRESULT function_to_string(FunctionInstance *function, jsstr_t **ret) -{ - jsstr_t *str; - - static const WCHAR native_prefixW[] = {'\n','f','u','n','c','t','i','o','n',' '}; - static const WCHAR native_suffixW[] = - {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'}; - - if(function->value_proc) { - DWORD name_len; - WCHAR *ptr; - - name_len = strlenW(function->name); - str = jsstr_alloc_buf(ARRAY_SIZE(native_prefixW) + ARRAY_SIZE(native_suffixW) + name_len, &ptr); - if(!str) - return E_OUTOFMEMORY; - - memcpy(ptr, native_prefixW, sizeof(native_prefixW)); - memcpy(ptr += ARRAY_SIZE(native_prefixW), function->name, name_len*sizeof(WCHAR)); - memcpy(ptr + name_len, native_suffixW, sizeof(native_suffixW)); - }else { - str = jsstr_alloc_len(function->func_code->source, function->func_code->source_len); - if(!str) - return E_OUTOFMEMORY; - } - - *ret = str; - return S_OK; -} - HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - const BOOL caller_execs_source = (flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE) != 0; FunctionInstance *function; TRACE("func %p this %p\n", func_this, jsthis); @@ -331,25 +270,7 @@ HRESULT Function_invoke(jsdisp_t *func_this, IDispatch *jsthis, WORD flags, unsi assert(is_class(func_this, JSCLASS_FUNCTION)); function = function_from_jsdisp(func_this); - flags &= ~DISPATCH_JSCRIPT_INTERNAL_MASK; - if(function->value_proc) - return invoke_value_proc(function->dispex.ctx, function, jsthis, flags, argc, argv, r); - - if(flags == DISPATCH_CONSTRUCT) { - jsdisp_t *this_obj; - HRESULT hres; - - hres = create_object(function->dispex.ctx, &function->dispex, &this_obj); - if(FAILED(hres)) - return hres; - - hres = invoke_source(function->dispex.ctx, function, to_disp(this_obj), argc, argv, TRUE, caller_execs_source, r); - jsdisp_release(this_obj); - return hres; - } - - assert(flags == DISPATCH_METHOD); - return invoke_source(function->dispex.ctx, function, jsthis, argc, argv, FALSE, caller_execs_source, r); + return function->vtbl->call(function->dispex.ctx, function, jsthis, flags, argc, argv, r); } static HRESULT Function_get_length(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r) @@ -372,7 +293,7 @@ static HRESULT Function_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(!(function = function_this(jsthis))) return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); - hres = function_to_string(function, &str); + hres = function->vtbl->toString(function, &str); if(FAILED(hres)) return hres; @@ -463,7 +384,7 @@ static HRESULT Function_apply(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, un if(SUCCEEDED(hres)) { if(function) { - hres = call_function(ctx, function, this_obj, cnt, args, (flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE) != 0, r); + hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, args, r); }else { jsval_t res; hres = disp_call_value(ctx, jsthis->u.disp, this_obj, DISPATCH_METHOD, cnt, args, &res); @@ -507,13 +428,46 @@ static HRESULT Function_call(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, uns cnt = argc-1; } - hres = call_function(ctx, function, this_obj, cnt, argv+1, (flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE) != 0, r); + hres = function->vtbl->call(ctx, function, this_obj, flags, cnt, argv + 1, r); if(this_obj) IDispatch_Release(this_obj); return hres; } +static HRESULT Function_bind(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, + jsval_t *r) +{ + FunctionInstance *function; + jsdisp_t *new_function; + HRESULT hres; + + TRACE("\n"); + + if(!(function = function_this(jsthis))) + return throw_type_error(ctx, JS_E_FUNCTION_EXPECTED, NULL); + + if(argc < 1) { + FIXME("no this argument\n"); + return E_NOTIMPL; + } + + if(!is_object_instance(argv[0]) || !get_object(argv[0])) { + FIXME("%s is not an object instance\n", debugstr_jsval(argv[0])); + return E_NOTIMPL; + } + + hres = create_bind_function(ctx, function, get_object(argv[0]), argc - 1, argv + 1, &new_function); + if(FAILED(hres)) + return hres; + + if(r) + *r = jsval_obj(new_function); + else + jsdisp_release(new_function); + return S_OK; +} + HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { @@ -527,19 +481,18 @@ HRESULT Function_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned } function = function_from_jsdisp(jsthis->u.jsdisp); - - assert(function->value_proc != NULL); - return invoke_value_proc(ctx, function, NULL, flags, argc, argv, r); + return function->vtbl->call(ctx, function, NULL, flags, argc, argv, r); } HRESULT Function_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r) { + FunctionInstance *function = function_from_jsdisp(jsthis); jsstr_t *str; HRESULT hres; TRACE("\n"); - hres = function_to_string(function_from_jsdisp(jsthis), &str); + hres = function->vtbl->toString(function, &str); if(FAILED(hres)) return hres; @@ -573,18 +526,15 @@ static HRESULT Function_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval static void Function_destructor(jsdisp_t *dispex) { - FunctionInstance *This = function_from_jsdisp(dispex); - - if(This->code) - release_bytecode(This->code); - if(This->scope_chain) - scope_release(This->scope_chain); - heap_free(This); + FunctionInstance *function = function_from_jsdisp(dispex); + function->vtbl->destructor(function); + heap_free(function); } static const builtin_prop_t Function_props[] = { {applyW, Function_apply, PROPF_METHOD|2}, {argumentsW, NULL, 0, Function_get_arguments}, + {bindW, Function_bind, PROPF_METHOD|PROPF_ES5|1}, {callW, Function_call, PROPF_METHOD|1}, {lengthW, NULL, 0, Function_get_length}, {toStringW, Function_toString, PROPF_METHOD} @@ -613,13 +563,13 @@ static const builtin_info_t FunctionInst_info = { NULL }; -static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, DWORD flags, - BOOL funcprot, jsdisp_t *prototype, FunctionInstance **ret) +static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_info, const function_vtbl_t *vtbl, size_t size, + DWORD flags, BOOL funcprot, jsdisp_t *prototype, void **ret) { FunctionInstance *function; HRESULT hres; - function = heap_alloc_zero(sizeof(FunctionInstance)); + function = heap_alloc_zero(size); if(!function) return E_OUTOFMEMORY; @@ -634,6 +584,7 @@ static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_ return hres; } + function->vtbl = vtbl; function->flags = flags; function->length = flags & PROPF_ARGMASK; @@ -641,30 +592,86 @@ static HRESULT create_function(script_ctx_t *ctx, const builtin_info_t *builtin_ return S_OK; } +static HRESULT NativeFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_disp, unsigned flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + NativeFunction *function = (NativeFunction*)func; + vdisp_t vthis; + HRESULT hres; + + if(this_disp) + set_disp(&vthis, this_disp); + else if(ctx->host_global) + set_disp(&vthis, ctx->host_global); + else + set_jsdisp(&vthis, ctx->global); + + hres = function->proc(ctx, &vthis, flags & ~DISPATCH_JSCRIPT_INTERNAL_MASK, argc, argv, r); + + vdisp_release(&vthis); + return hres; +} + +static HRESULT NativeFunction_toString(FunctionInstance *func, jsstr_t **ret) +{ + NativeFunction *function = (NativeFunction*)func; + DWORD name_len; + jsstr_t *str; + WCHAR *ptr; + + static const WCHAR native_prefixW[] = {'\n','f','u','n','c','t','i','o','n',' '}; + static const WCHAR native_suffixW[] = + {'(',')',' ','{','\n',' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n','}','\n'}; + + name_len = function->name ? lstrlenW(function->name) : 0; + str = jsstr_alloc_buf(ARRAY_SIZE(native_prefixW) + ARRAY_SIZE(native_suffixW) + name_len, &ptr); + if(!str) + return E_OUTOFMEMORY; + + memcpy(ptr, native_prefixW, sizeof(native_prefixW)); + ptr += ARRAY_SIZE(native_prefixW); + memcpy(ptr, function->name, name_len*sizeof(WCHAR)); + ptr += name_len; + memcpy(ptr, native_suffixW, sizeof(native_suffixW)); + + *ret = str; + return S_OK; +} + +static void NativeFunction_destructor(FunctionInstance *function) +{ +} + +static const function_vtbl_t NativeFunctionVtbl = { + NativeFunction_call, + NativeFunction_toString, + NativeFunction_destructor +}; + HRESULT create_builtin_function(script_ctx_t *ctx, builtin_invoke_t value_proc, const WCHAR *name, const builtin_info_t *builtin_info, DWORD flags, jsdisp_t *prototype, jsdisp_t **ret) { - FunctionInstance *function; + NativeFunction *function; HRESULT hres; - hres = create_function(ctx, builtin_info, flags, FALSE, NULL, &function); + hres = create_function(ctx, builtin_info, &NativeFunctionVtbl, sizeof(NativeFunction), flags, FALSE, NULL, (void**)&function); if(FAILED(hres)) return hres; if(builtin_info) - hres = jsdisp_define_data_property(&function->dispex, lengthW, 0, - jsval_number(function->length)); + hres = jsdisp_define_data_property(&function->function.dispex, lengthW, 0, + jsval_number(function->function.length)); if(SUCCEEDED(hres)) - hres = jsdisp_define_data_property(&function->dispex, prototypeW, 0, jsval_obj(prototype)); + hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, 0, jsval_obj(prototype)); if(FAILED(hres)) { - jsdisp_release(&function->dispex); + jsdisp_release(&function->function.dispex); return hres; } - function->value_proc = value_proc; + function->proc = value_proc; function->name = name; - *ret = &function->dispex; + *ret = &function->function.dispex; return S_OK; } @@ -696,10 +703,71 @@ HRESULT create_builtin_constructor(script_ctx_t *ctx, builtin_invoke_t value_pro return S_OK; } +static HRESULT InterpretedFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + InterpretedFunction *function = (InterpretedFunction*)func; + jsdisp_t *var_disp, *new_obj = NULL; + DWORD exec_flags = 0; + HRESULT hres; + + TRACE("%p\n", function); + + if(ctx->state == SCRIPTSTATE_UNINITIALIZED || ctx->state == SCRIPTSTATE_CLOSED) { + WARN("Script engine state does not allow running code.\n"); + return E_UNEXPECTED; + } + + if(flags & DISPATCH_CONSTRUCT) { + hres = create_object(ctx, &function->function.dispex, &new_obj); + if(FAILED(hres)) + return hres; + this_obj = to_disp(new_obj); + } + + if(flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE) + exec_flags |= EXEC_RETURN_TO_INTERP; + if(flags & DISPATCH_CONSTRUCT) + exec_flags |= EXEC_CONSTRUCTOR; + + hres = create_dispex(ctx, NULL, NULL, &var_disp); + if(SUCCEEDED(hres)) + hres = exec_source(ctx, exec_flags, function->code, function->func_code, function->scope_chain, this_obj, + &function->function.dispex, var_disp, argc, argv, r); + if(new_obj) + jsdisp_release(new_obj); + + jsdisp_release(var_disp); + return hres; +} + +static HRESULT InterpretedFunction_toString(FunctionInstance *func, jsstr_t **ret) +{ + InterpretedFunction *function = (InterpretedFunction*)func; + + *ret = jsstr_alloc_len(function->func_code->source, function->func_code->source_len); + return *ret ? S_OK : E_OUTOFMEMORY; +} + +static void InterpretedFunction_destructor(FunctionInstance *func) +{ + InterpretedFunction *function = (InterpretedFunction*)func; + + release_bytecode(function->code); + if(function->scope_chain) + scope_release(function->scope_chain); +} + +static const function_vtbl_t InterpretedFunctionVtbl = { + InterpretedFunction_call, + InterpretedFunction_toString, + InterpretedFunction_destructor +}; + HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_code_t *func_code, scope_chain_t *scope_chain, jsdisp_t **ret) { - FunctionInstance *function; + InterpretedFunction *function; jsdisp_t *prototype; HRESULT hres; @@ -707,14 +775,15 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod if(FAILED(hres)) return hres; - hres = create_function(ctx, NULL, PROPF_CONSTR, FALSE, NULL, &function); + hres = create_function(ctx, NULL, &InterpretedFunctionVtbl, sizeof(InterpretedFunction), PROPF_CONSTR, + FALSE, NULL, (void**)&function); if(SUCCEEDED(hres)) { - hres = jsdisp_define_data_property(&function->dispex, prototypeW, PROPF_WRITABLE, + hres = jsdisp_define_data_property(&function->function.dispex, prototypeW, PROPF_WRITABLE, jsval_obj(prototype)); if(SUCCEEDED(hres)) - hres = set_constructor_prop(ctx, &function->dispex, prototype); + hres = set_constructor_prop(ctx, &function->function.dispex, prototype); if(FAILED(hres)) - jsdisp_release(&function->dispex); + jsdisp_release(&function->function.dispex); } jsdisp_release(prototype); if(FAILED(hres)) @@ -728,9 +797,97 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod bytecode_addref(code); function->code = code; function->func_code = func_code; - function->length = function->func_code->param_cnt; + function->function.length = function->func_code->param_cnt; + + *ret = &function->function.dispex; + return S_OK; +} + +static HRESULT BindFunction_call(script_ctx_t *ctx, FunctionInstance *func, IDispatch *this_obj, unsigned flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + BindFunction *function = (BindFunction*)func; + jsval_t *call_args = NULL; + unsigned call_argc; + HRESULT hres; + + TRACE("%p\n", function); + + call_argc = function->argc + argc; + if(call_argc) { + call_args = heap_alloc(function->argc * sizeof(*function->args)); + if(!call_args) + return E_OUTOFMEMORY; + + if(function->argc) + memcpy(call_args, function->args, function->argc * sizeof(*call_args)); + if(argc) + memcpy(call_args + function->argc, argv, argc * sizeof(*call_args)); + } + + hres = function->target->vtbl->call(ctx, function->target, function->this, flags, call_argc, call_args, r); + + heap_free(call_args); + return hres; +} + +static HRESULT BindFunction_toString(FunctionInstance *function, jsstr_t **ret) +{ + static const WCHAR native_functionW[] = + {'\n','f','u','n','c','t','i','o','n','(',')',' ','{','\n', + ' ',' ',' ',' ','[','n','a','t','i','v','e',' ','c','o','d','e',']','\n', + '}','\n',0}; + + *ret = jsstr_alloc(native_functionW); + return *ret ? S_OK : E_OUTOFMEMORY; +} + +static void BindFunction_destructor(FunctionInstance *func) +{ + BindFunction *function = (BindFunction*)func; + unsigned i; + + TRACE("%p\n", function); + + for(i = 0; i < function->argc; i++) + jsval_release(function->args[i]); + jsdisp_release(&function->target->dispex); + IDispatch_Release(function->this); +} + +static const function_vtbl_t BindFunctionVtbl = { + BindFunction_call, + BindFunction_toString, + BindFunction_destructor +}; + +static HRESULT create_bind_function(script_ctx_t *ctx, FunctionInstance *target, IDispatch *bound_this, unsigned argc, + jsval_t *argv, jsdisp_t **ret) +{ + BindFunction *function; + HRESULT hres; + + hres = create_function(ctx, NULL, &BindFunctionVtbl, FIELD_OFFSET(BindFunction, args[argc]), PROPF_METHOD, + FALSE, NULL, (void**)&function); + if(FAILED(hres)) + return hres; + + jsdisp_addref(&target->dispex); + function->target = target; + + IDispatch_AddRef(function->this = bound_this); + + for(function->argc = 0; function->argc < argc; function->argc++) { + hres = jsval_copy(argv[function->argc], function->args + function->argc); + if(FAILED(hres)) { + jsdisp_release(&function->function.dispex); + return hres; + } + } + + function->function.length = target->length > argc ? target->length - argc : 0; - *ret = &function->dispex; + *ret = &function->function.dispex; return S_OK; } @@ -852,32 +1009,34 @@ static HRESULT FunctionProt_value(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags HRESULT init_function_constr(script_ctx_t *ctx, jsdisp_t *object_prototype) { - FunctionInstance *prot, *constr; + NativeFunction *prot, *constr; HRESULT hres; static const WCHAR FunctionW[] = {'F','u','n','c','t','i','o','n',0}; - hres = create_function(ctx, &Function_info, PROPF_CONSTR, TRUE, object_prototype, &prot); + hres = create_function(ctx, &Function_info, &NativeFunctionVtbl, sizeof(NativeFunction), PROPF_CONSTR, + TRUE, object_prototype, (void**)&prot); if(FAILED(hres)) return hres; - prot->value_proc = FunctionProt_value; + prot->proc = FunctionProt_value; prot->name = prototypeW; - hres = create_function(ctx, &FunctionInst_info, PROPF_CONSTR|1, TRUE, &prot->dispex, &constr); + hres = create_function(ctx, &FunctionInst_info, &NativeFunctionVtbl, sizeof(NativeFunction), PROPF_CONSTR|1, + TRUE, &prot->function.dispex, (void**)&constr); if(SUCCEEDED(hres)) { - constr->value_proc = FunctionConstr_value; + constr->proc = FunctionConstr_value; constr->name = FunctionW; - hres = jsdisp_define_data_property(&constr->dispex, prototypeW, 0, jsval_obj(&prot->dispex)); + hres = jsdisp_define_data_property(&constr->function.dispex, prototypeW, 0, jsval_obj(&prot->function.dispex)); if(SUCCEEDED(hres)) - hres = set_constructor_prop(ctx, &constr->dispex, &prot->dispex); + hres = set_constructor_prop(ctx, &constr->function.dispex, &prot->function.dispex); if(FAILED(hres)) - jsdisp_release(&constr->dispex); + jsdisp_release(&constr->function.dispex); } - jsdisp_release(&prot->dispex); + jsdisp_release(&prot->function.dispex); if(FAILED(hres)) return hres; - ctx->function_constr = &constr->dispex; + ctx->function_constr = &constr->function.dispex; return S_OK; } diff --git a/dll/win32/jscript/global.c b/dll/win32/jscript/global.c index 92b146c83ac..24c4eebf1db 100644 --- a/dll/win32/jscript/global.c +++ b/dll/win32/jscript/global.c @@ -16,8 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> #include <limits.h> @@ -181,7 +183,7 @@ static HRESULT JSGlobal_escape(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - call_frame_t *frame; + call_frame_t *frame = ctx->call_ctx; DWORD exec_flags = EXEC_EVAL; bytecode_t *code; const WCHAR *src; @@ -201,11 +203,6 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a return S_OK; } - if(!(frame = ctx->call_ctx)) { - FIXME("No active exec_ctx\n"); - return E_UNEXPECTED; - } - src = jsstr_flatten(get_string(argv[0])); if(!src) return E_OUTOFMEMORY; @@ -217,12 +214,12 @@ HRESULT JSGlobal_eval(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned a return throw_syntax_error(ctx, hres, NULL); } - if(frame->flags & EXEC_GLOBAL) + if(!frame || (frame->flags & EXEC_GLOBAL)) exec_flags |= EXEC_GLOBAL; if(flags & DISPATCH_JSCRIPT_CALLEREXECSSOURCE) exec_flags |= EXEC_RETURN_TO_INTERP; - hres = exec_source(ctx, exec_flags, code, &code->global_code, frame->scope, - frame->this_obj, NULL, frame->variable_obj, 0, NULL, r); + hres = exec_source(ctx, exec_flags, code, &code->global_code, frame ? frame->scope : NULL, + frame ? frame->this_obj : NULL, NULL, frame ? frame->variable_obj : ctx->global, 0, NULL, r); release_bytecode(code); return hres; } @@ -317,7 +314,7 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, if(FAILED(hres)) return hres; - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; switch(*ptr) { @@ -343,6 +340,8 @@ static HRESULT JSGlobal_parseInt(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, }else { radix = 10; } + }else if(radix == 16 && *ptr == '0' && (ptr[1] == 'x' || ptr[1] == 'X')) { + ptr += 2; } i = char_to_int(*ptr++); @@ -385,7 +384,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag if(FAILED(hres)) return hres; - while(isspaceW(*str)) str++; + while(iswspace(*str)) str++; if(*str == '+') str++; @@ -394,10 +393,10 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag str++; } - if(isdigitW(*str)) + if(iswdigit(*str)) ret_nan = FALSE; - while(isdigitW(*str)) { + while(iswdigit(*str)) { hlp = d*10 + *(str++) - '0'; if(d>MAXLONGLONG/10 || hlp<0) { exp++; @@ -406,17 +405,17 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag else d = hlp; } - while(isdigitW(*str)) { + while(iswdigit(*str)) { exp++; str++; } if(*str == '.') str++; - if(isdigitW(*str)) + if(iswdigit(*str)) ret_nan = FALSE; - while(isdigitW(*str)) { + while(iswdigit(*str)) { hlp = d*10 + *(str++) - '0'; if(d>MAXLONGLONG/10 || hlp<0) break; @@ -424,7 +423,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag d = hlp; exp--; } - while(isdigitW(*str)) + while(iswdigit(*str)) str++; if(*str && !ret_nan && (*str=='e' || *str=='E')) { @@ -438,7 +437,7 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag str++; } - while(isdigitW(*str)) { + while(iswdigit(*str)) { if(e>INT_MAX/10 || (e = e*10 + *str++ - '0')<0) e = INT_MAX; } @@ -465,8 +464,8 @@ static HRESULT JSGlobal_parseFloat(script_ctx_t *ctx, vdisp_t *jsthis, WORD flag } static inline int hex_to_int(const WCHAR wch) { - if(toupperW(wch)>='A' && toupperW(wch)<='F') return toupperW(wch)-'A'+10; - if(isdigitW(wch)) return wch-'0'; + if(towupper(wch)>='A' && towupper(wch)<='F') return towupper(wch)-'A'+10; + if(iswdigit(wch)) return wch-'0'; return -1; } diff --git a/dll/win32/jscript/jscript.h b/dll/win32/jscript/jscript.h index 5149d0d4a3f..427ddf59cb9 100644 --- a/dll/win32/jscript/jscript.h +++ b/dll/win32/jscript/jscript.h @@ -20,19 +20,22 @@ #include <stdarg.h> #include <stdio.h> +#include <stdint.h> #define COBJMACROS #include "windef.h" #include "winbase.h" #include "winuser.h" +#ifdef __REACTOS__ +#include "winnls.h" +#endif #include "ole2.h" #include "dispex.h" #include "activscp.h" #include "resource.h" -#include "wine/unicode.h" #include "wine/heap.h" #include "wine/list.h" @@ -77,7 +80,7 @@ static inline LPWSTR heap_strdupW(LPCWSTR str) if(str) { DWORD size; - size = (strlenW(str)+1)*sizeof(WCHAR); + size = (lstrlenW(str)+1)*sizeof(WCHAR); ret = heap_alloc(size); if(ret) memcpy(ret, str, size); @@ -299,6 +302,7 @@ HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN; HRESULT jsdisp_get_own_property(jsdisp_t*,const WCHAR*,BOOL,property_desc_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_define_property(jsdisp_t*,const WCHAR*,property_desc_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_define_data_property(jsdisp_t*,const WCHAR*,unsigned,jsval_t) DECLSPEC_HIDDEN; +HRESULT jsdisp_next_prop(jsdisp_t*,DISPID,BOOL,DISPID*) DECLSPEC_HIDDEN; HRESULT create_builtin_function(script_ctx_t*,builtin_invoke_t,const WCHAR*,const builtin_info_t*,DWORD, jsdisp_t*,jsdisp_t**) DECLSPEC_HIDDEN; @@ -507,14 +511,6 @@ static inline BOOL is_vclass(vdisp_t *vdisp, jsclass_t class) return is_jsdisp(vdisp) && is_class(vdisp->u.jsdisp, class); } -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif - -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif - static inline BOOL is_int32(double d) { return INT32_MIN <= d && d <= INT32_MAX && (double)(int)d == d; diff --git a/dll/win32/jscript/json.c b/dll/win32/jscript/json.c index d4405436907..608237f32a9 100644 --- a/dll/win32/jscript/json.c +++ b/dll/win32/jscript/json.c @@ -23,7 +23,6 @@ #include "parser.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(jscript); @@ -89,14 +88,14 @@ static HRESULT parse_json_string(json_parse_ctx_t *ctx, WCHAR **r) return E_OUTOFMEMORY; if(len) memcpy(buf, ptr, len*sizeof(WCHAR)); - buf[len] = 0; - if(!unescape(buf)) { + if(!unescape(buf, &len)) { FIXME("unescape failed\n"); heap_free(buf); return E_FAIL; } + buf[len] = 0; ctx->ptr++; *r = buf; return S_OK; @@ -261,19 +260,12 @@ static HRESULT parse_json_value(json_parse_ctx_t *ctx, jsval_t *r) skip_spaces(ctx); } - if(!isdigitW(*ctx->ptr)) + if(*ctx->ptr == '0' && ctx->ptr + 1 < ctx->end && iswdigit(ctx->ptr[1])) break; - if(*ctx->ptr == '0') { - ctx->ptr++; - n = 0; - if(is_identifier_char(*ctx->ptr)) - break; - }else { - hres = parse_decimal(&ctx->ptr, ctx->end, &n); - if(FAILED(hres)) - return hres; - } + hres = parse_decimal(&ctx->ptr, ctx->end, &n); + if(FAILED(hres)) + break; *r = jsval_number(sign*n); return S_OK; @@ -402,7 +394,7 @@ static BOOL append_string_len(stringify_ctx_t *ctx, const WCHAR *str, size_t len static inline BOOL append_string(stringify_ctx_t *ctx, const WCHAR *str) { - return append_string_len(ctx, str, strlenW(str)); + return append_string_len(ctx, str, lstrlenW(str)); } static inline BOOL append_char(stringify_ctx_t *ctx, WCHAR c) @@ -489,7 +481,7 @@ static HRESULT json_quote(stringify_ctx_t *ctx, const WCHAR *ptr, size_t len) if(*ptr < ' ') { static const WCHAR formatW[] = {'\\','u','%','0','4','x',0}; WCHAR buf[7]; - sprintfW(buf, formatW, *ptr); + swprintf(buf, formatW, *ptr); if(!append_string(ctx, buf)) return E_OUTOFMEMORY; }else { diff --git a/dll/win32/jscript/jsregexp.c b/dll/win32/jscript/jsregexp.c index 84360694eed..d4ee506f03b 100644 --- a/dll/win32/jscript/jsregexp.c +++ b/dll/win32/jscript/jsregexp.c @@ -647,12 +647,12 @@ HRESULT create_regexp(script_ctx_t *ctx, jsstr_t *src, DWORD flags, jsdisp_t **r const WCHAR *str; HRESULT hres; - TRACE("%s %x\n", debugstr_jsstr(src), flags); - str = jsstr_flatten(src); if(!str) return E_OUTOFMEMORY; + TRACE("%s %x\n", debugstr_wn(str, jsstr_length(src)), flags); + hres = alloc_regexp(ctx, NULL, ®exp); if(FAILED(hres)) return hres; diff --git a/dll/win32/jscript/jsstr.h b/dll/win32/jscript/jsstr.h index d9506861241..e55fef23584 100644 --- a/dll/win32/jscript/jsstr.h +++ b/dll/win32/jscript/jsstr.h @@ -102,7 +102,7 @@ jsstr_t *jsstr_alloc_buf(unsigned,WCHAR**) DECLSPEC_HIDDEN; static inline jsstr_t *jsstr_alloc(const WCHAR *str) { - return jsstr_alloc_len(str, strlenW(str)); + return jsstr_alloc_len(str, lstrlenW(str)); } void jsstr_free(jsstr_t*) DECLSPEC_HIDDEN; diff --git a/dll/win32/jscript/jsutils.c b/dll/win32/jscript/jsutils.c index b653e525d81..33a61c2d856 100644 --- a/dll/win32/jscript/jsutils.c +++ b/dll/win32/jscript/jsutils.c @@ -16,8 +16,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> #include <assert.h> @@ -294,6 +296,12 @@ HRESULT variant_to_jsval(VARIANT *var, jsval_t *r) *r = jsval_disp(V_DISPATCH(var)); return S_OK; } + case VT_I1: + *r = jsval_number(V_I1(var)); + return S_OK; + case VT_UI1: + *r = jsval_number(V_UI1(var)); + return S_OK; case VT_I2: *r = jsval_number(V_I2(var)); return S_OK; @@ -516,7 +524,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret) if(!ptr) return E_OUTOFMEMORY; - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; if(*ptr == '-') { @@ -526,9 +534,9 @@ static HRESULT str_to_number(jsstr_t *str, double *ret) ptr++; } - if(!strncmpW(ptr, infinityW, ARRAY_SIZE(infinityW))) { + if(!wcsncmp(ptr, infinityW, ARRAY_SIZE(infinityW))) { ptr += ARRAY_SIZE(infinityW); - while(*ptr && isspaceW(*ptr)) + while(*ptr && iswspace(*ptr)) ptr++; if(*ptr) @@ -551,7 +559,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret) return S_OK; } - while(isdigitW(*ptr)) + while(iswdigit(*ptr)) d = d*10 + (*ptr++ - '0'); if(*ptr == 'e' || *ptr == 'E') { @@ -566,7 +574,7 @@ static HRESULT str_to_number(jsstr_t *str, double *ret) ptr++; } - while(isdigitW(*ptr)) + while(iswdigit(*ptr)) l = l*10 + (*ptr++ - '0'); if(eneg) l = -l; @@ -576,13 +584,13 @@ static HRESULT str_to_number(jsstr_t *str, double *ret) DOUBLE dec = 0.1; ptr++; - while(isdigitW(*ptr)) { + while(iswdigit(*ptr)) { d += dec * (*ptr++ - '0'); dec *= 0.1; } } - while(isspaceW(*ptr)) + while(iswspace(*ptr)) ptr++; if(*ptr) { @@ -894,6 +902,14 @@ HRESULT variant_change_type(script_ctx_t *ctx, VARIANT *dst, VARIANT *src, VARTY } break; } + case VT_UI2: { + UINT32 i; + + hres = to_uint32(ctx, val, &i); + if(SUCCEEDED(hres)) + V_UI2(dst) = i; + break; + } case VT_R8: { double n; hres = to_number(ctx, val, &n); diff --git a/dll/win32/jscript/lex.c b/dll/win32/jscript/lex.c index cbaebdbfa52..4f0ea45362e 100644 --- a/dll/win32/jscript/lex.c +++ b/dll/win32/jscript/lex.c @@ -16,10 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" #include <limits.h> +#include <math.h> #include "jscript.h" #include "activscp.h" @@ -30,86 +29,45 @@ #include "parser.tab.h" #include "wine/debug.h" -#include "wine/unicode.h" - -#ifdef __REACTOS__ -/* FIXME: Inspect - For some reason these exist in the generated header but are not picked up */ -#define kGET (270) -#define kSET (272) -#endif WINE_DEFAULT_DEBUG_CHANNEL(jscript); -static const WCHAR breakW[] = {'b','r','e','a','k',0}; -static const WCHAR caseW[] = {'c','a','s','e',0}; -static const WCHAR catchW[] = {'c','a','t','c','h',0}; -static const WCHAR continueW[] = {'c','o','n','t','i','n','u','e',0}; -static const WCHAR defaultW[] = {'d','e','f','a','u','l','t',0}; -static const WCHAR deleteW[] = {'d','e','l','e','t','e',0}; -static const WCHAR doW[] = {'d','o',0}; -static const WCHAR elseW[] = {'e','l','s','e',0}; -static const WCHAR falseW[] = {'f','a','l','s','e',0}; -static const WCHAR finallyW[] = {'f','i','n','a','l','l','y',0}; -static const WCHAR forW[] = {'f','o','r',0}; -static const WCHAR functionW[] = {'f','u','n','c','t','i','o','n',0}; -static const WCHAR getW[] = {'g','e','t',0}; -static const WCHAR ifW[] = {'i','f',0}; -static const WCHAR inW[] = {'i','n',0}; -static const WCHAR instanceofW[] = {'i','n','s','t','a','n','c','e','o','f',0}; -static const WCHAR newW[] = {'n','e','w',0}; -static const WCHAR nullW[] = {'n','u','l','l',0}; -static const WCHAR returnW[] = {'r','e','t','u','r','n',0}; -static const WCHAR setW[] = {'s','e','t',0}; -static const WCHAR switchW[] = {'s','w','i','t','c','h',0}; -static const WCHAR thisW[] = {'t','h','i','s',0}; -static const WCHAR throwW[] = {'t','h','r','o','w',0}; -static const WCHAR trueW[] = {'t','r','u','e',0}; -static const WCHAR tryW[] = {'t','r','y',0}; -static const WCHAR typeofW[] = {'t','y','p','e','o','f',0}; -static const WCHAR varW[] = {'v','a','r',0}; -static const WCHAR voidW[] = {'v','o','i','d',0}; -static const WCHAR whileW[] = {'w','h','i','l','e',0}; -static const WCHAR withW[] = {'w','i','t','h',0}; - -static const WCHAR elifW[] = {'e','l','i','f',0}; -static const WCHAR endW[] = {'e','n','d',0}; - static const struct { const WCHAR *word; int token; BOOL no_nl; unsigned min_version; } keywords[] = { - {breakW, kBREAK, TRUE}, - {caseW, kCASE}, - {catchW, kCATCH}, - {continueW, kCONTINUE, TRUE}, - {defaultW, kDEFAULT}, - {deleteW, kDELETE}, - {doW, kDO}, - {elseW, kELSE}, - {falseW, kFALSE}, - {finallyW, kFINALLY}, - {forW, kFOR}, - {functionW, kFUNCTION}, - {getW, kGET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, - {ifW, kIF}, - {inW, kIN}, - {instanceofW, kINSTANCEOF}, - {newW, kNEW}, - {nullW, kNULL}, - {returnW, kRETURN, TRUE}, - {setW, kSET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, - {switchW, kSWITCH}, - {thisW, kTHIS}, - {throwW, kTHROW}, - {trueW, kTRUE}, - {tryW, kTRY}, - {typeofW, kTYPEOF}, - {varW, kVAR}, - {voidW, kVOID}, - {whileW, kWHILE}, - {withW, kWITH} + {L"break", kBREAK, TRUE}, + {L"case", kCASE}, + {L"catch", kCATCH}, + {L"continue", kCONTINUE, TRUE}, + {L"default", kDEFAULT}, + {L"delete", kDELETE}, + {L"do", kDO}, + {L"else", kELSE}, + {L"false", kFALSE}, + {L"finally", kFINALLY}, + {L"for", kFOR}, + {L"function", kFUNCTION}, + {L"get", kGET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, + {L"if", kIF}, + {L"in", kIN}, + {L"instanceof", kINSTANCEOF}, + {L"new", kNEW}, + {L"null", kNULL}, + {L"return", kRETURN, TRUE}, + {L"set", kSET, FALSE, SCRIPTLANGUAGEVERSION_ES5}, + {L"switch", kSWITCH}, + {L"this", kTHIS}, + {L"throw", kTHROW}, + {L"true", kTRUE}, + {L"try", kTRY}, + {L"typeof", kTYPEOF}, + {L"var", kVAR}, + {L"void", kVOID}, + {L"while", kWHILE}, + {L"with", kWITH} }; static int lex_error(parser_ctx_t *ctx, HRESULT hres) @@ -122,12 +80,12 @@ static int lex_error(parser_ctx_t *ctx, HRESULT hres) /* ECMA-262 3rd Edition 7.6 */ BOOL is_identifier_char(WCHAR c) { - return isalnumW(c) || c == '$' || c == '_' || c == '\\'; + return iswalnum(c) || c == '$' || c == '_' || c == '\\'; } static BOOL is_identifier_first_char(WCHAR c) { - return isalphaW(c) || c == '$' || c == '_' || c == '\\'; + return iswalpha(c) || c == '$' || c == '_' || c == '\\'; } static int check_keyword(parser_ctx_t *ctx, const WCHAR *word, const WCHAR **lval) @@ -183,7 +141,7 @@ static int check_keywords(parser_ctx_t *ctx, const WCHAR **lval) if(ctx->script->version < keywords[i].min_version) { TRACE("ignoring keyword %s in incompatible mode\n", debugstr_w(keywords[i].word)); - ctx->ptr -= strlenW(keywords[i].word); + ctx->ptr -= lstrlenW(keywords[i].word); return 0; } ctx->implicit_nl_semicolon = keywords[i].no_nl; @@ -258,7 +216,7 @@ static BOOL skip_comment(parser_ctx_t *ctx) static BOOL skip_spaces(parser_ctx_t *ctx) { - while(ctx->ptr < ctx->end && (isspaceW(*ctx->ptr) || *ctx->ptr == 0xFEFF /* UTF16 BOM */)) { + while(ctx->ptr < ctx->end && (iswspace(*ctx->ptr) || *ctx->ptr == 0xFEFF /* UTF16 BOM */)) { if(is_endline(*ctx->ptr++)) ctx->nl = TRUE; } @@ -266,19 +224,20 @@ static BOOL skip_spaces(parser_ctx_t *ctx) return ctx->ptr != ctx->end; } -BOOL unescape(WCHAR *str) +BOOL unescape(WCHAR *str, size_t *len) { - WCHAR *pd, *p, c; + WCHAR *pd, *p, c, *end = str + *len; int i; pd = p = str; - while(*p) { + while(p < end) { if(*p != '\\') { *pd++ = *p++; continue; } - p++; + if(++p == end) + return FALSE; switch(*p) { case '\'': @@ -302,6 +261,8 @@ BOOL unescape(WCHAR *str) c = '\r'; break; case 'x': + if(p + 2 >= end) + return FALSE; i = hex_to_int(*++p); if(i == -1) return FALSE; @@ -313,6 +274,8 @@ BOOL unescape(WCHAR *str) c += i; break; case 'u': + if(p + 4 >= end) + return FALSE; i = hex_to_int(*++p); if(i == -1) return FALSE; @@ -334,11 +297,11 @@ BOOL unescape(WCHAR *str) c += i; break; default: - if(isdigitW(*p)) { + if(iswdigit(*p)) { c = *p++ - '0'; - if(isdigitW(*p)) { + if(p < end && iswdigit(*p)) { c = c*8 + (*p++ - '0'); - if(isdigitW(*p)) + if(p < end && iswdigit(*p)) c = c*8 + (*p++ - '0'); } p--; @@ -351,7 +314,7 @@ BOOL unescape(WCHAR *str) p++; } - *pd = 0; + *len = pd - str; return TRUE; } @@ -374,33 +337,41 @@ static int parse_identifier(parser_ctx_t *ctx, const WCHAR **ret) return tIdentifier; } -static int parse_string_literal(parser_ctx_t *ctx, const WCHAR **ret, WCHAR endch) +static int parse_string_literal(parser_ctx_t *ctx, jsstr_t **ret, WCHAR endch) { - const WCHAR *ptr = ++ctx->ptr; - WCHAR *wstr; - int len; + const WCHAR *ptr = ++ctx->ptr, *ret_str = ptr; + BOOL needs_unescape = FALSE; + WCHAR *unescape_str; + size_t len; while(ctx->ptr < ctx->end && *ctx->ptr != endch) { - if(*ctx->ptr++ == '\\') + if(*ctx->ptr++ == '\\') { ctx->ptr++; + needs_unescape = TRUE; + } } if(ctx->ptr == ctx->end) return lex_error(ctx, JS_E_UNTERMINATED_STRING); - len = ctx->ptr-ptr; - - *ret = wstr = parser_alloc(ctx, (len+1)*sizeof(WCHAR)); - memcpy(wstr, ptr, len*sizeof(WCHAR)); - wstr[len] = 0; - + len = ctx->ptr - ptr; ctx->ptr++; - if(!unescape(wstr)) { - WARN("unescape failed\n"); - return lex_error(ctx, E_FAIL); + if(needs_unescape) { + ret_str = unescape_str = parser_alloc(ctx, len * sizeof(WCHAR)); + if(!unescape_str) + return lex_error(ctx, E_OUTOFMEMORY); + memcpy(unescape_str, ptr, len * sizeof(WCHAR)); + if(!unescape(unescape_str, &len)) { + WARN("unescape failed\n"); + return lex_error(ctx, E_FAIL); + } } + if(!(*ret = compiler_alloc_string_len(ctx->compiler, ret_str, len))) + return lex_error(ctx, E_OUTOFMEMORY); + + /* FIXME: leaking string */ return tStringLiteral; } @@ -429,7 +400,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) LONGLONG d = 0, hlp; int exp = 0; - while(ptr < end && isdigitW(*ptr)) { + while(ptr < end && iswdigit(*ptr)) { hlp = d*10 + *(ptr++) - '0'; if(d>MAXLONGLONG/10 || hlp<0) { exp++; @@ -438,7 +409,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) else d = hlp; } - while(ptr < end && isdigitW(*ptr)) { + while(ptr < end && iswdigit(*ptr)) { exp++; ptr++; } @@ -446,7 +417,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) if(*ptr == '.') { ptr++; - while(ptr < end && isdigitW(*ptr)) { + while(ptr < end && iswdigit(*ptr)) { hlp = d*10 + *(ptr++) - '0'; if(d>MAXLONGLONG/10 || hlp<0) break; @@ -454,7 +425,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) d = hlp; exp--; } - while(ptr < end && isdigitW(*ptr)) + while(ptr < end && iswdigit(*ptr)) ptr++; } @@ -467,7 +438,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) }else if(*ptr == '-') { sign = -1; ptr++; - }else if(!isdigitW(*ptr)) { + }else if(!iswdigit(*ptr)) { WARN("Expected exponent part\n"); return E_FAIL; } @@ -478,7 +449,7 @@ HRESULT parse_decimal(const WCHAR **iter, const WCHAR *end, double *ret) return E_FAIL; } - while(ptr < end && isdigitW(*ptr)) { + while(ptr < end && iswdigit(*ptr)) { if(e > INT_MAX/10 || (e = e*10 + *ptr++ - '0')<0) e = INT_MAX; } @@ -529,12 +500,12 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret) return TRUE; } - if(isdigitW(*ctx->ptr)) { + if(iswdigit(*ctx->ptr)) { unsigned base = 8; const WCHAR *ptr; double val = 0; - for(ptr = ctx->ptr; ptr < ctx->end && isdigitW(*ptr); ptr++) { + for(ptr = ctx->ptr; ptr < ctx->end && iswdigit(*ptr); ptr++) { if(*ptr > '7') { base = 10; break; @@ -543,7 +514,7 @@ static BOOL parse_numeric_literal(parser_ctx_t *ctx, double *ret) do { val = val*base + *ctx->ptr-'0'; - }while(++ctx->ptr < ctx->end && isdigitW(*ctx->ptr)); + }while(++ctx->ptr < ctx->end && iswdigit(*ctx->ptr)); /* FIXME: Do we need it here? */ if(ctx->ptr < ctx->end && (is_identifier_char(*ctx->ptr) || *ctx->ptr == '.')) { @@ -585,7 +556,7 @@ static int next_token(parser_ctx_t *ctx, void *lval) ctx->implicit_nl_semicolon = FALSE; } - if(isalphaW(*ctx->ptr)) { + if(iswalpha(*ctx->ptr)) { int ret = check_keywords(ctx, lval); if(ret) return ret; @@ -593,7 +564,7 @@ static int next_token(parser_ctx_t *ctx, void *lval) return parse_identifier(ctx, lval); } - if(isdigitW(*ctx->ptr)) { + if(iswdigit(*ctx->ptr)) { double n; if(!parse_numeric_literal(ctx, &n)) @@ -620,7 +591,7 @@ static int next_token(parser_ctx_t *ctx, void *lval) return '}'; case '.': - if(ctx->ptr+1 < ctx->end && isdigitW(ctx->ptr[1])) { + if(ctx->ptr+1 < ctx->end && iswdigit(ctx->ptr[1])) { double n; HRESULT hres; hres = parse_decimal(&ctx->ptr, ctx->end, &n); @@ -860,7 +831,7 @@ static BOOL new_cc_var(cc_ctx_t *cc, const WCHAR *name, int len, ccval_t v) cc_var_t *new_v; if(len == -1) - len = strlenW(name); + len = lstrlenW(name); new_v = heap_alloc(sizeof(cc_var_t) + (len+1)*sizeof(WCHAR)); if(!new_v) @@ -890,14 +861,6 @@ static BOOL init_cc(parser_ctx_t *ctx) { cc_ctx_t *cc; - static const WCHAR _win32W[] = {'_','w','i','n','3','2',0}; - static const WCHAR _win64W[] = {'_','w','i','n','6','4',0}; - static const WCHAR _x86W[] = {'_','x','8','6',0}; - static const WCHAR _amd64W[] = {'_','a','m','d','6','4',0}; - static const WCHAR _jscriptW[] = {'_','j','s','c','r','i','p','t',0}; - static const WCHAR _jscript_buildW[] = {'_','j','s','c','r','i','p','t','_','b','u','i','l','d',0}; - static const WCHAR _jscript_versionW[] = {'_','j','s','c','r','i','p','t','_','v','e','r','s','i','o','n',0}; - if(ctx->script->cc) return TRUE; @@ -909,11 +872,11 @@ static BOOL init_cc(parser_ctx_t *ctx) cc->vars = NULL; - if(!new_cc_var(cc, _jscriptW, -1, ccval_bool(TRUE)) - || !new_cc_var(cc, sizeof(void*) == 8 ? _win64W : _win32W, -1, ccval_bool(TRUE)) - || !new_cc_var(cc, sizeof(void*) == 8 ? _amd64W : _x86W, -1, ccval_bool(TRUE)) - || !new_cc_var(cc, _jscript_versionW, -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0)) - || !new_cc_var(cc, _jscript_buildW, -1, ccval_num(JSCRIPT_BUILD_VERSION))) { + if(!new_cc_var(cc, L"_jscript", -1, ccval_bool(TRUE)) + || !new_cc_var(cc, sizeof(void*) == 8 ? L"_win64" : L"_win32", -1, ccval_bool(TRUE)) + || !new_cc_var(cc, sizeof(void*) == 8 ? L"_amd64" : L"_x86", -1, ccval_bool(TRUE)) + || !new_cc_var(cc, L"_jscript_version", -1, ccval_num(JSCRIPT_MAJOR_VERSION + (DOUBLE)JSCRIPT_MINOR_VERSION/10.0)) + || !new_cc_var(cc, L"_jscript_build", -1, ccval_num(JSCRIPT_BUILD_VERSION))) { release_cc(cc); lex_error(ctx, E_OUTOFMEMORY); return FALSE; @@ -946,7 +909,7 @@ int try_parse_ccval(parser_ctx_t *ctx, ccval_t *r) if(!skip_spaces(ctx)) return -1; - if(isdigitW(*ctx->ptr)) { + if(iswdigit(*ctx->ptr)) { double n; if(!parse_numeric_literal(ctx, &n)) @@ -969,12 +932,12 @@ int try_parse_ccval(parser_ctx_t *ctx, ccval_t *r) return 1; } - if(!check_keyword(ctx, trueW, NULL)) { + if(!check_keyword(ctx, L"true", NULL)) { *r = ccval_bool(TRUE); return 1; } - if(!check_keyword(ctx, falseW, NULL)) { + if(!check_keyword(ctx, L"false", NULL)) { *r = ccval_bool(FALSE); return 1; } @@ -988,20 +951,20 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) const WCHAR *ptr; while(1) { - ptr = strchrW(ctx->ptr, '@'); + ptr = wcschr(ctx->ptr, '@'); if(!ptr) { WARN("No @end\n"); return lex_error(ctx, JS_E_EXPECTED_CCEND); } ctx->ptr = ptr+1; - if(!check_keyword(ctx, endW, NULL)) { + if(!check_keyword(ctx, L"end", NULL)) { if(--if_depth) continue; return 0; } - if(exec_else && !check_keyword(ctx, elifW, NULL)) { + if(exec_else && !check_keyword(ctx, L"elif", NULL)) { if(if_depth > 1) continue; @@ -1019,7 +982,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) return 0; } - if(exec_else && !check_keyword(ctx, elseW, NULL)) { + if(exec_else && !check_keyword(ctx, L"else", NULL)) { if(if_depth > 1) continue; @@ -1028,7 +991,7 @@ static int skip_code(parser_ctx_t *ctx, BOOL exec_else) return 0; } - if(!check_keyword(ctx, ifW, NULL)) { + if(!check_keyword(ctx, L"if", NULL)) { if_depth++; continue; } @@ -1042,15 +1005,12 @@ static int cc_token(parser_ctx_t *ctx, void *lval) unsigned id_len = 0; cc_var_t *var; - static const WCHAR cc_onW[] = {'c','c','_','o','n',0}; - static const WCHAR setW[] = {'s','e','t',0}; - ctx->ptr++; - if(!check_keyword(ctx, cc_onW, NULL)) + if(!check_keyword(ctx, L"cc_on", NULL)) return init_cc(ctx) ? 0 : -1; - if(!check_keyword(ctx, setW, NULL)) { + if(!check_keyword(ctx, L"set", NULL)) { const WCHAR *ident; unsigned ident_len; cc_var_t *var; @@ -1084,7 +1044,7 @@ static int cc_token(parser_ctx_t *ctx, void *lval) return 0; } - if(!check_keyword(ctx, ifW, NULL)) { + if(!check_keyword(ctx, L"if", NULL)) { if(!init_cc(ctx)) return -1; @@ -1103,14 +1063,14 @@ static int cc_token(parser_ctx_t *ctx, void *lval) return skip_code(ctx, TRUE); } - if(!check_keyword(ctx, elifW, NULL) || !check_keyword(ctx, elseW, NULL)) { + if(!check_keyword(ctx, L"elif", NULL) || !check_keyword(ctx, L"else", NULL)) { if(!ctx->cc_if_depth) return lex_error(ctx, JS_E_SYNTAX); return skip_code(ctx, FALSE); } - if(!check_keyword(ctx, endW, NULL)) { + if(!check_keyword(ctx, L"end", NULL)) { if(!ctx->cc_if_depth) return lex_error(ctx, JS_E_SYNTAX); @@ -1193,7 +1153,7 @@ literal_t *parse_regexp(parser_ctx_t *ctx) re_len = ctx->ptr-re; flags_ptr = ++ctx->ptr; - while(ctx->ptr < ctx->end && isalnumW(*ctx->ptr)) + while(ctx->ptr < ctx->end && iswalnum(*ctx->ptr)) ctx->ptr++; hres = parse_regexp_flags(flags_ptr, ctx->ptr-flags_ptr, &flags); @@ -1202,8 +1162,7 @@ literal_t *parse_regexp(parser_ctx_t *ctx) ret = parser_alloc(ctx, sizeof(literal_t)); ret->type = LT_REGEXP; - ret->u.regexp.str = re; - ret->u.regexp.str_len = re_len; + ret->u.regexp.str = compiler_alloc_string_len(ctx->compiler, re, re_len); ret->u.regexp.flags = flags; return ret; } diff --git a/dll/win32/jscript/math.c b/dll/win32/jscript/math.c index dc07a97758a..caceb6d94c7 100644 --- a/dll/win32/jscript/math.c +++ b/dll/win32/jscript/math.c @@ -17,8 +17,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" -#include "wine/port.h" +#ifdef __REACTOS__ +#include <wine/config.h> +#include <wine/port.h> +#endif #include <math.h> #include <limits.h> diff --git a/dll/win32/jscript/number.c b/dll/win32/jscript/number.c index 3d9890b36ab..bf67dfa0415 100644 --- a/dll/win32/jscript/number.c +++ b/dll/win32/jscript/number.c @@ -332,7 +332,7 @@ static HRESULT Number_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u ch = '-'; } else ch = '+'; - sprintfW(&buf[idx], formatW, ch, (int)log_radix); + swprintf(&buf[idx], formatW, ch, (int)log_radix); } } else buf[idx] = '\0'; diff --git a/dll/win32/jscript/object.c b/dll/win32/jscript/object.c index 6ba99db108b..206f12a1afc 100644 --- a/dll/win32/jscript/object.c +++ b/dll/win32/jscript/object.c @@ -32,8 +32,11 @@ static const WCHAR propertyIsEnumerableW[] = {'p','r','o','p','e','r','t','y','I','s','E','n','u','m','e','r','a','b','l','e',0}; static const WCHAR isPrototypeOfW[] = {'i','s','P','r','o','t','o','t','y','p','e','O','f',0}; +static const WCHAR createW[] = {'c','r','e','a','t','e',0}; static const WCHAR getOwnPropertyDescriptorW[] = {'g','e','t','O','w','n','P','r','o','p','e','r','t','y','D','e','s','c','r','i','p','t','o','r',0}; +static const WCHAR getPrototypeOfW[] = + {'g','e','t','P','r','o','t','o','t','y','p','e','O','f',0}; static const WCHAR definePropertyW[] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','y',0}; static const WCHAR definePropertiesW[] = {'d','e','f','i','n','e','P','r','o','p','e','r','t','i','e','s',0}; @@ -86,11 +89,11 @@ static HRESULT Object_toString(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, u jsstr_t *ret; WCHAR *ptr; - ret = jsstr_alloc_buf(9+strlenW(str), &ptr); + ret = jsstr_alloc_buf(9+lstrlenW(str), &ptr); if(!ret) return E_OUTOFMEMORY; - sprintfW(ptr, formatW, str); + swprintf(ptr, formatW, str); *r = jsval_string(ret); } @@ -406,6 +409,57 @@ static HRESULT to_property_descriptor(script_ctx_t *ctx, jsdisp_t *attr_obj, pro return hres; } +static HRESULT jsdisp_define_properties(script_ctx_t *ctx, jsdisp_t *obj, jsval_t list_val) +{ + DISPID id = DISPID_STARTENUM; + property_desc_t prop_desc; + IDispatch *list_disp; + jsdisp_t *list_obj, *desc_obj; + jsval_t desc_val; + BSTR name; + HRESULT hres; + + hres = to_object(ctx, list_val, &list_disp); + if(FAILED(hres)) + return hres; + + if(!(list_obj = to_jsdisp(list_disp))) { + FIXME("non-JS list obj\n"); + IDispatch_Release(list_disp); + return E_NOTIMPL; + } + + while(1) { + hres = jsdisp_next_prop(list_obj, id, TRUE, &id); + if(hres != S_OK) + break; + + hres = jsdisp_propget(list_obj, id, &desc_val); + if(FAILED(hres)) + break; + + if(!is_object_instance(desc_val) || !get_object(desc_val) || !(desc_obj = to_jsdisp(get_object(desc_val)))) { + jsval_release(desc_val); + break; + } + + hres = to_property_descriptor(ctx, desc_obj, &prop_desc); + jsdisp_release(desc_obj); + if(FAILED(hres)) + break; + + hres = IDispatchEx_GetMemberName(&list_obj->IDispatchEx_iface, id, &name); + if(SUCCEEDED(hres)) + hres = jsdisp_define_property(obj, name, &prop_desc); + release_property_descriptor(&prop_desc); + if(FAILED(hres)) + break; + } + + jsdisp_release(list_obj); + return FAILED(hres) ? hres : S_OK; +} + static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { @@ -446,14 +500,28 @@ static HRESULT Object_defineProperty(script_ctx_t *ctx, vdisp_t *jsthis, WORD fl hres = jsdisp_define_property(obj, name, &prop_desc); release_property_descriptor(&prop_desc); + if(SUCCEEDED(hres) && r) + *r = jsval_obj(jsdisp_addref(obj)); return hres; } static HRESULT Object_defineProperties(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r) { - FIXME("\n"); - return E_NOTIMPL; + jsdisp_t *obj; + HRESULT hres; + + if(argc < 1 || !is_object_instance(argv[0]) || !get_object(argv[0]) || !(obj = to_jsdisp(get_object(argv[0])))) { + FIXME("not an object\n"); + return E_NOTIMPL; + } + + TRACE("%p\n", obj); + + hres = jsdisp_define_properties(ctx, obj, argc >= 2 ? argv[1] : jsval_undefined()); + if(SUCCEEDED(hres) && r) + *r = jsval_obj(jsdisp_addref(obj)); + return hres; } static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, @@ -519,10 +587,76 @@ static HRESULT Object_getOwnPropertyDescriptor(script_ctx_t *ctx, vdisp_t *jsthi return hres; } +static HRESULT Object_create(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + jsdisp_t *proto = NULL, *obj; + HRESULT hres; + + if(!argc || (!is_object_instance(argv[0]) && !is_null(argv[0]))) { + FIXME("Invalid arg\n"); + return E_INVALIDARG; + } + + TRACE("(%s)\n", debugstr_jsval(argv[0])); + + if(argc && is_object_instance(argv[0])) { + if(get_object(argv[0])) + proto = to_jsdisp(get_object(argv[0])); + if(!proto) { + FIXME("Non-JS prototype\n"); + return E_NOTIMPL; + } + }else if(!is_null(argv[0])) { + FIXME("Invalid arg %s\n", debugstr_jsval(argc ? argv[0] : jsval_undefined())); + return E_INVALIDARG; + } + + hres = create_dispex(ctx, NULL, proto, &obj); + if(FAILED(hres)) + return hres; + + if(argc >= 2 && !is_undefined(argv[1])) + hres = jsdisp_define_properties(ctx, obj, argv[1]); + + if(SUCCEEDED(hres) && r) + *r = jsval_obj(obj); + else + jsdisp_release(obj); + return hres; +} + +static HRESULT Object_getPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, + unsigned argc, jsval_t *argv, jsval_t *r) +{ + jsdisp_t *obj; + + if(!argc || !is_object_instance(argv[0])) { + FIXME("invalid arguments\n"); + return E_NOTIMPL; + } + + TRACE("(%s)\n", debugstr_jsval(argv[1])); + + obj = to_jsdisp(get_object(argv[0])); + if(!obj) { + FIXME("Non-JS object\n"); + return E_NOTIMPL; + } + + if(r) + *r = obj->prototype + ? jsval_obj(jsdisp_addref(obj->prototype)) + : jsval_null(); + return S_OK; +} + static const builtin_prop_t ObjectConstr_props[] = { + {createW, Object_create, PROPF_ES5|PROPF_METHOD|2}, {definePropertiesW, Object_defineProperties, PROPF_ES5|PROPF_METHOD|2}, {definePropertyW, Object_defineProperty, PROPF_ES5|PROPF_METHOD|2}, - {getOwnPropertyDescriptorW, Object_getOwnPropertyDescriptor, PROPF_ES5|PROPF_METHOD|2} + {getOwnPropertyDescriptorW, Object_getOwnPropertyDescriptor, PROPF_ES5|PROPF_METHOD|2}, + {getPrototypeOfW, Object_getPrototypeOf, PROPF_ES5|PROPF_METHOD|1} }; static const builtin_info_t ObjectConstr_info = { diff --git a/dll/win32/jscript/parser.h b/dll/win32/jscript/parser.h index f19db5bd5e6..b7a9f72ae8f 100644 --- a/dll/win32/jscript/parser.h +++ b/dll/win32/jscript/parser.h @@ -36,6 +36,7 @@ typedef struct _parser_ctx_t { const WCHAR *ptr; script_ctx_t *script; + struct _compiler_ctx_t *compiler; source_elements_t *source; BOOL nl; BOOL implicit_nl_semicolon; @@ -49,7 +50,7 @@ typedef struct _parser_ctx_t { heap_pool_t heap; } parser_ctx_t; -HRESULT script_parse(script_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN; +HRESULT script_parse(script_ctx_t*,struct _compiler_ctx_t*,const WCHAR*,const WCHAR*,BOOL,parser_ctx_t**) DECLSPEC_HIDDEN; void parser_release(parser_ctx_t*) DECLSPEC_HIDDEN; int parser_lex(void*,parser_ctx_t*) DECLSPEC_HIDDEN; @@ -65,7 +66,7 @@ static inline void *parser_alloc_tmp(parser_ctx_t *ctx, DWORD size) } BOOL is_identifier_char(WCHAR) DECLSPEC_HIDDEN; -BOOL unescape(WCHAR*) DECLSPEC_HIDDEN; +BOOL unescape(WCHAR*,size_t*) DECLSPEC_HIDDEN; HRESULT parse_decimal(const WCHAR**,const WCHAR*,double*) DECLSPEC_HIDDEN; typedef enum { @@ -80,11 +81,10 @@ typedef struct { literal_type_t type; union { double dval; - const WCHAR *wstr; + jsstr_t *str; BOOL bval; struct { - const WCHAR *str; - DWORD str_len; + jsstr_t *str; DWORD flags; } regexp; } u; @@ -401,3 +401,5 @@ static inline double get_ccnum(ccval_t v) { return v.is_num ? v.u.n : v.u.b; } + +jsstr_t *compiler_alloc_string_len(struct _compiler_ctx_t*,const WCHAR *,unsigned) DECLSPEC_HIDDEN; diff --git a/dll/win32/jscript/parser.tab.c b/dll/win32/jscript/parser.tab.c index 43d616134d5..246a38ce53c 100644 --- a/dll/win32/jscript/parser.tab.c +++ b/dll/win32/jscript/parser.tab.c @@ -1,8 +1,9 @@ -/* A Bison parser, made by GNU Bison 3.0. */ +/* A Bison parser, made by GNU Bison 3.4.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 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 @@ -40,11 +41,14 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ +/* Undocumented macros, especially those whose name start with YY_, + are private implementation details. Do not rely on them. */ + /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0" +#define YYBISON_VERSION "3.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -67,8 +71,8 @@ #define yynerrs parser_nerrs -/* Copy the first part of user declarations. */ -#line 19 "parser.y" /* yacc.c:339 */ +/* First part of user prologue. */ +#line 19 "parser.y" #include "jscript.h" @@ -90,7 +94,7 @@ typedef struct _statement_list_t { statement_t *tail; } statement_list_t; -static literal_t *new_string_literal(parser_ctx_t*,const WCHAR*); +static literal_t *new_string_literal(parser_ctx_t*,jsstr_t*); static literal_t *new_null_literal(parser_ctx_t*); typedef struct _property_list_t { @@ -191,13 +195,17 @@ static source_elements_t *new_source_elements(parser_ctx_t*); static source_elements_t *source_elements_add_statement(source_elements_t*,statement_t*); -#line 195 "parser.tab.c" /* yacc.c:339 */ +#line 199 "parser.tab.c" -# ifndef YY_NULL -# if defined __cplusplus && 201103L <= __cplusplus -# define YY_NULL nullptr +# ifndef YY_NULLPTR +# if defined __cplusplus +# if 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif # else -# define YY_NULL 0 +# define YY_NULLPTR ((void*)0) # endif # endif @@ -209,8 +217,8 @@ static source_elements_t *source_elements_add_statement(source_elements_t*,state # define YYERROR_VERBOSE 0 #endif -/* In a future release of Bison, this section will be replaced - by #include "parser.tab.h". */ +/* Use api.header.include to #include this header + instead of duplicating it here. */ #ifndef YY_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_PARSER_TAB_H_INCLUDED # define YY_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_PARSER_TAB_H_INCLUDED /* Debug traces. */ @@ -278,14 +286,13 @@ extern int parser_debug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED -typedef union YYSTYPE YYSTYPE; union YYSTYPE { -#line 147 "parser.y" /* yacc.c:355 */ +#line 147 "parser.y" int ival; const WCHAR *srcptr; - LPCWSTR wstr; + jsstr_t *str; literal_t *literal; struct _argument_list_t *argument_list; case_clausule_t *case_clausule; @@ -303,8 +310,10 @@ union YYSTYPE struct _variable_list_t *variable_list; variable_declaration_t *variable_declaration; -#line 307 "parser.tab.c" /* yacc.c:355 */ +#line 314 "parser.tab.c" + }; +typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 #endif @@ -315,9 +324,7 @@ int parser_parse (parser_ctx_t *ctx); #endif /* !YY_PARSER_E_REACTOSSYNC_GCC_DLL_WIN32_JSCRIPT_PARSER_TAB_H_INCLUDED */ -/* Copy the second part of user declarations. */ -#line 321 "parser.tab.c" /* yacc.c:358 */ #ifdef short # undef short @@ -338,13 +345,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -356,7 +363,7 @@ typedef short int yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -374,14 +381,24 @@ typedef short int yytype_int16; # endif #endif -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if (! defined __GNUC__ || __GNUC__ < 2 \ - || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)) -# define __attribute__(Spec) /* empty */ +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ # endif #endif +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -389,7 +406,7 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -409,6 +426,8 @@ typedef short int yytype_int16; #endif +#define YY_ASSERT(E) ((void) (0 && (E))) + #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -551,16 +570,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 454 -/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned - by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 304 +/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, without out-of-bounds checking. */ + as returned by yylex. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -674,7 +693,7 @@ static const char *const yytname[] = "PropertyNameAndValueList", "PropertyDefinition", "GetterSetterMethod", "PropertyName", "Identifier_opt", "IdentifierName", "ReservedAsIdentifier", "Literal", "BooleanLiteral", "semicolon_opt", - "left_bracket", "right_bracket", "semicolon", YY_NULL + "left_bracket", "right_bracket", "semicolon", YY_NULLPTR }; #endif @@ -1257,22 +1276,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (ctx, YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (0) +#define YYBACKUP(Token, Value) \ + do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (ctx, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ + while (0) /* Error token number */ #define YYTERROR 1 @@ -1312,38 +1331,38 @@ do { \ } while (0) -/*----------------------------------------. -| Print this symbol's value on YYOUTPUT. | -`----------------------------------------*/ +/*-----------------------------------. +| Print this symbol's value on YYO. | +`-----------------------------------*/ static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) +yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) { - FILE *yyo = yyoutput; - YYUSE (yyo); + FILE *yyoutput = yyo; + YYUSE (yyoutput); YYUSE (ctx); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); + YYPRINT (yyo, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +/*---------------------------. +| Print this symbol on YYO. | +`---------------------------*/ static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) +yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, parser_ctx_t *ctx) { - YYFPRINTF (yyoutput, "%s %s (", + YYFPRINTF (yyo, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyoutput, yytype, yyvaluep, ctx); - YYFPRINTF (yyoutput, ")"); + yy_symbol_value_print (yyo, yytype, yyvaluep, ctx); + YYFPRINTF (yyo, ")"); } /*------------------------------------------------------------------. @@ -1377,7 +1396,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_ctx_t *ctx) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -1388,7 +1407,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parser_ctx_t * YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &(yyvsp[(yyi + 1) - (yynrhs)]) + &yyvsp[(yyi + 1) - (yynrhs)] , ctx); YYFPRINTF (stderr, "\n"); } @@ -1492,7 +1511,10 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - /* Fall through. */ + else + goto append; + + append: default: if (yyres) yyres[yyn] = *yyp; @@ -1510,7 +1532,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return yystpcpy (yyres, yystr) - yyres; + return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); } # endif @@ -1526,11 +1548,11 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); YYSIZE_T yysize = yysize0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = YY_NULL; + const char *yyformat = YY_NULLPTR; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1587,11 +1609,11 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, } yyarg[yycount++] = yytname[yyx]; { - YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } } } @@ -1603,6 +1625,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1614,9 +1637,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) + yysize = yysize1; + else return 2; - yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1747,23 +1771,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; + /*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | +| yynewstate -- push a new state, which is found in yystate. | `------------------------------------------------------------*/ - yynewstate: +yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - yysetstate: - *yyssp = yystate; + +/*--------------------------------------------------------------------. +| yynewstate -- set current state (the top of the stack) to yystate. | +`--------------------------------------------------------------------*/ +yysetstate: + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + YY_ASSERT (0 <= yystate && yystate < YYNSTATES); + *yyssp = (yytype_int16) yystate; if (yyss + yystacksize - 1 <= yyssp) +#if !defined yyoverflow && !defined YYSTACK_RELOCATE + goto yyexhaustedlab; +#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; + YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); -#ifdef yyoverflow +# if defined yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1779,14 +1813,10 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); - yyss = yyss1; yyvs = yyvs1; } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyexhaustedlab; -# else +# else /* defined YYSTACK_RELOCATE */ /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1802,35 +1832,33 @@ YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default); goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif -#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); +#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ if (yystate == YYFINAL) YYACCEPT; goto yybackup; + /*-----------. | yybackup. | `-----------*/ yybackup: - /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1888,7 +1916,6 @@ yybackup: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END - goto yynewstate; @@ -1903,7 +1930,7 @@ yydefault: /*-----------------------------. -| yyreduce -- Do a reduction. | +| yyreduce -- do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1923,1160 +1950,1160 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: -#line 259 "parser.y" /* yacc.c:1646 */ + case 2: +#line 259 "parser.y" { program_parsed(ctx, (yyvsp[-2].source_elements)); } -#line 1930 "parser.tab.c" /* yacc.c:1646 */ +#line 1957 "parser.tab.c" break; case 3: -#line 262 "parser.y" /* yacc.c:1646 */ +#line 262 "parser.y" {} -#line 1936 "parser.tab.c" /* yacc.c:1646 */ +#line 1963 "parser.tab.c" break; case 4: -#line 263 "parser.y" /* yacc.c:1646 */ +#line 263 "parser.y" {} -#line 1942 "parser.tab.c" /* yacc.c:1646 */ +#line 1969 "parser.tab.c" break; case 5: -#line 267 "parser.y" /* yacc.c:1646 */ +#line 267 "parser.y" { (yyval.source_elements) = new_source_elements(ctx); } -#line 1948 "parser.tab.c" /* yacc.c:1646 */ +#line 1975 "parser.tab.c" break; case 6: -#line 269 "parser.y" /* yacc.c:1646 */ +#line 269 "parser.y" { (yyval.source_elements) = source_elements_add_statement((yyvsp[-1].source_elements), (yyvsp[0].statement)); } -#line 1954 "parser.tab.c" /* yacc.c:1646 */ +#line 1981 "parser.tab.c" break; case 7: -#line 274 "parser.y" /* yacc.c:1646 */ +#line 274 "parser.y" { (yyval.expr) = new_function_expression(ctx, NULL, (yyvsp[-4].parameter_list), (yyvsp[-1].source_elements), NULL, (yyvsp[-6].srcptr), (yyvsp[0].srcptr)-(yyvsp[-6].srcptr)+1); } -#line 1960 "parser.tab.c" /* yacc.c:1646 */ +#line 1987 "parser.tab.c" break; case 8: -#line 276 "parser.y" /* yacc.c:1646 */ +#line 276 "parser.y" { (yyval.expr) = new_function_expression(ctx, (yyvsp[-6].identifier), (yyvsp[-4].parameter_list), (yyvsp[-1].source_elements), NULL, (yyvsp[-7].srcptr), (yyvsp[0].srcptr)-(yyvsp[-7].srcptr)+1); } -#line 1966 "parser.tab.c" /* yacc.c:1646 */ +#line 1993 "parser.tab.c" break; case 9: -#line 278 "parser.y" /* yacc.c:1646 */ +#line 278 "parser.y" { (yyval.expr) = new_function_expression(ctx, (yyvsp[-6].identifier), (yyvsp[-4].parameter_list), (yyvsp[-1].source_elements), (yyvsp[-8].identifier), (yyvsp[-9].srcptr), (yyvsp[0].srcptr)-(yyvsp[-9].srcptr)+1); } -#line 1972 "parser.tab.c" /* yacc.c:1646 */ +#line 1999 "parser.tab.c" break; case 10: -#line 281 "parser.y" /* yacc.c:1646 */ +#line 281 "parser.y" { (yyval.srcptr) = ctx->ptr - 8; } -#line 1978 "parser.tab.c" /* yacc.c:1646 */ +#line 2005 "parser.tab.c" break; case 11: -#line 285 "parser.y" /* yacc.c:1646 */ +#line 285 "parser.y" { (yyval.source_elements) = (yyvsp[0].source_elements); } -#line 1984 "parser.tab.c" /* yacc.c:1646 */ +#line 2011 "parser.tab.c" break; case 12: -#line 289 "parser.y" /* yacc.c:1646 */ +#line 289 "parser.y" { (yyval.parameter_list) = new_parameter_list(ctx, (yyvsp[0].identifier)); } -#line 1990 "parser.tab.c" /* yacc.c:1646 */ +#line 2017 "parser.tab.c" break; case 13: -#line 291 "parser.y" /* yacc.c:1646 */ +#line 291 "parser.y" { (yyval.parameter_list) = parameter_list_add(ctx, (yyvsp[-2].parameter_list), (yyvsp[0].identifier)); } -#line 1996 "parser.tab.c" /* yacc.c:1646 */ +#line 2023 "parser.tab.c" break; case 14: -#line 295 "parser.y" /* yacc.c:1646 */ +#line 295 "parser.y" { (yyval.parameter_list) = NULL; } -#line 2002 "parser.tab.c" /* yacc.c:1646 */ +#line 2029 "parser.tab.c" break; case 15: -#line 296 "parser.y" /* yacc.c:1646 */ +#line 296 "parser.y" { (yyval.parameter_list) = (yyvsp[0].parameter_list); } -#line 2008 "parser.tab.c" /* yacc.c:1646 */ +#line 2035 "parser.tab.c" break; case 16: -#line 300 "parser.y" /* yacc.c:1646 */ +#line 300 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2014 "parser.tab.c" /* yacc.c:1646 */ +#line 2041 "parser.tab.c" break; case 17: -#line 301 "parser.y" /* yacc.c:1646 */ +#line 301 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2020 "parser.tab.c" /* yacc.c:1646 */ +#line 2047 "parser.tab.c" break; case 18: -#line 302 "parser.y" /* yacc.c:1646 */ +#line 302 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2026 "parser.tab.c" /* yacc.c:1646 */ +#line 2053 "parser.tab.c" break; case 19: -#line 303 "parser.y" /* yacc.c:1646 */ +#line 303 "parser.y" { (yyval.statement) = new_expression_statement(ctx, (yyvsp[0].expr)); } -#line 2032 "parser.tab.c" /* yacc.c:1646 */ +#line 2059 "parser.tab.c" break; case 20: -#line 304 "parser.y" /* yacc.c:1646 */ +#line 304 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2038 "parser.tab.c" /* yacc.c:1646 */ +#line 2065 "parser.tab.c" break; case 21: -#line 305 "parser.y" /* yacc.c:1646 */ +#line 305 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2044 "parser.tab.c" /* yacc.c:1646 */ +#line 2071 "parser.tab.c" break; case 22: -#line 306 "parser.y" /* yacc.c:1646 */ +#line 306 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2050 "parser.tab.c" /* yacc.c:1646 */ +#line 2077 "parser.tab.c" break; case 23: -#line 307 "parser.y" /* yacc.c:1646 */ +#line 307 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2056 "parser.tab.c" /* yacc.c:1646 */ +#line 2083 "parser.tab.c" break; case 24: -#line 308 "parser.y" /* yacc.c:1646 */ +#line 308 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2062 "parser.tab.c" /* yacc.c:1646 */ +#line 2089 "parser.tab.c" break; case 25: -#line 309 "parser.y" /* yacc.c:1646 */ +#line 309 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2068 "parser.tab.c" /* yacc.c:1646 */ +#line 2095 "parser.tab.c" break; case 26: -#line 310 "parser.y" /* yacc.c:1646 */ +#line 310 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2074 "parser.tab.c" /* yacc.c:1646 */ +#line 2101 "parser.tab.c" break; case 27: -#line 311 "parser.y" /* yacc.c:1646 */ +#line 311 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2080 "parser.tab.c" /* yacc.c:1646 */ +#line 2107 "parser.tab.c" break; case 28: -#line 312 "parser.y" /* yacc.c:1646 */ +#line 312 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2086 "parser.tab.c" /* yacc.c:1646 */ +#line 2113 "parser.tab.c" break; case 29: -#line 313 "parser.y" /* yacc.c:1646 */ +#line 313 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2092 "parser.tab.c" /* yacc.c:1646 */ +#line 2119 "parser.tab.c" break; case 30: -#line 314 "parser.y" /* yacc.c:1646 */ +#line 314 "parser.y" { (yyval.statement) = (yyvsp[0].statement); } -#line 2098 "parser.tab.c" /* yacc.c:1646 */ +#line 2125 "parser.tab.c" break; case 31: -#line 318 "parser.y" /* yacc.c:1646 */ +#line 318 "parser.y" { (yyval.statement_list) = new_statement_list(ctx, (yyvsp[0].statement)); } -#line 2104 "parser.tab.c" /* yacc.c:1646 */ +#line 2131 "parser.tab.c" break; case 32: -#line 320 "parser.y" /* yacc.c:1646 */ +#line 320 "parser.y" { (yyval.statement_list) = statement_list_add((yyvsp[-1].statement_list), (yyvsp[0].statement)); } -#line 2110 "parser.tab.c" /* yacc.c:1646 */ +#line 2137 "parser.tab.c" break; case 33: -#line 324 "parser.y" /* yacc.c:1646 */ +#line 324 "parser.y" { (yyval.statement_list) = NULL; } -#line 2116 "parser.tab.c" /* yacc.c:1646 */ +#line 2143 "parser.tab.c" break; case 34: -#line 325 "parser.y" /* yacc.c:1646 */ +#line 325 "parser.y" { (yyval.statement_list) = (yyvsp[0].statement_list); } -#line 2122 "parser.tab.c" /* yacc.c:1646 */ +#line 2149 "parser.tab.c" break; case 35: -#line 329 "parser.y" /* yacc.c:1646 */ +#line 329 "parser.y" { (yyval.statement) = new_block_statement(ctx, (yyvsp[-1].statement_list)); } -#line 2128 "parser.tab.c" /* yacc.c:1646 */ +#line 2155 "parser.tab.c" break; case 36: -#line 330 "parser.y" /* yacc.c:1646 */ +#line 330 "parser.y" { (yyval.statement) = new_block_statement(ctx, NULL); } -#line 2134 "parser.tab.c" /* yacc.c:1646 */ +#line 2161 "parser.tab.c" break; case 37: -#line 335 "parser.y" /* yacc.c:1646 */ +#line 335 "parser.y" { (yyval.statement) = new_var_statement(ctx, (yyvsp[-1].variable_list)); } -#line 2140 "parser.tab.c" /* yacc.c:1646 */ +#line 2167 "parser.tab.c" break; case 38: -#line 339 "parser.y" /* yacc.c:1646 */ +#line 339 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[0].variable_declaration)); } -#line 2146 "parser.tab.c" /* yacc.c:1646 */ +#line 2173 "parser.tab.c" break; case 39: -#line 341 "parser.y" /* yacc.c:1646 */ +#line 341 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[-2].variable_list), (yyvsp[0].variable_declaration)); } -#line 2152 "parser.tab.c" /* yacc.c:1646 */ +#line 2179 "parser.tab.c" break; case 40: -#line 346 "parser.y" /* yacc.c:1646 */ +#line 346 "parser.y" { (yyval.variable_list) = new_variable_list(ctx, (yyvsp[0].variable_declaration)); } -#line 2158 "parser.tab.c" /* yacc.c:1646 */ +#line 2185 "parser.tab.c" break; case 41: -#line 348 "parser.y" /* yacc.c:1646 */ +#line 348 "parser.y" { (yyval.variable_list) = variable_list_add(ctx, (yyvsp[-2].variable_list), (yyvsp[0].variable_declaration)); } -#line 2164 "parser.tab.c" /* yacc.c:1646 */ +#line 2191 "parser.tab.c" break; case 42: -#line 353 "parser.y" /* yacc.c:1646 */ +#line 353 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[-1].identifier), (yyvsp[0].expr)); } -#line 2170 "parser.tab.c" /* yacc.c:1646 */ +#line 2197 "parser.tab.c" break; case 43: -#line 358 "parser.y" /* yacc.c:1646 */ +#line 358 "parser.y" { (yyval.variable_declaration) = new_variable_declaration(ctx, (yyvsp[-1].identifier), (yyvsp[0].expr)); } -#line 2176 "parser.tab.c" /* yacc.c:1646 */ +#line 2203 "parser.tab.c" break; case 44: -#line 362 "parser.y" /* yacc.c:1646 */ +#line 362 "parser.y" { (yyval.expr) = NULL; } -#line 2182 "parser.tab.c" /* yacc.c:1646 */ +#line 2209 "parser.tab.c" break; case 45: -#line 363 "parser.y" /* yacc.c:1646 */ +#line 363 "parser.y" { (yyval.expr) = (yyvsp[0].expr); } -#line 2188 "parser.tab.c" /* yacc.c:1646 */ +#line 2215 "parser.tab.c" break; case 46: -#line 368 "parser.y" /* yacc.c:1646 */ +#line 368 "parser.y" { (yyval.expr) = (yyvsp[0].expr); } -#line 2194 "parser.tab.c" /* yacc.c:1646 */ +#line 2221 "parser.tab.c" break; case 47: -#line 372 "parser.y" /* yacc.c:1646 */ +#line 372 "parser.y" { (yyval.expr) = NULL; } -#line 2200 "parser.tab.c" /* yacc.c:1646 */ +#line 2227 "parser.tab.c" break; case 48: -#line 373 "parser.y" /* yacc.c:1646 */ +#line 373 "parser.y" { (yyval.expr) = (yyvsp[0].expr); } -#line 2206 "parser.tab.c" /* yacc.c:1646 */ +#line 2233 "parser.tab.c" break; case 49: -#line 378 "parser.y" /* yacc.c:1646 */ +#line 378 "parser.y" { (yyval.expr) = (yyvsp[0].expr); } -#line 2212 "parser.tab.c" /* yacc.c:1646 */ +#line 2239 "parser.tab.c" break; case 50: -#line 382 "parser.y" /* yacc.c:1646 */ +#line 382 "parser.y" { (yyval.statement) = new_statement(ctx, STAT_EMPTY, 0); } -#line 2218 "parser.tab.c" /* yacc.c:1646 */ +#line 2245 "parser.tab.c" break; case 51: -#line 387 "parser.y" /* yacc.c:1646 */ +#line 387 "parser.y" { (yyval.statement) = new_expression_statement(ctx, (yyvsp[-1].expr)); } -#line 2224 "parser.tab.c" /* yacc.c:1646 */ +#line 2251 "parser.tab.c" break; case 52: -#line 392 "parser.y" /* yacc.c:1646 */ +#line 392 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[-4].expr), (yyvsp[-2].statement), (yyvsp[0].statement)); } -#line 2230 "parser.tab.c" /* yacc.c:1646 */ +#line 2257 "parser.tab.c" break; case 53: -#line 394 "parser.y" /* yacc.c:1646 */ +#line 394 "parser.y" { (yyval.statement) = new_if_statement(ctx, (yyvsp[-2].expr), (yyvsp[0].statement), NULL); } -#line 2236 "parser.tab.c" /* yacc.c:1646 */ +#line 2263 "parser.tab.c" break; case 54: -#line 399 "parser.y" /* yacc.c:1646 */ +#line 399 "parser.y" { (yyval.statement) = new_while_statement(ctx, TRUE, (yyvsp[-2].expr), (yyvsp[-5].statement)); } -#line 2242 "parser.tab.c" /* yacc.c:1646 */ +#line 2269 "parser.tab.c" break; case 55: -#line 401 "parser.y" /* yacc.c:1646 */ +#line 401 "parser.y" { (yyval.statement) = new_while_statement(ctx, FALSE, (yyvsp[-2].expr), (yyvsp[0].statement)); } -#line 2248 "parser.tab.c" /* yacc.c:1646 */ +#line 2275 "parser.tab.c" break; case 56: -#line 403 "parser.y" /* yacc.c:1646 */ +#line 403 "parser.y" { if(!explicit_error(ctx, (yyvsp[0].expr), ';')) YYABORT; } -#line 2254 "parser.tab.c" /* yacc.c:1646 */ +#line 2281 "parser.tab.c" break; case 57: -#line 405 "parser.y" /* yacc.c:1646 */ +#line 405 "parser.y" { if(!explicit_error(ctx, (yyvsp[0].expr), ';')) YYABORT; } -#line 2260 "parser.tab.c" /* yacc.c:1646 */ +#line 2287 "parser.tab.c" break; case 58: -#line 407 "parser.y" /* yacc.c:1646 */ +#line 407 "parser.y" { (yyval.statement) = new_for_statement(ctx, NULL, (yyvsp[-8].expr), (yyvsp[-5].expr), (yyvsp[-2].expr), (yyvsp[0].statement)); } -#line 2266 "parser.tab.c" /* yacc.c:1646 */ +#line 2293 "parser.tab.c" break; case 59: -#line 409 "parser.y" /* yacc.c:1646 */ +#line 409 "parser.y" { if(!explicit_error(ctx, (yyvsp[0].variable_list), ';')) YYABORT; } -#line 2272 "parser.tab.c" /* yacc.c:1646 */ +#line 2299 "parser.tab.c" break; case 60: -#line 411 "parser.y" /* yacc.c:1646 */ +#line 411 "parser.y" { if(!explicit_error(ctx, (yyvsp[0].expr), ';')) YYABORT; } -#line 2278 "parser.tab.c" /* yacc.c:1646 */ +#line 2305 "parser.tab.c" break; case 61: -#line 413 "parser.y" /* yacc.c:1646 */ +#line 413 "parser.y" { (yyval.statement) = new_for_statement(ctx, (yyvsp[-8].variable_list), NULL, (yyvsp[-5].expr), (yyvsp[-2].expr), (yyvsp[0].statement)); } -#line 2284 "parser.tab.c" /* yacc.c:1646 */ +#line 2311 "parser.tab.c" break; case 62: -#line 415 "parser.y" /* yacc.c:1646 */ +#line 415 "parser.y" { (yyval.statement) = new_forin_statement(ctx, NULL, (yyvsp[-4].expr), (yyvsp[-2].expr), (yyvsp[0].statement)); } -#line 2290 "parser.tab.c" /* yacc.c:1646 */ +#line 2317 "parser.tab.c" break; case 63: -#line 417 "parser.y" /* yacc.c:1646 */ +#line 417 "parser.y" { (yyval.statement) = new_forin_statement(ctx, (yyvsp[-4].variable_declaration), NULL, (yyvsp[-2].expr), (yyvsp[0].statement)); } -#line 2296 "parser.tab.c" /* yacc.c:1646 */ +#line 2323 "parser.tab.c" ... 2116 lines suppressed ...
5 years, 1 month
1
0
0
0
[reactos] 01/01: [ITSS] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=da0cd273dedd1feb2dd8e…
commit da0cd273dedd1feb2dd8e87bf54d42d284ecd9c9 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:37:34 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:37:34 2019 +0100 [ITSS] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/itss/chm_lib.c | 25 +++++++++++-------------- dll/win32/itss/itss.c | 2 -- dll/win32/itss/lzx.c | 17 ++++------------- dll/win32/itss/moniker.c | 16 +++++++--------- dll/win32/itss/precomp.h | 4 ---- dll/win32/itss/protocol.c | 29 ++++++++++++++--------------- dll/win32/itss/storage.c | 26 ++++++++++++-------------- media/doc/README.WINE | 2 +- 8 files changed, 49 insertions(+), 72 deletions(-) diff --git a/dll/win32/itss/chm_lib.c b/dll/win32/itss/chm_lib.c index 829f758516a..f55017675ea 100644 --- a/dll/win32/itss/chm_lib.c +++ b/dll/win32/itss/chm_lib.c @@ -54,8 +54,6 @@ * * ***************************************************************************/ -#include "config.h" -#include "wine/port.h" #include <stdarg.h> #include <stdio.h> @@ -64,7 +62,7 @@ #include "windef.h" #include "winbase.h" -#include "wine/unicode.h" +#include "winnls.h" #include "chm_lib.h" #include "lzx.h" @@ -995,7 +993,7 @@ static UChar *_chm_find_in_PMGL(UChar *page_buf, return NULL; /* check if it is the right name */ - if (! strcmpiW(buffer, objPath)) + if (! wcsicmp(buffer, objPath)) return temp; _chm_skip_PMGL_entry_data(&cur); @@ -1036,7 +1034,7 @@ static Int32 _chm_find_in_PMGI(UChar *page_buf, return -1; /* check if it is the right name */ - if (strcmpiW(buffer, objPath) > 0) + if (wcsicmp(buffer, objPath) > 0) return page; /* load next value for path */ @@ -1327,9 +1325,8 @@ static Int64 _chm_decompress_region(struct chmFile *h, /* data request not satisfied, so... start up the decompressor machine */ if (! h->lzx_state) { - int window_size = ffs(h->window_size) - 1; h->lzx_last_block = -1; - h->lzx_state = LZXinit(window_size); + h->lzx_state = LZXinit(h->window_size); } /* decompress some data */ @@ -1438,7 +1435,7 @@ BOOL chm_enumerate_dir(struct chmFile *h, /* initialize pathname state */ lstrcpynW(prefixRectified, prefix, CHM_MAX_PATHLEN); - prefixLen = strlenW(prefixRectified); + prefixLen = lstrlenW(prefixRectified); if (prefixLen != 0) { if (prefixRectified[prefixLen-1] != '/') @@ -1487,7 +1484,7 @@ BOOL chm_enumerate_dir(struct chmFile *h, /* check if we should start */ if (! it_has_begun) { - if (ui.length == 0 && strncmpiW(ui.path, prefixRectified, prefixLen) == 0) + if (ui.length == 0 && _wcsnicmp(ui.path, prefixRectified, prefixLen) == 0) it_has_begun = TRUE; else continue; @@ -1499,7 +1496,7 @@ BOOL chm_enumerate_dir(struct chmFile *h, /* check if we should stop */ else { - if (strncmpiW(ui.path, prefixRectified, prefixLen) != 0) + if (_wcsnicmp(ui.path, prefixRectified, prefixLen) != 0) { HeapFree(GetProcessHeap(), 0, page_buf); return TRUE; @@ -1509,14 +1506,14 @@ BOOL chm_enumerate_dir(struct chmFile *h, /* check if we should include this path */ if (lastPathLen != -1) { - if (strncmpiW(ui.path, lastPath, lastPathLen) == 0) + if (_wcsnicmp(ui.path, lastPath, lastPathLen) == 0) continue; } - strcpyW(lastPath, ui.path); - lastPathLen = strlenW(lastPath); + lstrcpyW(lastPath, ui.path); + lastPathLen = lstrlenW(lastPath); /* get the length of the path */ - ui_path_len = strlenW(ui.path)-1; + ui_path_len = lstrlenW(ui.path)-1; /* check for DIRS */ if (ui.path[ui_path_len] == '/' && !(what & CHM_ENUMERATE_DIRS)) diff --git a/dll/win32/itss/itss.c b/dll/win32/itss/itss.c index 1d236a59604..e284400cf11 100644 --- a/dll/win32/itss/itss.c +++ b/dll/win32/itss/itss.c @@ -21,7 +21,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" #include <stdarg.h> #include <stdio.h> @@ -36,7 +35,6 @@ #include "rpcproxy.h" #include "advpub.h" -#include "wine/unicode.h" #include "wine/debug.h" #include "itsstor.h" diff --git a/dll/win32/itss/lzx.c b/dll/win32/itss/lzx.c index 01a94924115..e14de3a92c2 100644 --- a/dll/win32/itss/lzx.c +++ b/dll/win32/itss/lzx.c @@ -169,16 +169,11 @@ static const ULONG position_base[51] = { 1835008, 1966080, 2097152 }; -struct LZXstate *LZXinit(int window) +struct LZXstate *LZXinit(int wndsize) { struct LZXstate *pState=NULL; - ULONG wndsize = 1 << window; int i, posn_slots; - /* LZX supports window sizes of 2^15 (32Kb) through 2^21 (2Mb) */ - /* if a previously allocated window is big enough, keep it */ - if (window < 15 || window > 21) return NULL; - /* allocate state and associated window */ pState = HeapAlloc(GetProcessHeap(), 0, sizeof(struct LZXstate)); if (!(pState->window = HeapAlloc(GetProcessHeap(), 0, wndsize))) @@ -190,12 +185,8 @@ struct LZXstate *LZXinit(int window) pState->window_size = wndsize; /* calculate required position slots */ - if (window == 20) posn_slots = 42; - else if (window == 21) posn_slots = 50; - else posn_slots = window << 1; - - /** alternatively **/ - /* posn_slots=i=0; while (i < wndsize) i += 1 << extra_bits[posn_slots++]; */ + posn_slots = i = 0; + while (i < wndsize) i += 1 << extra_bits[posn_slots++]; /* initialize other state */ pState->R0 = pState->R1 = pState->R2 = 1; @@ -797,7 +788,7 @@ int main(int c, char **v) int i; int count=0; int w = atoi(v[1]); - LZXinit(&state, w); + LZXinit(&state, 1 << w); fout = fopen(v[2], "wb"); for (i=3; i<c; i++) { diff --git a/dll/win32/itss/moniker.c b/dll/win32/itss/moniker.c index 6c61f47482b..e74b6e3d772 100644 --- a/dll/win32/itss/moniker.c +++ b/dll/win32/itss/moniker.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" #include <stdarg.h> #include <stdio.h> @@ -33,7 +32,6 @@ #include "ole2.h" #include "wine/itss.h" -#include "wine/unicode.h" #include "wine/debug.h" #include "itsstor.h" @@ -292,9 +290,9 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName( TRACE("%p %p %p %p\n", iface, pbc, pmkToLeft, ppszDisplayName); - len = strlenW( This->szFile ) + strlenW( This->szHtml ); + len = lstrlenW( This->szFile ) + lstrlenW( This->szHtml ); str = CoTaskMemAlloc( len*sizeof(WCHAR) ); - sprintfW( str, szFormat, This->szFile, This->szHtml ); + swprintf( str, szFormat, This->szFile, This->szHtml ); *ppszDisplayName = str; @@ -354,12 +352,12 @@ static HRESULT ITS_IMoniker_create( IMoniker **ppObj, LPCWSTR name, DWORD n ) DWORD sz; /* szFile[1] has space for one character already */ - sz = FIELD_OFFSET( ITS_IMonikerImpl, szFile[strlenW( name ) + 1] ); + sz = FIELD_OFFSET( ITS_IMonikerImpl, szFile[lstrlenW( name ) + 1] ); itsmon = HeapAlloc( GetProcessHeap(), 0, sz ); itsmon->IMoniker_iface.lpVtbl = &ITS_IMonikerImpl_Vtbl; itsmon->ref = 1; - strcpyW( itsmon->szFile, name ); + lstrcpyW( itsmon->szFile, name ); itsmon->szHtml = &itsmon->szFile[n]; while( *itsmon->szHtml == ':' ) @@ -443,11 +441,11 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName( TRACE("%p %s %p %p\n", This, debugstr_w( pszDisplayName ), pchEaten, ppmkOut ); - if( strncmpiW( pszDisplayName, szPrefix, prefix_len ) ) + if( _wcsnicmp( pszDisplayName, szPrefix, prefix_len ) ) return MK_E_SYNTAX; /* search backwards for a double colon */ - for( n = strlenW( pszDisplayName ) - 3; prefix_len <= n; n-- ) + for( n = lstrlenW( pszDisplayName ) - 3; prefix_len <= n; n-- ) if( ( pszDisplayName[n] == ':' ) && ( pszDisplayName[n+1] == ':' ) ) break; @@ -457,7 +455,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName( if( !pszDisplayName[n+2] ) return MK_E_SYNTAX; - *pchEaten = strlenW( pszDisplayName ) - n - 3; + *pchEaten = lstrlenW( pszDisplayName ) - n - 3; return ITS_IMoniker_create( ppmkOut, &pszDisplayName[prefix_len], n-prefix_len ); diff --git a/dll/win32/itss/precomp.h b/dll/win32/itss/precomp.h index 5f9be9183b0..e7e65986e23 100644 --- a/dll/win32/itss/precomp.h +++ b/dll/win32/itss/precomp.h @@ -2,9 +2,6 @@ #ifndef _ITSS_PCH_ #define _ITSS_PCH_ -#include <wine/config.h> -#include <wine/port.h> - #include <stdarg.h> #define WIN32_NO_STATUS @@ -18,7 +15,6 @@ #include <objbase.h> #include <wine/itss.h> -#include <wine/unicode.h> #include <wine/debug.h> #include "chm_lib.h" diff --git a/dll/win32/itss/protocol.c b/dll/win32/itss/protocol.c index a7c40077cce..1f6362661b8 100644 --- a/dll/win32/itss/protocol.c +++ b/dll/win32/itss/protocol.c @@ -31,7 +31,6 @@ #include "chm_lib.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(itss); @@ -153,11 +152,11 @@ static LPCWSTR skip_schema(LPCWSTR url) static const WCHAR msits_schema[] = {'m','s','-','i','t','s',':'}; static const WCHAR mk_schema[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':'}; - if(!strncmpiW(its_schema, url, ARRAY_SIZE(its_schema))) + if(!_wcsnicmp(its_schema, url, ARRAY_SIZE(its_schema))) return url + ARRAY_SIZE(its_schema); - if(!strncmpiW(msits_schema, url, ARRAY_SIZE(msits_schema))) + if(!_wcsnicmp(msits_schema, url, ARRAY_SIZE(msits_schema))) return url + ARRAY_SIZE(msits_schema); - if(!strncmpiW(mk_schema, url, ARRAY_SIZE(mk_schema))) + if(!_wcsnicmp(mk_schema, url, ARRAY_SIZE(mk_schema))) return url + ARRAY_SIZE(mk_schema); return NULL; @@ -251,7 +250,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, ReleaseBindInfo(&bindinfo); - len = strlenW(ptr)+3; + len = lstrlenW(ptr)+3; file_name = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR)); memcpy(file_name, ptr, len*sizeof(WCHAR)); hres = UrlUnescapeW(file_name, NULL, &len, URL_UNESCAPE_INPLACE); @@ -261,7 +260,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, return hres; } - p = strstrW(file_name, separator); + p = wcsstr(file_name, separator); if(!p) { WARN("invalid url\n"); HeapFree(GetProcessHeap(), 0, file_name); @@ -277,7 +276,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, } object_name = p+2; - len = strlenW(object_name); + len = lstrlenW(object_name); if(*object_name != '/' && *object_name != '\\') { memmove(object_name+1, object_name, (len+1)*sizeof(WCHAR)); @@ -307,7 +306,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl, } IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, - strrchrW(object_name, '/')+1); + wcsrchr(object_name, '/')+1); /* FIXME: Native doesn't use FindMimeFromData */ hres = FindMimeFromData(NULL, object_name, NULL, 0, NULL, 0, &mime, 0); @@ -487,7 +486,7 @@ static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult, pcchResult, dwReserved); - base_end = strstrW(pwzBaseUrl, separator); + base_end = wcsstr(pwzBaseUrl, separator); if(!base_end) return 0x80041001; base_end += 2; @@ -495,20 +494,20 @@ static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, if(!skip_schema(pwzBaseUrl)) return INET_E_USE_DEFAULT_PROTOCOLHANDLER; - if(strchrW(pwzRelativeUrl, ':')) + if(wcschr(pwzRelativeUrl, ':')) return STG_E_INVALIDNAME; if(pwzRelativeUrl[0] == '#') { - base_end += strlenW(base_end); + base_end += lstrlenW(base_end); }else if(pwzRelativeUrl[0] != '/') { - ptr = strrchrW(base_end, '/'); + ptr = wcsrchr(base_end, '/'); if(ptr) base_end = ptr+1; else - base_end += strlenW(base_end); + base_end += lstrlenW(base_end); } - rel_len = strlenW(pwzRelativeUrl)+1; + rel_len = lstrlenW(pwzRelativeUrl)+1; *pcchResult = rel_len + (base_end-pwzBaseUrl); @@ -516,7 +515,7 @@ static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface, return E_OUTOFMEMORY; memcpy(pwzResult, pwzBaseUrl, (base_end-pwzBaseUrl)*sizeof(WCHAR)); - strcpyW(pwzResult + (base_end-pwzBaseUrl), pwzRelativeUrl); + lstrcpyW(pwzResult + (base_end-pwzBaseUrl), pwzRelativeUrl); return S_OK; } diff --git a/dll/win32/itss/storage.c b/dll/win32/itss/storage.c index f20c5bc0bed..86d33f29dfb 100644 --- a/dll/win32/itss/storage.c +++ b/dll/win32/itss/storage.c @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" #include <stdarg.h> #include <stdio.h> @@ -36,7 +35,6 @@ #include "itsstor.h" #include "wine/itss.h" -#include "wine/unicode.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(itss); @@ -167,9 +165,9 @@ static HRESULT WINAPI ITSS_IEnumSTATSTG_Next( str = cur->ui.path; if( *str == '/' ) str++; - len = strlenW( str ) + 1; + len = lstrlenW( str ) + 1; rgelt->pwcsName = CoTaskMemAlloc( len*sizeof(WCHAR) ); - strcpyW( rgelt->pwcsName, str ); + lstrcpyW( rgelt->pwcsName, str ); /* determine the type */ if( rgelt->pwcsName[len-2] == '/' ) @@ -345,17 +343,17 @@ static HRESULT WINAPI ITSS_IStorageImpl_OpenStream( TRACE("%p %s %p %u %u %p\n", This, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm ); - len = strlenW( This->dir ) + strlenW( pwcsName ) + 1; + len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 1; path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - strcpyW( path, This->dir ); + lstrcpyW( path, This->dir ); if( pwcsName[0] == '/' || pwcsName[0] == '\\' ) { - p = &path[strlenW( path ) - 1]; + p = &path[lstrlenW( path ) - 1]; while( ( path <= p ) && ( *p == '/' ) ) *p-- = 0; } - strcatW( path, pwcsName ); + lstrcatW( path, pwcsName ); for(p=path; *p; p++) { if(*p == '\\') @@ -417,17 +415,17 @@ static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage( if( !chmfile ) return E_FAIL; - len = strlenW( This->dir ) + strlenW( pwcsName ) + 2; /* need room for a terminating slash */ + len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 2; /* need room for a terminating slash */ path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); - strcpyW( path, This->dir ); + lstrcpyW( path, This->dir ); if( pwcsName[0] == '/' || pwcsName[0] == '\\' ) { - p = &path[strlenW( path ) - 1]; + p = &path[lstrlenW( path ) - 1]; while( ( path <= p ) && ( *p == '/' ) ) *p-- = 0; } - strcatW( path, pwcsName ); + lstrcatW( path, pwcsName ); for(p=path; *p; p++) { if(*p == '\\') @@ -620,11 +618,11 @@ static HRESULT ITSS_create_chm_storage( TRACE("%p %s\n", chmfile, debugstr_w( dir ) ); stg = HeapAlloc( GetProcessHeap(), 0, - FIELD_OFFSET( ITSS_IStorageImpl, dir[strlenW( dir ) + 1] )); + FIELD_OFFSET( ITSS_IStorageImpl, dir[lstrlenW( dir ) + 1] )); stg->IStorage_iface.lpVtbl = &ITSS_IStorageImpl_Vtbl; stg->ref = 1; stg->chmfile = chmfile; - strcpyW( stg->dir, dir ); + lstrcpyW( stg->dir, dir ); *ppstgOpen = &stg->IStorage_iface; diff --git a/media/doc/README.WINE b/media/doc/README.WINE index fdb4205f77e..7404dc33c41 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -85,7 +85,7 @@ dll/win32/initpki # Synced to WineStaging-4.18 dll/win32/inseng # Synced to WineStaging-4.18 dll/win32/iphlpapi # Out of sync dll/win32/itircl # Synced to WineStaging-4.18 -dll/win32/itss # Synced to WineStaging-3.17 +dll/win32/itss # Synced to WineStaging-4.18 dll/win32/jscript # Synced to WineStaging-4.0 dll/win32/jsproxy # Synced to WineStaging-4.0 dll/win32/loadperf # Synced to WineStaging-3.3
5 years, 1 month
1
0
0
0
[reactos] 01/01: [ITIRCL] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=eac6ed63323ecfedb7517…
commit eac6ed63323ecfedb7517ba492773a74697f4876 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:36:57 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:36:57 2019 +0100 [ITIRCL] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/itircl/itircl_main.c | 1 - media/doc/README.WINE | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/dll/win32/itircl/itircl_main.c b/dll/win32/itircl/itircl_main.c index 4fb05c0a194..e35bbba3359 100644 --- a/dll/win32/itircl/itircl_main.c +++ b/dll/win32/itircl/itircl_main.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "config.h" #include <stdarg.h> diff --git a/media/doc/README.WINE b/media/doc/README.WINE index f0c31646024..fdb4205f77e 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -84,7 +84,7 @@ dll/win32/inetmib1 # Synced to WineStaging-4.18 dll/win32/initpki # Synced to WineStaging-4.18 dll/win32/inseng # Synced to WineStaging-4.18 dll/win32/iphlpapi # Out of sync -dll/win32/itircl # Synced to WineStaging-3.3 +dll/win32/itircl # Synced to WineStaging-4.18 dll/win32/itss # Synced to WineStaging-3.17 dll/win32/jscript # Synced to WineStaging-4.0 dll/win32/jsproxy # Synced to WineStaging-4.0
5 years, 1 month
1
0
0
0
[reactos] 01/01: [INSENG] Sync with Wine Staging 4.18. CORE-16441
by Amine Khaldi
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bf833d29a7a1de84e13ef…
commit bf833d29a7a1de84e13ef395e3f5912ec7f7af75 Author: Amine Khaldi <amine.khaldi(a)reactos.org> AuthorDate: Sat Nov 2 18:36:31 2019 +0100 Commit: Amine Khaldi <amine.khaldi(a)reactos.org> CommitDate: Sat Nov 2 18:36:31 2019 +0100 [INSENG] Sync with Wine Staging 4.18. CORE-16441 --- dll/win32/inseng/icif.c | 2 +- dll/win32/inseng/inseng_main.c | 1 - dll/win32/inseng/inseng_private.h | 9 ++++++--- dll/win32/inseng/precomp.h | 2 -- media/doc/README.WINE | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dll/win32/inseng/icif.c b/dll/win32/inseng/icif.c index f7bf0a07077..6fd35625006 100644 --- a/dll/win32/inseng/icif.c +++ b/dll/win32/inseng/icif.c @@ -18,7 +18,7 @@ #define COBJMACROS -#include "config.h" + #include <stdarg.h> #include <string.h> diff --git a/dll/win32/inseng/inseng_main.c b/dll/win32/inseng/inseng_main.c index 8e2c4814931..213b27ee7b8 100644 --- a/dll/win32/inseng/inseng_main.c +++ b/dll/win32/inseng/inseng_main.c @@ -21,7 +21,6 @@ #define COBJMACROS -#include "config.h" #include <stdarg.h> diff --git a/dll/win32/inseng/inseng_private.h b/dll/win32/inseng/inseng_private.h index 60b6db953cd..ea99c233131 100644 --- a/dll/win32/inseng/inseng_private.h +++ b/dll/win32/inseng/inseng_private.h @@ -21,11 +21,14 @@ #include "windef.h" #include "winbase.h" #include "winuser.h" +#ifdef __REACTOS__ +#include "winnls.h" +#endif #include "ole2.h" #include "rpcproxy.h" #include "inseng.h" #include "wine/heap.h" -#include "wine/unicode.h" + static inline char *strdupA(const char *src) { @@ -38,8 +41,8 @@ static inline WCHAR *strdupW(const WCHAR *src) { WCHAR *dest; if (!src) return NULL; - dest = HeapAlloc(GetProcessHeap(), 0, (strlenW(src) + 1) * sizeof(WCHAR)); - if (dest) strcpyW(dest, src); + dest = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR)); + if (dest) lstrcpyW(dest, src); return dest; } diff --git a/dll/win32/inseng/precomp.h b/dll/win32/inseng/precomp.h index 18e231259c5..0a8943f27de 100644 --- a/dll/win32/inseng/precomp.h +++ b/dll/win32/inseng/precomp.h @@ -2,8 +2,6 @@ #ifndef _INSENG_PRECOMP_H #define _INSENG_PRECOMP_H -#include <wine/config.h> - #define WIN32_NO_STATUS #define _INC_WINDOWS #define COM_NO_WINDOWS_H diff --git a/media/doc/README.WINE b/media/doc/README.WINE index cbeb18fd511..f0c31646024 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -82,7 +82,7 @@ dll/win32/imm32 # Synced to WineStaging-4.18 dll/win32/inetcomm # Synced to WineStaging-4.18 dll/win32/inetmib1 # Synced to WineStaging-4.18 dll/win32/initpki # Synced to WineStaging-4.18 -dll/win32/inseng # Synced to WineStaging-3.3 +dll/win32/inseng # Synced to WineStaging-4.18 dll/win32/iphlpapi # Out of sync dll/win32/itircl # Synced to WineStaging-3.3 dll/win32/itss # Synced to WineStaging-3.17
5 years, 1 month
1
0
0
0
← Newer
1
...
27
28
29
30
31
32
33
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Results per page:
10
25
50
100
200