protected override void AddProperty(DefProperty p) { if (p.Function.IsVirtual) { base.AddProperty(p); } }
public static DefProperty[] GetPropertiesFromFunctions(List <DefFunction> funcs) { SortedList <string, DefProperty> props = new SortedList <string, DefProperty>(); foreach (DefFunction f in funcs) { if (f.IsProperty) { DefProperty p = null; if (props.ContainsKey(f.CLRName)) { p = props[f.CLRName]; } else { p = new DefProperty(); p.Name = f.CLRName; if (f.IsGetProperty) { p.TypeName = f.TypeName; p.PassedByType = f.PassedByType; } else { p.TypeName = f.Parameters[0].TypeName; p.PassedByType = f.Parameters[0].PassedByType; } props.Add(f.CLRName, p); } if (f.IsGetProperty) { p.CanRead = true; p.GetterFunction = f; } else if (f.IsSetProperty) { p.CanWrite = true; p.SetterFunction = f; } } } DefProperty[] parr = new DefProperty[props.Count]; for (int i = 0; i < props.Count; i++) { parr[i] = props.Values[i]; } return(parr); }
protected DefProperty EnhanceProperty(DefProperty property) { DefProperty prop = property.Clone(); if (_t.BaseClass != null) { if (!prop.CanWrite) { // There's a chance the class overrides only the get function. If the // property is not declared virtual then it will be read-only, so if // it's not virtual check if a base class contains the set property // and if it does, include it. // If it's virtual and its base function will be declared virtual, this // function will be declared virtual too, so it's not necessary to add // the set function. if (!DeclareAsVirtual(prop.GetterFunction)) { DefProperty bp = _t.BaseClass.GetProperty(prop.Name, true); if (bp != null && bp.CanWrite) { prop.CanWrite = true; prop.SetterFunction = bp.SetterFunction; } } } if (!prop.CanRead) { // There's a chance the class overrides only the set function. If the // property is not declared virtual then it will be write-only, so if // it's not virtual check if a base class contains the set property // and if it does, include it. // If it's virtual and its base function will be declared virtual, this // function will be declared virtual too, so it's not necessary to add // the get function. if (!DeclareAsVirtual(prop.SetterFunction)) { DefProperty bp = _t.BaseClass.GetProperty(prop.Name, true); if (bp != null && bp.CanRead) { prop.CanRead = true; prop.GetterFunction = bp.GetterFunction; } } } } return(prop); }
protected override bool AllowProperty(DefProperty p) { if (base.AllowProperty(p)) { if (p.Name == "Singleton" || p.Name == "SingletonPtr") { return(false); } else { return(true); } } else { return(false); } }
protected virtual void AddInterfaceProperty(DefProperty prop) { AddProperty(prop); }
protected virtual void AddProperty(DefProperty prop) { }
protected override void AddProperty(DefProperty p) { string ptype = GetCLRTypeName(p); string pname = GetClassName() + "::" + p.Name; if (p.CanRead) { if (!(p.GetterFunction.IsAbstract && AllowSubclassing)) { if (AllowProtectedMembers || p.GetterFunction.ProtectionType != ProtectionType.Protected) { string managedType = GetMethodNativeCall(p.GetterFunction, 0); _sb.AppendLine(ptype + " " + pname + "::get()"); _sb.AppendLine("{"); if (_cachedMembers.Contains(p.GetterFunction)) { string priv = NameToPrivate(p.Name); _sb.AppendLine("\treturn ( CLR_NULL == " + priv + " ) ? (" + priv + " = " + managedType + ") : " + priv + ";"); } else { _sb.AppendLine("\treturn " + managedType + ";"); } _sb.AppendLine("}"); } } } if (p.CanWrite) { if (!(p.SetterFunction.IsAbstract && AllowSubclassing)) { if (AllowProtectedMembers || p.SetterFunction.ProtectionType != ProtectionType.Protected) { _sb.AppendLine("void " + pname + "::set( " + ptype + " " + p.SetterFunction.Parameters[0].Name + " )"); _sb.AppendLine("{"); _sb.IncreaseIndent(); string preCall = GetMethodPreNativeCall(p.SetterFunction, 1); string nativeCall = GetMethodNativeCall(p.SetterFunction, 1); string postCall = GetMethodPostNativeCall(p.SetterFunction, 1); if (!String.IsNullOrEmpty(preCall)) { _sb.AppendLine(preCall); } _sb.AppendLine(nativeCall + ";"); if (!String.IsNullOrEmpty(postCall)) { _sb.AppendLine(postCall); } _sb.DecreaseIndent(); _sb.AppendLine("}"); } } } }