19 new Dictionary<string, Func<BadObject, BadObject>>();
24 private readonly Dictionary<Type, Dictionary<string, Func<BadObject, BadObject>>>
m_ObjectExtensions =
25 new Dictionary<Type, Dictionary<string, Func<BadObject, BadObject>>>();
31 new Dictionary<Type, Dictionary<string, Func<BadObject, BadObject>>>();
33 private readonly Dictionary<Type, bool>
m_SupportedTypes =
new Dictionary<Type, bool>();
65 Type t = obj.GetType();
77 return objs.ToArray();
87 return objs.ToArray();
125 if (
m_StaticExtensionCache.TryGetValue(type, out Dictionary<
string, Func<BadObject, BadObject>>? extensions))
130 Dictionary<string, Func<BadObject, BadObject>>
131 exts =
new Dictionary<string, Func<BadObject, BadObject>>();
133 foreach (KeyValuePair<Type, Dictionary<
string, Func<BadObject, BadObject>>> kvp
in m_ObjectExtensions.Where(
134 x => x.Key.IsAssignableFrom(type)
137 foreach (KeyValuePair<
string, Func<BadObject, BadObject>> keyValuePair
in kvp.Value)
139 exts[keyValuePair.Key] = keyValuePair.Value;
214 public void RegisterObject(Type t,
string propName, Func<BadObject, BadObject> obj)
216 if (
m_ObjectExtensions.TryGetValue(t, out Dictionary<
string, Func<BadObject, BadObject>>? extension))
218 extension[propName] = obj;
269 $
"{t.Name}.{propName}",
270 () =>
GetObject(t, propName, instance, caller)
286 if (ext.ContainsKey(propName))
288 return ext[propName](instance);
310 return GetObject(typeof(T), propName, instance, caller);
Implements the Scope for the Script Engine.
Gets thrown by the runtime.
static BadRuntimeException Create(BadScope? scope, string message)
Creates a new BadScriptException.
Public Extension API for the BS2 Runtime.
void InnerAddExtensions(BadInteropExtensionProvider provider)
Adds the Extensions to the given Provider.
void RegisterObject(Type t, string propName, Func< BadObject, BadObject > obj)
Registers the specified extension for the specified type.
readonly List< Type > m_ActiveExtensions
List of all active extensions.
void RegisterObject(Type t, string propName, BadObject obj)
Registers the specified extension for the specified type.
void RegisterGlobal(string propName, Func< BadObject, BadObject > func)
Registers the specified extension for all objects.
readonly Dictionary< Type, bool > m_SupportedTypes
BadInteropExtensionProvider()
Creates a new BadInteropExtensionProvider.
bool HasObject< T >(string propName)
Returns True if the specified type has the specified extension.
readonly Dictionary< Type, Dictionary< string, Func< BadObject, BadObject > > > m_StaticExtensionCache
Cache for already built extension tables.
BadObjectReference GetObjectReference(Type t, string propName, BadObject instance, BadScope? caller)
Returns a reference to the specified extension.
void RegisterObject< T >(string propName, Func< T, BadObject > obj)
Registers the specified extension for the specified type.
BadObject[] GetExtensionNames(BadObject obj)
Returns all Extension Names for the specified object.
bool InnerHasTypeExtensions(Type t)
void AddExtension(BadInteropExtension extension)
Adds the specified extension to the list of registered extensions.
Dictionary< string, Func< BadObject, BadObject > > GetTypeExtensions(Type type)
Returns all type extensions for the specified type.
bool HasGlobalExtensions(string propName)
Returns true if a global extension with the specified name is available.
void AddExtensions(params BadInteropExtension[] extensions)
Adds the specified extensions to the list of registered extensions.
void RegisterGlobal(string propName, BadObject obj)
Registers the specified extension for all objects.
readonly Dictionary< Type, Dictionary< string, Func< BadObject, BadObject > > > m_ObjectExtensions
Object Extensions that are available for objects of the specified type.
void AddExtension< T >()
Adds an Extension Class to the List of registered extensions.
BadObject GetObject(Type t, string propName, BadObject instance, BadScope? caller)
Returns the specified extension.
BadInteropExtensionProvider(BadInteropExtension[] extensions)
Creates a new BadInteropExtensionProvider.
bool HasObject(Type t, string propName)
Returns True if the specified type has the specified extension.
BadObject[] GetExtensionNames()
Returns all Global Extension names.
bool HasTypeExtensions(Type t)
Returns true if any extensions are available for the specified object(excluding global extensions)
BadObject GetObject< T >(string propName, BadObject instance, BadScope? caller=null)
Returns the specified extension.
readonly Dictionary< string, Func< BadObject, BadObject > > m_GlobalExtensions
Global extensions that are available for all objects in the runtime.
void Initialize(BadInteropExtension ext)
Initializes the extension.
The Base Class for all BadScript Objects.
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 Native Type.
T Value
The Value of the Native Type.
Defines Settings for Native Optimizations.
static T Instance
Returns the Instance of the Settings Provider.
Defines properties for Native Types.
Contains the Error Objects for the BadScript2 Language.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Native Runtime Objects.
Contains the Runtime Objects.
Contains Runtime Settings Objects.