static private Class declareClass(Type type) { string fullname = type.GetSafeFullName(); int lastDotIndex = fullname.LastIndexOf('.'); string parentName = lastDotIndex > -1 ? fullname.Substring(0, lastDotIndex) : string.Empty; if (string.IsNullOrWhiteSpace(parentName)) { return(declareClass(typeof(Entry), null, type)); } else { Base parent = Base.FindInstance(parentName); if (null == parent) { Entry.LogWarning("Need to bind parent [{0}]!", parentName); parent = Entry.DeclareNamespace(parentName); } if (!(parent is Class) && !(parent is Namespace)) { Entry.LogError("Try to bind class dynamically but its parent [{0}] is not a class nor namespace!", parent); return(null); } return(declareClass(parent.GetType(), parent, type)); } }
static private StaticProperty getStaticProperty(IntPtr handle) { StaticProperty property = Base.FindInstance <StaticProperty>(handle); if (null == property && !sStaticProperties.TryGetValue(handle, out property)) { Entry.LogWarning("No static property for handle {0}", handle.ToString()); } return(property); }
static private InstanceProperty getInstanceProperty(object target, IntPtr handle, string name) { Type type = target.GetType(); Class c = Class.FindClass(type.GetSafeFullName()); if (null == c) { Entry.LogWarning("No class registered with name {0}", type.FullName); return(null); } InstanceProperty property = Base.FindInstance <InstanceProperty>(handle); if (null == property) { property = c.GetInstanceProperty(name); } if (null == property) { Entry.LogWarning("No property registered in {0} with name {1}", type.FullName, name); return(null); } return(property); }
static protected IntPtr CallInstanceFunction(IntPtr caller, IntPtr handle, string name, IntPtr parameters, int count) { IntPtr result = IntPtr.Zero; Entry.BeginCallFunction(); object target = Entry.Object.GetInstance(caller); do { if (null == target) { Entry.LogWarning("No instance for index {0}", caller.ToString()); break; } Type type = target.GetType(); Class c = Class.FindClass(type.GetSafeFullName()); if (null == c) { Entry.LogWarning("No class registered with name {0}", type.FullName); break; } InstanceFunctionBase function = Base.FindInstance <InstanceFunctionBase>(handle); if (null == function) { function = c.GetInstanceFunction(name); } if (null == function) { Entry.LogWarning("No function registered in {0} with name {1}", type.FullName, name); break; } result = function.Invoke(target, parameters, count); } while (false); Entry.EndCallFunction(); return(result); }