Skip to content

Commit 6688079

Browse files
author
Jianchun Xu
committed
linux: builds more lib/Parser files
Make 5 more lib/Parser files build. - Added bunch of needed win error codes. - Applied a work around StaticSymLen<N> for StaticSym (flexible array initialization not allowed). - #ifdef out few resource loading code under ENABLE_GLOBALIZATION. - Deleted unused code.
1 parent ca74226 commit 6688079

11 files changed

Lines changed: 76 additions & 63 deletions

File tree

lib/Common/CommonPal.h

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,49 @@ inline int get_cpuid(int cpuInfo[4], int function_id)
8989
#undef sprintf_s
9090

9191
// PAL LoadLibraryExW not supported
92-
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0
93-
#define FACILITY_JSCRIPT 2306
92+
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0
93+
// winerror.h
94+
#define FACILITY_JSCRIPT 2306
95+
#define JSCRIPT_E_CANTEXECUTE _HRESULT_TYPEDEF_(0x89020001L)
96+
#define DISP_E_UNKNOWNINTERFACE _HRESULT_TYPEDEF_(0x80020001L)
97+
#define DISP_E_MEMBERNOTFOUND _HRESULT_TYPEDEF_(0x80020003L)
98+
#define DISP_E_UNKNOWNNAME _HRESULT_TYPEDEF_(0x80020006L)
99+
#define DISP_E_NONAMEDARGS _HRESULT_TYPEDEF_(0x80020007L)
100+
#define DISP_E_EXCEPTION _HRESULT_TYPEDEF_(0x80020009L)
101+
#define DISP_E_BADINDEX _HRESULT_TYPEDEF_(0x8002000BL)
102+
#define DISP_E_UNKNOWNLCID _HRESULT_TYPEDEF_(0x8002000CL)
103+
#define DISP_E_ARRAYISLOCKED _HRESULT_TYPEDEF_(0x8002000DL)
104+
#define DISP_E_BADPARAMCOUNT _HRESULT_TYPEDEF_(0x8002000EL)
105+
#define DISP_E_PARAMNOTOPTIONAL _HRESULT_TYPEDEF_(0x8002000FL)
106+
#define DISP_E_NOTACOLLECTION _HRESULT_TYPEDEF_(0x80020011L)
107+
#define TYPE_E_DLLFUNCTIONNOTFOUND _HRESULT_TYPEDEF_(0x8002802FL)
108+
#define TYPE_E_TYPEMISMATCH _HRESULT_TYPEDEF_(0x80028CA0L)
109+
#define TYPE_E_OUTOFBOUNDS _HRESULT_TYPEDEF_(0x80028CA1L)
110+
#define TYPE_E_IOERROR _HRESULT_TYPEDEF_(0x80028CA2L)
111+
#define TYPE_E_CANTCREATETMPFILE _HRESULT_TYPEDEF_(0x80028CA3L)
112+
#define TYPE_E_CANTLOADLIBRARY _HRESULT_TYPEDEF_(0x80029C4AL)
113+
#define STG_E_TOOMANYOPENFILES _HRESULT_TYPEDEF_(0x80030004L)
114+
#define STG_E_ACCESSDENIED _HRESULT_TYPEDEF_(0x80030005L)
115+
#define STG_E_INSUFFICIENTMEMORY _HRESULT_TYPEDEF_(0x80030008L)
116+
#define STG_E_NOMOREFILES _HRESULT_TYPEDEF_(0x80030012L)
117+
#define STG_E_DISKISWRITEPROTECTED _HRESULT_TYPEDEF_(0x80030013L)
118+
#define STG_E_READFAULT _HRESULT_TYPEDEF_(0x8003001EL)
119+
#define STG_E_SHAREVIOLATION _HRESULT_TYPEDEF_(0x80030020L)
120+
#define STG_E_LOCKVIOLATION _HRESULT_TYPEDEF_(0x80030021L)
121+
#define STG_E_MEDIUMFULL _HRESULT_TYPEDEF_(0x80030070L)
122+
#define STG_E_INVALIDNAME _HRESULT_TYPEDEF_(0x800300FCL)
123+
#define STG_E_INUSE _HRESULT_TYPEDEF_(0x80030100L)
124+
#define STG_E_NOTCURRENT _HRESULT_TYPEDEF_(0x80030101L)
125+
#define STG_E_CANTSAVE _HRESULT_TYPEDEF_(0x80030103L)
126+
#define REGDB_E_CLASSNOTREG _HRESULT_TYPEDEF_(0x80040154L)
127+
#define MK_E_UNAVAILABLE _HRESULT_TYPEDEF_(0x800401E3L)
128+
#define MK_E_INVALIDEXTENSION _HRESULT_TYPEDEF_(0x800401E6L)
129+
#define MK_E_CANTOPENFILE _HRESULT_TYPEDEF_(0x800401EAL)
130+
#define CO_E_APPNOTFOUND _HRESULT_TYPEDEF_(0x800401F5L)
131+
#define CO_E_APPDIDNTREG _HRESULT_TYPEDEF_(0x800401FEL)
132+
#define GetScode(hr) ((SCODE) (hr))
133+
// activscp.h
134+
#define SCRIPT_E_RECORDED 0x86664004L
94135

