in tools/codegen/exe/OutputEffectType.cs [538:617]
private static void WritePropertyImplementation(Effects.Effect effect, Formatter output, Effects.Property property)
{
// Property with type string describes
// name/author/category/description of effect but not input type
if (property.Type == "string" || property.IsHandCoded || property.IsHidden)
return;
var min = property.Properties.Find(internalProperty => internalProperty.Name == "Min");
var max = property.Properties.Find(internalProperty => internalProperty.Name == "Max");
bool isWithUnsupported = (property.ExcludedEnumIndexes != null) && (property.ExcludedEnumIndexes.Count != 0);
string customConversion = null;
if (property.ConvertRadiansToDegrees)
{
customConversion = "ConvertRadiansToDegrees";
}
else if (property.ConvertColorHdrToVector3)
{
customConversion = "ConvertColorHdrToVector3";
}
else if (property.Name == "AlphaMode")
{
customConversion = "ConvertAlphaMode";
}
bool isValidation = ((min != null) || (max != null) || isWithUnsupported) && (customConversion == null);
string implementMacro = property.IsArray ? "IMPLEMENT_EFFECT_ARRAY_PROPERTY" : "IMPLEMENT_EFFECT_PROPERTY";
if (isValidation)
{
implementMacro += "_WITH_VALIDATION";
}
output.WriteLine(implementMacro + "(" + effect.ClassName + ",");
output.Indent();
output.WriteLine(property.Name + ",");
output.WriteLine((customConversion ?? property.TypeNameBoxed) + ",");
if (!property.IsArray)
{
output.WriteLine(property.TypeNameCpp + ",");
}
if (isValidation)
{
output.WriteLine(property.NativePropertyName + ",");
var validationChecks = new List<string>();
if (min != null)
{
AddValidationChecks(validationChecks, property, min.Value, ">=");
}
if (max != null)
{
AddValidationChecks(validationChecks, property, max.Value, "<=");
}
if (isWithUnsupported)
{
foreach (var index in property.ExcludedEnumIndexes)
{
validationChecks.Add("value != static_cast<" + property.TypeNameCpp + ">(" + index + ")");
}
}
output.WriteLine("(" + string.Join(") && (", validationChecks) + "))");
}
else
{
output.WriteLine(property.NativePropertyName + ")");
}
output.Unindent();
output.WriteLine();
}