Reworked script function attribute, added initial math library
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Upsilon.BaseTypes;
|
||||
using Upsilon.StandardLibraries;
|
||||
using Type = Upsilon.BaseTypes.Type;
|
||||
|
||||
namespace Upsilon.BoundTypes
|
||||
@@ -52,12 +54,25 @@ namespace Upsilon.BoundTypes
|
||||
{
|
||||
obj.Properties.Add(f.Name.ToLowerInvariant(), f);
|
||||
}
|
||||
var methods = backingType.GetMethods().Select(x => new UserDataBoundMethod()
|
||||
var methods = new List<UserDataBoundMethod>();
|
||||
var backingMethods = backingType.GetMethods();
|
||||
foreach (var backingMethod in backingMethods)
|
||||
{
|
||||
Name = x.Name,
|
||||
Type = Type.Function,
|
||||
ResultType = x.ReturnType.GetScriptType()
|
||||
});
|
||||
if (backingMethod.IsSpecialName)
|
||||
continue;
|
||||
var name = backingMethod.Name;
|
||||
var attribute = backingMethod.GetCustomAttribute(typeof(ScriptFunctionAttribute));
|
||||
if (attribute is ScriptFunctionAttribute sfa )
|
||||
{
|
||||
name = sfa.Name;
|
||||
}
|
||||
methods.Add(new UserDataBoundMethod()
|
||||
{
|
||||
Name = name,
|
||||
Type = Type.Function,
|
||||
ResultType = backingMethod.ReturnType.GetScriptType()
|
||||
});
|
||||
}
|
||||
foreach (var f in methods)
|
||||
{
|
||||
obj.Properties.Add(f.Name.ToLowerInvariant(), f);
|
||||
|
||||
Reference in New Issue
Block a user