95136
// _countof
96137
#if defined _M_X64 || defined _M_ARM || defined _M_ARM64

lib/Parser/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ add_library (Chakra.Parser
66
# CharSet.cpp
77
CharTrie.cpp
88
DebugWriter.cpp
9-
# Hash.cpp
9+
Hash.cpp
1010
OctoquadIdentifier.cpp
1111
# Parse.cpp
1212
ParserPch.cpp
@@ -19,11 +19,11 @@ add_library (Chakra.Parser
1919
# StandardChars.cpp
2020
# TextbookBoyerMoore.cpp
2121
cmperr.cpp
22-
# errstr.cpp
23-
# globals.cpp
22+
errstr.cpp
23+
globals.cpp
2424
jserr.gen
25-
# rterror.cpp
26-
# screrror.cpp
25+
rterror.cpp
26+
screrror.cpp
2727
)
2828

2929
target_include_directories (

lib/Parser/Hash.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const HashTbl::ReservedWordInfo HashTbl::s_reservedWordInfo[tkID] =
2222
{
2323
{ nullptr, fidNil },
2424
#define KEYWORD(tk,f,prec2,nop2,prec1,nop1,name) \
25-
{ &g_ssym_##name, f },
25+
{ reinterpret_cast<const StaticSym*>(&g_ssym_##name), f },
2626
#include "keywords.h"
2727
};
2828

@@ -237,7 +237,7 @@ IdentPtr HashTbl::PidHashNameLenWithHash(_In_reads_(cch) CharType const * prgch,
237237

238238
IdentPtr * ppid;
239239
IdentPtr pid;
240-
long cb;
240+
LONG cb;
241241
long bucketCount;
242242

243243

lib/Parser/Hash.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@
44
//-------------------------------------------------------------------------------------------------------
55
#pragma once
66

7-
struct StaticSym;
7+
// StaticSym contains a string literal at the end (flexible array) and is
8+
// meant to be initialized statically. However, flexible array initialization
9+
// is not allowed in standard C++. We declare each StaticSym with length
10+
// instead and cast to common StaticSymLen<0>* (StaticSym*) to access.
11+
template <ulong N>
12+
struct StaticSymLen
13+
{
14+
ulong luHash;
15+
ulong cch;
16+
OLECHAR sz[N];
17+
};
18+
19+
typedef StaticSymLen<0> StaticSym;
820

921
/***************************************************************************
1022
Hashing functions. Definitions in core\hashfunc.cpp.

lib/Parser/HashFunc.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
* of the hash function so things don't go out of sync.
1717
*/
1818

19-
// scaffolding - define ULONG
20-
typedef unsigned long ULONG;
21-
2219
ULONG CaseSensitiveComputeHashCch(LPCOLESTR prgch, long cch)
2320
{
2421
ULONG luHash = 0;

lib/Parser/errstr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ static BOOL FGetStringFromLibrary(HMODULE hlib, int istring, __out_ecount(cchMax
2929
istring &= 0x0F;
3030
BOOL fRet = FALSE;
3131

32+
#ifdef ENABLE_GLOBALIZATION
3233
psz[0] = '\0';
3334

3435
if (NULL == hlib)
@@ -106,7 +107,7 @@ static BOOL FGetStringFromLibrary(HMODULE hlib, int istring, __out_ecount(cchMax
106107
}
107108

108109
#endif
109-
110+
#endif // ENABLE_GLOBALIZATION
110111
return fRet;
111112
}
112113

lib/Parser/globals.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@
66

77
// strings for builtin names
88
#define HASH_NAME(name, hashCS, hashCI) \
9-
const StaticSym g_ssym_##name = \
9+
const StaticSymLen<sizeof(#name)> g_ssym_##name = \
1010
{ \
1111
hashCS, \
1212
sizeof(#name) - 1, \
13-
OLESTR(#name) \
14-
};
13+
CH_WSTR(#name) \
14+
}; \
15+
C_ASSERT(offsetof(StaticSymLen<sizeof(#name)>, luHash) == offsetof(StaticSym, luHash)); \
16+
C_ASSERT(offsetof(StaticSymLen<sizeof(#name)>, cch) == offsetof(StaticSym, cch)); \
17+
C_ASSERT(offsetof(StaticSymLen<sizeof(#name)>, sz) == offsetof(StaticSym, sz)); \
18+
1519
#include "objnames.h"
1620
#undef HASH_NAME
17-
18-

lib/Parser/globals.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,9 @@
44
//-------------------------------------------------------------------------------------------------------
55
#pragma once
66

7-
struct StaticSym
8-
{
9-
ulong luHash;
10-
ulong cch;
11-
OLECHAR sz[];
12-
};
13-
147
// Builtin symbols.
15-
#define HASH_NAME(name, hashCS, hashCI) extern const StaticSym g_ssym_##name;
8+
#define HASH_NAME(name, hashCS, hashCI) \
9+
extern const StaticSymLen<sizeof(#name)> g_ssym_##name;
1610
#include "objnames.h"
1711
#undef HASH_NAME
1812

lib/Parser/rterror.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ C_ASSERT(JSERR_CantExecute == 0x800A1393);
1515
// verify HR matches between public SDK and private (.h) files
1616
C_ASSERT(JSCRIPT_E_CANTEXECUTE == JSPUBLICERR_CantExecute);
1717
// verify the HR value (as MAKE_HRESULT(SEVERITY_ERROR, FACILITY_JSCRIPT, 0x0001))
18-
C_ASSERT(JSPUBLICERR_CantExecute == 0x89020001L);
18+
C_ASSERT(JSPUBLICERR_CantExecute == _HRESULT_TYPEDEF_(0x89020001L));
1919

2020
// /PUBLIC ERROR codes
2121

lib/Parser/screrror.cpp

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,6 @@ void CopyException (EXCEPINFO *peiDest, const EXCEPINFO *peiSource)
2424
}
2525
}
2626

27-
/***
28-
*BOOL FSupportsErrorInfo
29-
*Purpose:
30-
* Answers if the given object supports the Rich Error mechanism
31-
* on the given interface.
32-
*
33-
*Entry:
34-
* punk = the object
35-
* riid = the IID of the interface on the object
36-
*
37-
*Exit:
38-
* return value = BOOL
39-
*
40-
***********************************************************************/
41-
BOOL FSupportsErrorInfo(IUnknown *punk, REFIID riid)
42-
{
43-
BOOL fSupports;
44-
ISupportErrorInfo *psupport;
45-
46-
fSupports = FALSE;
47-
if(SUCCEEDED(punk->QueryInterface(__uuidof(ISupportErrorInfo), (void **)&psupport)))
48-
{
49-
if(NOERROR == psupport->InterfaceSupportsErrorInfo(riid))
50-
fSupports = TRUE;
51-
psupport->Release();
52-
}
53-
return fSupports;
54-
}
55-
5627
/***
5728
*PUBLIC HRESULT GetErrorInfo
5829
*Purpose:
@@ -125,12 +96,8 @@ struct MHR
12596
const MHR g_rgmhr[] =
12697
{
12798
// FACILITY_NULL errors
128-
#if _WIN32 || _WIN64
12999
/*0x80004001*/ MAPHR(E_NOTIMPL, VBSERR_ActionNotSupported),
130100
/*0x80004002*/ MAPHR(E_NOINTERFACE, VBSERR_OLENotSupported),
131-
#else
132-
#error Neither __WIN32, nor _WIN64 is defined
133-
#endif
134101

135102
// FACILITY_DISPATCH - IDispatch errors.
136103
/*0x80020001*/ MAPHR(DISP_E_UNKNOWNINTERFACE, VBSERR_OLENoPropOrMethod),
@@ -332,7 +299,7 @@ HRESULT CompileScriptException::ProcessError(IScanner * pScan, HRESULT hr, Pars
332299
BstrGetResourceString(HRESULT_CODE(ei.scode))))
333300
{
334301
OLECHAR szT[50];
335-
_snwprintf_s(szT, ARRAYSIZE(szT), ARRAYSIZE(szT)-1, OLESTR("error %d"), ei.scode);
302+
_snwprintf_s(szT, ARRAYSIZE(szT), ARRAYSIZE(szT)-1, CH_WSTR("error %d"), ei.scode);
336303
if (nullptr == (ei.bstrDescription = SysAllocString(szT)))
337304
ei.scode = E_OUTOFMEMORY;
338305
}

0 commit comments

Comments
 (0)