Skip to content

Commit

Permalink
Implement Intl.Locale
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhorton committed Sep 8, 2018
1 parent 962624d commit 06bd8ce
Show file tree
Hide file tree
Showing 10 changed files with 812 additions and 26 deletions.
1 change: 1 addition & 0 deletions lib/Parser/rterrors.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ RT_ERROR_MSG(JSERR_MissingCurrencyCode, 5123, "", "Currency code was not specifi
RT_ERROR_MSG(JSERR_InvalidDate, 5124, "", "Invalid Date", kjstRangeError, 0)
RT_ERROR_MSG(JSERR_IntlNotAvailable, 5125, "", "Intl is not available.", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_IntlNotImplemented, 5126, "", "Intl operation '%s' is not implemented.", kjstTypeError, 0)
RT_ERROR_MSG(JSERR_InvalidPrivateOrGrandfatheredTag, 5127, "", "The arguments provided to Intl.Locale form an invalid privateuse or grandfathered language tag", kjstRangeError, 0)

RT_ERROR_MSG(JSERR_ArgumentOutOfRange, 5130, "%s: argument out of range", "argument out of range", kjstRangeError, 0)
RT_ERROR_MSG(JSERR_ErrorOnNew, 5131, "", "Function is not a constructor", kjstTypeError, 0)
Expand Down
2 changes: 1 addition & 1 deletion lib/Runtime/Base/JnDirectFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ ENTRY(builtInJavascriptObjectEntryIsExtensible)
ENTRY(builtInJavascriptObjectEntryKeys)
ENTRY(builtInJavascriptObjectGetOwnPropertyDescriptor)
ENTRY(builtInJavascriptObjectPreventExtensions)
ENTRY(builtInJavascriptRegExpEntryTest) // TODO(jahorto): is this needed?
ENTRY(builtInJavascriptStringEntryIndexOf)
ENTRY(builtInJavascriptStringEntryMatch)
ENTRY(builtInJavascriptStringEntryRepeat)
Expand Down Expand Up @@ -708,6 +707,7 @@ ENTRY(raiseOptionValueOutOfRange_3)
ENTRY(raiseOptionValueOutOfRange)
ENTRY(raiseThis_NullOrUndefined)
ENTRY(raiseFunctionArgument_NeedFunction)
ENTRY(raiseInvalidPrivateOrGrandfatheredTag)

// Promise (ChakraFull)
ENTRY(Promise)
Expand Down
3 changes: 2 additions & 1 deletion lib/Runtime/Library/Chakra.Runtime.Library.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<ClInclude Include="..\SerializableFunctionFields.h" />
<ClInclude Include="AtomicsObject.h" />
<ClInclude Include="AtomicsOperations.h" />
<ClInclude Include="EngineInterfaceObjectBuiltIns.h" />
<ClInclude Include="PropertyRecordUsageCache.h" />
<ClInclude Include="CustomExternalIterator.h" />
<ClInclude Include="JsBuiltInEngineInterfaceExtensionObject.h" />
Expand Down Expand Up @@ -326,4 +327,4 @@
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
<Import Project="$(BuildConfig_ARMASM_Path)armasm.targets" />
</ImportGroup>
</Project>
</Project>
5 changes: 4 additions & 1 deletion lib/Runtime/Library/Chakra.Runtime.Library.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
<ClInclude Include="JsBuiltIn\JsBuiltIn.js.nojit.bc.64b.h" />
<ClInclude Include="PropertyRecordUsageCache.h" />
<ClInclude Include="..\LibraryFunction.h" />
<ClInclude Include="IntlExtensionObjectBuiltIns.h" />
<ClInclude Include="StringCacheList.h" />
<ClInclude Include="EngineInterfaceObjectBuiltIns.h" />
</ItemGroup>
<ItemGroup>
<None Include="ConcatString.inl" />
Expand Down Expand Up @@ -286,4 +289,4 @@
<ARMASM Include="$(MSBuildThisFileDirectory)arm64\arm64_CallFunction.asm" />
<ARMASM Include="$(MSBuildThisFileDirectory)arm64\arm64_DeferredParsingThunk.asm" />
</ItemGroup>
</Project>
</Project>
20 changes: 7 additions & 13 deletions lib/Runtime/Library/EngineInterfaceObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace Js
// to share the common APIs without requiring everyone to access EngineInterfaceObject.Common.
this->commonNativeInterfaces = DynamicObject::New(recycler,
DynamicType::New(scriptContext, TypeIds_Object, library->GetObjectPrototype(), nullptr,
DeferredTypeHandler<InitializeCommonNativeInterfaces>::GetDefaultInstance()));
DeferredTypeHandler<InitializeCommonNativeInterfaces>::GetDefaultInstance()));
library->AddMember(this, Js::PropertyIds::Common, this->commonNativeInterfaces);

