Skip to content

Commit cb95360

Browse files
committed
Added ecma boolean, function, symbol.
1 parent 1d4415a commit cb95360

4 files changed

Lines changed: 156 additions & 1 deletion

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using CSharpToJavaScript.Utils;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace CSharpToJavaScript.APIs.JS;
9+
//https://262.ecma-international.org/14.0/#sec-boolean-objects
10+
[To(ToAttribute.Default)]
11+
public partial class Boolean : BooleanPrototype
12+
{
13+
public dynamic Value { get; set; }
14+
15+
public static implicit operator Boolean(bool value) { return new Boolean(value) { Value = value }; }
16+
public static implicit operator bool(Boolean value) { return new Boolean(value) { Value = value }; }
17+
18+
[To(ToAttribute.FirstCharToLowerCase)]
19+
public static BooleanPrototype Prototype { get; } = new();
20+
21+
public Boolean(dynamic value) { }
22+
}
23+
[To(ToAttribute.FirstCharToLowerCase)]
24+
public partial class BooleanPrototype : ObjectPrototype
25+
{
26+
27+
public BooleanPrototype() { }
28+
29+
public string ToString()
30+
{
31+
throw new System.NotImplementedException();
32+
}
33+
34+
public bool ValueOf()
35+
{
36+
throw new System.NotImplementedException();
37+
}
38+
}

CSharpToJavaScript/APIs/JS/Ecma/Error.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public Error(string message, object? options = null)
1919
}
2020

2121
[To(ToAttribute.FirstCharToLowerCase)]
22-
public class ErrorPrototype
22+
public class ErrorPrototype : ObjectPrototype
2323
{
2424
public string Message { get; set; } = string.Empty;
2525
public string Name { get; set; } = "Error";
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using CSharpToJavaScript.Utils;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace CSharpToJavaScript.APIs.JS;
9+
10+
//https://262.ecma-international.org/14.0/#sec-function-objects
11+
public partial class Function : FunctionPrototype
12+
{
13+
[To(ToAttribute.FirstCharToLowerCase)]
14+
public int Length { get; } = 1;
15+
[To(ToAttribute.FirstCharToLowerCase)]
16+
public string Name { get; } = string.Empty;
17+
18+
[To(ToAttribute.FirstCharToLowerCase)]
19+
public static FunctionPrototype Prototype { get; } = new();
20+
21+
22+
//see note!
23+
//https://262.ecma-international.org/14.0/#sec-function-p1-p2-pn-body
24+
[To(ToAttribute.Default)]
25+
public Function(string parameterArgs, string bodyArg)
26+
{
27+
28+
}
29+
}
30+
31+
[To(ToAttribute.FirstCharToLowerCase)]
32+
public partial class FunctionPrototype : ObjectPrototype
33+
{
34+
public FunctionPrototype() { }
35+
36+
public dynamic Apply(dynamic thisArg, dynamic argArray)
37+
{
38+
throw new System.NotImplementedException();
39+
}
40+
41+
public dynamic Bbind(dynamic thisArg, params dynamic[] args)
42+
{
43+
throw new System.NotImplementedException();
44+
}
45+
public dynamic Call(dynamic thisArg, params dynamic[] args)
46+
{
47+
throw new System.NotImplementedException();
48+
}
49+
public string ToString()
50+
{
51+
throw new System.NotImplementedException();
52+
}
53+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using CSharpToJavaScript.Utils;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace CSharpToJavaScript.APIs.JS;
9+
10+
//https://262.ecma-international.org/14.0/#sec-symbol-objects
11+
[To(ToAttribute.Default)]
12+
public partial class Symbol : SymbolPrototype
13+
{
14+
//TODO! How?
15+
//https://262.ecma-international.org/14.0/#sec-symbol.asynciterator
16+
//https://262.ecma-international.org/14.0/#sec-symbol.hasinstance
17+
//https://262.ecma-international.org/14.0/#sec-symbol.iterator
18+
//https://262.ecma-international.org/14.0/#sec-symbol.match
19+
//https://262.ecma-international.org/14.0/#sec-symbol.matchall
20+
//https://262.ecma-international.org/14.0/#sec-symbol.replace
21+
//https://262.ecma-international.org/14.0/#sec-symbol.search
22+
//https://262.ecma-international.org/14.0/#sec-symbol.species
23+
//https://262.ecma-international.org/14.0/#sec-symbol.split
24+
//https://262.ecma-international.org/14.0/#sec-symbol.toprimitive
25+
//https://262.ecma-international.org/14.0/#sec-symbol.tostringtag
26+
//https://262.ecma-international.org/14.0/#sec-symbol.unscopables
27+
28+
[To(ToAttribute.FirstCharToLowerCase)]
29+
public SymbolPrototype Prototype { get; } = new();
30+
31+
[To(ToAttribute.Default)]
32+
public Symbol(string description = "")
33+
{
34+
35+
}
36+
37+
[To(ToAttribute.FirstCharToLowerCase)]
38+
public static Symbol For(string key)
39+
{
40+
throw new System.NotImplementedException();
41+
}
42+
43+
[To(ToAttribute.FirstCharToLowerCase)]
44+
public static string KeyFor(Symbol sym)
45+
{
46+
throw new System.NotImplementedException();
47+
}
48+
}
49+
50+
[To(ToAttribute.FirstCharToLowerCase)]
51+
public partial class SymbolPrototype : ObjectPrototype
52+
{
53+
public string Description { get; } = string.Empty;
54+
public SymbolPrototype() { }
55+
public string ToString(dynamic? radix = null)
56+
{
57+
throw new System.NotImplementedException();
58+
}
59+
public Symbol ValueOf()
60+
{
61+
throw new System.NotImplementedException();
62+
}
63+
64+
}

0 commit comments

Comments
 (0)