Skip to content

Commit 06bd8ce

Browse files
committed
Implement Intl.Locale
1 parent 962624d commit 06bd8ce

10 files changed

+812
-26
lines changed

lib/Parser/rterrors.h

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ RT_ERROR_MSG(JSERR_MissingCurrencyCode, 5123, "", "Currency code was not specifi
257257
RT_ERROR_MSG(JSERR_InvalidDate, 5124, "", "Invalid Date", kjstRangeError, 0)
258258
RT_ERROR_MSG(JSERR_IntlNotAvailable, 5125, "", "Intl is not available.", kjstTypeError, 0)
259259
RT_ERROR_MSG(JSERR_IntlNotImplemented, 5126, "", "Intl operation '%s' is not implemented.", kjstTypeError, 0)
260+
RT_ERROR_MSG(JSERR_InvalidPrivateOrGrandfatheredTag, 5127, "", "The arguments provided to Intl.Locale form an invalid privateuse or grandfathered language tag", kjstRangeError, 0)
260261

261262
RT_ERROR_MSG(JSERR_ArgumentOutOfRange, 5130, "%s: argument out of range", "argument out of range", kjstRangeError, 0)
262263
RT_ERROR_MSG(JSERR_ErrorOnNew, 5131, "", "Function is not a constructor", kjstTypeError, 0)

lib/Runtime/Base/JnDirectFields.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,6 @@ ENTRY(builtInJavascriptObjectEntryIsExtensible)
671671
ENTRY(builtInJavascriptObjectEntryKeys)
672672
ENTRY(builtInJavascriptObjectGetOwnPropertyDescriptor)
673673
ENTRY(builtInJavascriptObjectPreventExtensions)
674-
ENTRY(builtInJavascriptRegExpEntryTest) // TODO(jahorto): is this needed?
675674
ENTRY(builtInJavascriptStringEntryIndexOf)
676675
ENTRY(builtInJavascriptStringEntryMatch)
677676
ENTRY(builtInJavascriptStringEntryRepeat)
@@ -708,6 +707,7 @@ ENTRY(raiseOptionValueOutOfRange_3)
708707
ENTRY(raiseOptionValueOutOfRange)
709708
ENTRY(raiseThis_NullOrUndefined)
710709
ENTRY(raiseFunctionArgument_NeedFunction)
710+
ENTRY(raiseInvalidPrivateOrGrandfatheredTag)
711711

712712
// Promise (ChakraFull)
713713
ENTRY(Promise)

lib/Runtime/Library/Chakra.Runtime.Library.vcxproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<ClInclude Include="..\SerializableFunctionFields.h" />
158158
<ClInclude Include="AtomicsObject.h" />
159159
<ClInclude Include="AtomicsOperations.h" />
160+
<ClInclude Include="EngineInterfaceObjectBuiltIns.h" />
160161
<ClInclude Include="PropertyRecordUsageCache.h" />
161162
<ClInclude Include="CustomExternalIterator.h" />
162163
<ClInclude Include="JsBuiltInEngineInterfaceExtensionObject.h" />
@@ -326,4 +327,4 @@
326327
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
327328
<Import Project="$(BuildConfig_ARMASM_Path)armasm.targets" />
328329
</ImportGroup>
329-
</Project>
330+
</Project>

lib/Runtime/Library/Chakra.Runtime.Library.vcxproj.filters

+4-1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@
226226
<ClInclude Include="JsBuiltIn\JsBuiltIn.js.nojit.bc.64b.h" />
227227
<ClInclude Include="PropertyRecordUsageCache.h" />
228228
<ClInclude Include="..\LibraryFunction.h" />
229+
<ClInclude Include="IntlExtensionObjectBuiltIns.h" />
230+
<ClInclude Include="StringCacheList.h" />
231+
<ClInclude Include="EngineInterfaceObjectBuiltIns.h" />
229232
</ItemGroup>
230233
<ItemGroup>
231234
<None Include="ConcatString.inl" />
@@ -286,4 +289,4 @@
286289
<ARMASM Include="$(MSBuildThisFileDirectory)arm64\arm64_CallFunction.asm" />
287290
<ARMASM Include="$(MSBuildThisFileDirectory)arm64\arm64_DeferredParsingThunk.asm" />
288291
</ItemGroup>
289-
</Project>
292+
</Project>

lib/Runtime/Library/EngineInterfaceObject.cpp

+7-13
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ namespace Js
170170
// to share the common APIs without requiring everyone to access EngineInterfaceObject.Common.
171171
this->commonNativeInterfaces = DynamicObject::New(recycler,
172172
DynamicType::New(scriptContext, TypeIds_Object, library->GetObjectPrototype(), nullptr,
173-
DeferredTypeHandler<InitializeCommonNativeInterfaces>::GetDefaultInstance()));
173+
DeferredTypeHandler<InitializeCommonNativeInterfaces>::GetDefaultInstance()));
174174
library->AddMember(this, Js::PropertyIds::Common, this->commonNativeInterfaces);
175175

