BadScript 2
Loading...
Searching...
No Matches
BadInteropEnumerable.cs
Go to the documentation of this file.
1using System.Collections;
2
9
11
16{
21 "Enumerable",
22 (_, _) => throw new BadRuntimeException("Cannot call method"),
23 () => new []{(BadInterfacePrototype)BadNativeClassBuilder.Enumerable.CreateGeneric(new []{BadAnyPrototype.Instance})}
24 );
25
29 private readonly IEnumerable<BadObject> m_Enumerable;
30
34 private readonly BadFunction m_Func;
35
40 public BadInteropEnumerable(IEnumerable<BadObject> enumerable)
41 {
42 m_Enumerable = enumerable;
43
45 "GetEnumerator",
46 _ => new BadInteropEnumerator(m_Enumerable.GetEnumerator()),
47 (BadClassPrototype)BadNativeClassBuilder.Enumerator.CreateGeneric(new []{BadAnyPrototype.Instance})
48 );
49 }
50
55 public IEnumerator<BadObject> GetEnumerator()
56 {
57 return m_Enumerable.GetEnumerator();
58 }
59
64 IEnumerator IEnumerable.GetEnumerator()
65 {
66 return m_Enumerable.GetEnumerator();
67 }
68
69
72 {
73 return s_Prototype;
74 }
75
77 public override bool HasProperty(string propName, BadScope? caller = null)
78 {
79 return propName == "GetEnumerator" ||
80 base.HasProperty(propName, caller);
81 }
82
84 public override BadObjectReference GetProperty(string propName, BadScope? caller = null)
85 {
86 return propName == "GetEnumerator"
87 ? BadObjectReference.Make("GetEnumerator", () => m_Func)
88 : base.GetProperty(propName, caller);
89 }
90
92 public override string ToSafeString(List<BadObject> done)
93 {
94 return "BadInteropEnumerable";
95 }
96}
Implements the Scope for the Script Engine.
Definition BadScope.cs:238
Implements an Interop Enumerable Object.
BadInteropEnumerable(IEnumerable< BadObject > enumerable)
Creates a new BadInteropEnumerable.
IEnumerator< BadObject > GetEnumerator()
Returns the Enumerator.
readonly IEnumerable< BadObject > m_Enumerable
The Enumerable Object.
static readonly BadClassPrototype s_Prototype
The Prototype for the Interop Enumerable Object.
readonly BadFunction m_Func
The Function that returns the Enumerator.
override BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.The Property Reference
override string ToSafeString(List< BadObject > done)
override bool HasProperty(string propName, BadScope? caller=null)
Returns true if the object contains a given property or there exists an extension for the current Ins...
Implements a simple wrapper for C# IEnumerators to be used in BS2.
The Base Class for all BadScript Objects.
Definition BadObject.cs:14
virtual BadObjectReference GetProperty(string propName, BadScope? caller=null)
Returns a Reference to the Property with the given Name.
Definition BadObject.cs:129
Implements the base functionality for a BadScript Reference.
static BadObjectReference Make(string refText, Func< BadObject > getter, Action< BadObject, BadPropertyInfo?>? setter=null, Action? delete=null)
Creates a new Reference Object.
Implements a function that can be called from the script.
Implements a Class Prototype for the BadScript Language.
Helper Class that Builds a Native Class from a Prototype.
static readonly BadInterfacePrototype Enumerable
The IEnumerable Interface Prototype.
static readonly BadInterfacePrototype Enumerator
The IEnumerator Interface Prototype.
BadObject CreateGeneric(BadObject[] args)
Resolves the Generic Object to a concrete type.
Defines a BadScript Enumerable.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Function Classes for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains Runtime Function Objects.
Contains Runtime Interface Objects.
Contains the Runtime Objects.
Definition BadArray.cs:10