for (uint i = 0; i <= MaxEngineInterfaceExtensionKind; i++)
Expand Down Expand Up @@ -210,15 +210,9 @@ namespace Js

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

#ifndef GlobalBuiltIn
#define GlobalBuiltIn(global, method) \
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtIn##global##method, &EngineInterfaceObject::EntryInfo::BuiltIn_##global##_##method##, 1); \

#define GlobalBuiltIn(global, method) library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtIn##global##method, &EngineInterfaceObject::EntryInfo::BuiltIn_##global##_##method##, 1);
#define GlobalBuiltInConstructor(global) SetPropertyOn(commonNativeInterfaces, Js::PropertyIds::##global##, library->Get##global##Constructor());

#define BuiltInRaiseException(exceptionType, exceptionID) \
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::raise##exceptionID, &EngineInterfaceObject::EntryInfo::BuiltIn_raise##exceptionID, 1); \

#define BuiltInRaiseException(exceptionType, exceptionID) library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::raise##exceptionID, &EngineInterfaceObject::EntryInfo::BuiltIn_raise##exceptionID, 1);
#define BuiltInRaiseException1(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID)
#define BuiltInRaiseException2(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID)
#define BuiltInRaiseException3(exceptionType, exceptionID) BuiltInRaiseException(exceptionType, exceptionID##_3)
Expand All @@ -231,7 +225,7 @@ namespace Js
#undef BuiltInRaiseException3
#undef GlobalBuiltIn
#undef GlobalBuiltInConstructor
#endif

library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectCreate, &JavascriptObject::EntryInfo::Create, 1);
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectPreventExtensions, &JavascriptObject::EntryInfo::PreventExtensions, 1);
library->AddFunctionToLibraryObject(commonNativeInterfaces, Js::PropertyIds::builtInJavascriptObjectGetOwnPropertyDescriptor, &JavascriptObject::EntryInfo::GetOwnPropertyDescriptor, 1);
Expand Down Expand Up @@ -266,7 +260,7 @@ namespace Js
int hr = Js::JavascriptConversion::ToInt32(args[1], scriptContext);
int resourceId;

switch(hr)
switch (hr)
{
case ASYNCERR_NoErrorInErrorState:
resourceId = 5200;
Expand All @@ -285,7 +279,7 @@ namespace Js
const int strLength = 1024;
OLECHAR errorString[strLength];

if(FGetResourceString(resourceId, errorString, strLength))
if (FGetResourceString(resourceId, errorString, strLength))
{
return Js::JavascriptString::NewCopySz(errorString, scriptContext);
}
Expand Down Expand Up @@ -440,7 +434,7 @@ namespace Js
Var newVars[3];
Js::Arguments newArgs(callInfo, newVars);

for (uint i = 0; i<args.Info.Count - 2; ++i)
for (uint i = 0; i < args.Info.Count - 2; ++i)
{
newArgs.Values[i] = args.Values[i + 2];
}
Expand Down
9 changes: 5 additions & 4 deletions lib/Runtime/Library/EngineInterfaceObjectBuiltIns.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ GlobalBuiltInConstructor(Error) /*This was added back in to allow assert errors*
GlobalBuiltInConstructor(Map)
GlobalBuiltInConstructor(Symbol)

GlobalBuiltIn(Math,Abs)
GlobalBuiltIn(Math,Floor)
GlobalBuiltIn(Math,Max)
GlobalBuiltIn(Math,Pow)
GlobalBuiltIn(Math, Abs)
GlobalBuiltIn(Math, Floor)
GlobalBuiltIn(Math, Max)
GlobalBuiltIn(Math, Pow)

GlobalBuiltIn(JavascriptObject, EntryDefineProperty)
GlobalBuiltIn(JavascriptObject, EntryGetPrototypeOf)
Expand Down Expand Up @@ -64,3 +64,4 @@ BuiltInRaiseException1(RangeError, InvalidCurrencyCode)
BuiltInRaiseException(TypeError, MissingCurrencyCode)
BuiltInRaiseException(RangeError, InvalidDate)
BuiltInRaiseException1(TypeError, FunctionArgument_NeedFunction)
BuiltInRaiseException(RangeError, InvalidPrivateOrGrandfatheredTag)
Loading

0 comments on commit 06bd8ce

Please sign in to comment.