176176
for (uint i = 0; i <= MaxEngineInterfaceExtensionKind; i++)
@@ -210,15 +210,9 @@ namespace Js
210210

211211
JavascriptLibrary* library = commonNativeInterfaces->GetScriptContext()->GetLibrary();
212212

213-
#ifndef GlobalBuiltIn
214-
#define GlobalBuiltIn(global, method) \
215-
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtIn##global##method, &EngineInterfaceObject::EntryInfo::BuiltIn_##global##_##method##, 1); \
216-
213+
#define GlobalBuiltIn(global, method) library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtIn##global##method, &EngineInterfaceObject::EntryInfo::BuiltIn_##global##_##method##, 1);
217214
#define GlobalBuiltInConstructor(global) SetPropertyOn(commonNativeInterfaces, Js::PropertyIds::##global##, library->Get##global##Constructor());
218-
219-
#define BuiltInRaiseException(exceptionType, exceptionID) \
220-
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::raise##exceptionID, &EngineInterfaceObject::EntryInfo::BuiltIn_raise##exceptionID, 1); \
221-
215+
#define BuiltInRaiseException(exceptionType, exceptionID) library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::raise##exceptionID, &EngineInterfaceObject::EntryInfo::BuiltIn_raise##exceptionID, 1);
222216
#define BuiltInRaiseException1(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID)
223217
#define BuiltInRaiseException2(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID)
224218
#define BuiltInRaiseException3(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID##_3)
@@ -231,7 +225,7 @@ namespace Js
231225
#undef BuiltInRaiseException3
232226
#undef GlobalBuiltIn
233227
#undef GlobalBuiltInConstructor
234-
#endif
228+
235229
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectCreate, &JavascriptObject::EntryInfo::Create, 1);
236230
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectPreventExtensions, &JavascriptObject::EntryInfo::PreventExtensions, 1);
237231
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectGetOwnPropertyDescriptor, &JavascriptObject::EntryInfo::GetOwnPropertyDescriptor, 1);
@@ -266,7 +260,7 @@ namespace Js
266260
int hr = Js::JavascriptConversion::ToInt32(args[1], scriptContext);
267261
int resourceId;
268262

269-
switch(hr)
263+
switch (hr)
270264
{
271265
case ASYNCERR_NoErrorInErrorState:
272266
resourceId = 5200;
@@ -285,7 +279,7 @@ namespace Js
285279
const int strLength = 1024;
286280
OLECHAR errorString[strLength];
287281

288-
if(FGetResourceString(resourceId, errorString, strLength))
282+
if (FGetResourceString(resourceId, errorString, strLength))
289283
{
290284
return Js::JavascriptString::NewCopySz(errorString, scriptContext);
291285
}
@@ -440,7 +434,7 @@ namespace Js
440434
Var newVars[3];
441435
Js::Arguments newArgs(callInfo, newVars);
442436

443-
for (uint i = 0; i<args.Info.Count - 2; ++i)
437+
for (uint i = 0; i < args.Info.Count - 2; ++i)
444438
{
445439
newArgs.Values[i] = args.Values[i + 2];
446440
}

lib/Runtime/Library/EngineInterfaceObjectBuiltIns.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ GlobalBuiltInConstructor(Error) /*This was added back in to allow assert errors*
1212
GlobalBuiltInConstructor(Map)
1313
GlobalBuiltInConstructor(Symbol)
1414

15-
GlobalBuiltIn(Math,Abs)
16-
GlobalBuiltIn(Math,Floor)
17-
GlobalBuiltIn(Math,Max)
18-
GlobalBuiltIn(Math,Pow)
15+
GlobalBuiltIn(Math, Abs)
16+
GlobalBuiltIn(Math, Floor)
17+
GlobalBuiltIn(Math, Max)
18+
GlobalBuiltIn(Math, Pow)
1919

2020
GlobalBuiltIn(JavascriptObject, EntryDefineProperty)
2121
GlobalBuiltIn(JavascriptObject, EntryGetPrototypeOf)
@@ -64,3 +64,4 @@ BuiltInRaiseException1(RangeError, InvalidCurrencyCode)
6464
BuiltInRaiseException(TypeError, MissingCurrencyCode)
6565
BuiltInRaiseException(RangeError, InvalidDate)
6666
BuiltInRaiseException1(TypeError, FunctionArgument_NeedFunction)
67+
BuiltInRaiseException(RangeError, InvalidPrivateOrGrandfatheredTag)

0 commit comments

Comments
 (0)