From 8d2d9864e0ed61784aabf6ccadba35ca441ee150 Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Fri, 5 Jan 2024 14:04:43 +0200 Subject: [PATCH] Hide GlobalObject public methods (#1723) --- Jint/Native/Global/GlobalObject.cs | 20 ++++++++--------- Jint/Native/Json/JsonParser.cs | 2 +- Jint/Native/Number/Dtoa/NumberExtensions.cs | 25 +++++++++------------ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Jint/Native/Global/GlobalObject.cs b/Jint/Native/Global/GlobalObject.cs index 0ac34b195b..5ed1234b0d 100644 --- a/Jint/Native/Global/GlobalObject.cs +++ b/Jint/Native/Global/GlobalObject.cs @@ -31,7 +31,7 @@ private JsValue ToStringString(JsValue thisObject, JsValue[] arguments) /// /// https://tc39.es/ecma262/#sec-parseint-string-radix /// - public static JsValue ParseInt(JsValue thisObject, JsValue[] arguments) + internal static JsValue ParseInt(JsValue thisObject, JsValue[] arguments) { var inputString = TypeConverter.ToString(arguments.At(0)); var trimmed = StringPrototype.TrimEx(inputString); @@ -120,7 +120,7 @@ public static JsValue ParseInt(JsValue thisObject, JsValue[] arguments) /// /// https://tc39.es/ecma262/#sec-parsefloat-string /// - public static JsValue ParseFloat(JsValue thisObject, JsValue[] arguments) + internal static JsValue ParseFloat(JsValue thisObject, JsValue[] arguments) { var inputString = TypeConverter.ToString(arguments.At(0)); var trimmedString = StringPrototype.TrimStartEx(inputString); @@ -241,7 +241,7 @@ public static JsValue ParseFloat(JsValue thisObject, JsValue[] arguments) /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.4 /// - public static JsValue IsNaN(JsValue thisObject, JsValue[] arguments) + private static JsValue IsNaN(JsValue thisObject, JsValue[] arguments) { var value = arguments.At(0); @@ -257,7 +257,7 @@ public static JsValue IsNaN(JsValue thisObject, JsValue[] arguments) /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.2.5 /// - public static JsValue IsFinite(JsValue thisObject, JsValue[] arguments) + private static JsValue IsFinite(JsValue thisObject, JsValue[] arguments) { if (arguments.Length != 1) { @@ -288,7 +288,7 @@ public static JsValue IsFinite(JsValue thisObject, JsValue[] arguments) /// /// /// - public JsValue EncodeUri(JsValue thisObject, JsValue[] arguments) + private JsValue EncodeUri(JsValue thisObject, JsValue[] arguments) { var uriString = TypeConverter.ToString(arguments.At(0)); @@ -302,7 +302,7 @@ public JsValue EncodeUri(JsValue thisObject, JsValue[] arguments) /// /// /// - public JsValue EncodeUriComponent(JsValue thisObject, JsValue[] arguments) + private JsValue EncodeUriComponent(JsValue thisObject, JsValue[] arguments) { var uriString = TypeConverter.ToString(arguments.At(0)); @@ -409,14 +409,14 @@ private JsValue Encode(string uriString, SearchValues unescapedUriSet) return JsEmpty.Instance; } - public JsValue DecodeUri(JsValue thisObject, JsValue[] arguments) + private JsValue DecodeUri(JsValue thisObject, JsValue[] arguments) { var uriString = TypeConverter.ToString(arguments.At(0)); return Decode(uriString, ReservedUriSet); } - public JsValue DecodeUriComponent(JsValue thisObject, JsValue[] arguments) + private JsValue DecodeUriComponent(JsValue thisObject, JsValue[] arguments) { var componentString = TypeConverter.ToString(arguments.At(0)); @@ -596,7 +596,7 @@ private static bool IsDigit(char c, int radix, out int result) /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-B.2.1 /// - public JsValue Escape(JsValue thisObject, JsValue[] arguments) + private JsValue Escape(JsValue thisObject, JsValue[] arguments) { var uriString = TypeConverter.ToString(arguments.At(0)); @@ -628,7 +628,7 @@ public JsValue Escape(JsValue thisObject, JsValue[] arguments) /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-B.2.2 /// - public JsValue Unescape(JsValue thisObject, JsValue[] arguments) + private JsValue Unescape(JsValue thisObject, JsValue[] arguments) { var uriString = TypeConverter.ToString(arguments.At(0)); diff --git a/Jint/Native/Json/JsonParser.cs b/Jint/Native/Json/JsonParser.cs index 3dc380781e..82925ba028 100644 --- a/Jint/Native/Json/JsonParser.cs +++ b/Jint/Native/Json/JsonParser.cs @@ -770,7 +770,7 @@ static class Messages internal static class StringExtensions { - public static char CharCodeAt(this string source, int index) + internal static char CharCodeAt(this string source, int index) { if (index > source.Length - 1) { diff --git a/Jint/Native/Number/Dtoa/NumberExtensions.cs b/Jint/Native/Number/Dtoa/NumberExtensions.cs index 10c02a615d..21ae514408 100644 --- a/Jint/Native/Number/Dtoa/NumberExtensions.cs +++ b/Jint/Native/Number/Dtoa/NumberExtensions.cs @@ -1,21 +1,18 @@ -#nullable disable - using System.Runtime.CompilerServices; -namespace Jint.Native.Number.Dtoa +namespace Jint.Native.Number.Dtoa; + +internal static class NumberExtensions { - internal static class NumberExtensions + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static long UnsignedShift(this long l, int shift) { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static long UnsignedShift(this long l, int shift) - { - return (long) ((ulong) l >> shift); - } + return (long) ((ulong) l >> shift); + } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static ulong UnsignedShift(this ulong l, int shift) - { - return l >> shift; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static ulong UnsignedShift(this ulong l, int shift) + { + return l >> shift; } }