["VECTOR4", "Vector4", "", "Vector4 temp = new Vector4(0.0f,0.0f,0.0f,0.0f);"],
["MATRIX3", "Matrix3", "", "Matrix3 temp = new Matrix3();"],
["MATRIX", "Matrix", "", "Matrix temp = new Matrix();" ],
- ["RECTANGLE", "RectInteger", "", "RectInteger temp = new RectInteger(0,0,0,0);"],
- ["ROTATION", "Quaternion", "", "Quaternion temp = new Quaternion();"],
+ ["RECTANGLE", "Rectangle", "", "Rectangle temp = new Rectangle(0,0,0,0);"],
+ ["ROTATION", "Rotation", "", "Rotation temp = new Rotation();"],
["STRING", "string", "out", "string temp;"],
["ARRAY", "Dali.Property.Array", "", "Dali.Property.Array temp = new Dali.Property.Array();"],
["MAP", "Dali.Property.Map", "", "Dali.Property.Map temp = new Dali.Property.Map();"],
]
+
+# Some csharp classes are renamed ( e.g. C++ Control is called View in C#)
+$renameMap = [
+ ["Control", "View"]
+ ]
+
$daliSwigPath = String.new;
+def getCSharpName( cppClassName )
+
+ entry = $renameMap.select{ |a| a.first == cppClassName }
+ if( entry.empty?)
+ return cppClassName
+ end
+ return entry[0][1]
+end
+
# use the table above to get information for a specific type
def getCSharpType( type )
entry = $typeTable.select{ |a| a.first == type }
- if( entry == nil )
+ if( entry.empty? )
return nil
end
return entry[0]
# Property struct stores the information about a property after parsing the C++ DALI_PROPERTY macro
-$propertyStruct = Struct.new("Property", :name, :type, :writable, :animatable,:constrainInput, :enum, :shortenum, :csharpGetter, :csharpSetter, :childProperty,)
+$propertyStruct = Struct.new("Property", :name, :type, :writable, :animatable,:constrainInput, :enum, :shortenum, :develAPI, :csharpGetter, :csharpSetter, :childProperty,)
# daliClass struct stores a class name and an array of properties
$daliClassStruct = Struct.new("DaliClass", :name, :properties )
# extract the property enum name Dali::Path::Property::POINTS -> POINTS
shortenum = data[6].split(":").last
+ develAPI = false;
+ # Check if the property uses devel API
+ # Currently we ignore devel properties for now
+ if data[6].include? "Devel"
+ develAPI = true;
+ puts("Ignoring DEVEL API property: " + shortenum);
+ end
+
+
+
# store the :name, :type, :writable, :animatable, :constrainInput, :enum
property = $propertyStruct.new;
property.animatable = (data[4] == "true")
property.constrainInput = (data[5]=="true")
property.enum = shortenum
-
+ property.develAPI = develAPI;
return property;
end
# Extract the property name, type
property = $propertyStruct.new;
+ #First strip out any comments at the end of the macro, some have text like // deprecated
+ commentIndex = propertyMacro.index("//");
+
+ if( commentIndex )
+ propertyMacro = propertyMacro.slice(0..commentIndex-1)
+ end
+
+
# Split the macro definition by comma and quotes, close bracket and delete any empty segments
data = propertyMacro.split(/[\s,")]/).reject { |s| s.empty? }
property.type = data[4]
end
+ # last item should be property enum, e.g. INPUT_POINT_SIZE
property.enum = data[data.length-1]
end
# open the CSharp file autogenerated by SWIG
swigFiles = $daliSwigPath + "/automatic/csharp/"
- fileName =(swigFiles+daliClass.name) + ".cs"
+ # some C++ classes are renamed for C#
+ className = getCSharpName( daliClass.name )
+
+ fileName =(swigFiles + className ) + ".cs"
+
# it's possible some classes in dali-core aren't being wrapped by swig, so if the swig generated file
# doesn't exist just return
for property in daliClass.properties
- if (!property.childProperty)
+ if( (!property.childProperty) && (!property.develAPI))
file.write( property.csharpGetter );
file.write( property.csharpSetter );
end
file.write("\n}\n\n}"); # re-insert the closing brackets we over-wrote
end
- puts("Injected #{daliClass.properties.length} C# Properties into #{daliClass.name}.cs".blueBackground)
+ puts("Injected #{daliClass.properties.length} C# Properties from #{daliClass.name} into #{className}.cs".blueBackground)
end
swigFiles = $daliSwigPath + "/automatic/csharp/"
# Add all the child properties to Control
- fileName = (swigFiles+"Control") + ".cs"
+ fileName = (swigFiles+"View") + ".cs"
if( ! File.exist?(fileName) )
return
file.write("\n}\n\n}"); # re-insert the closing brackets we over-wrote
end
- puts("Injected #{$childPropertyCount} C# Child Properties into #{"Control"}.cs".blueBackground)
+ puts("Injected #{$childPropertyCount} C# Child Properties into #{"View"}.cs".blueBackground)
end
#puts ( daliClass.name )
+
hasChildProperties = false
for property in daliClass.properties
next
end
+ #exception case <<<
+ #Tooltip gives swig build error
+ if( property.name == "Tooltip" )
+ next
+ end
+ #exception case >>>
+
$totalProperties+=1 # keep track of total
propertyType = propertyInfo[1] # e.g. bool or int
propertyArg = propertyInfo[2] # e.g. ref or out
tempDeclaration = propertyInfo[3] # e.g. bool temp;
- propertyName = "#{daliClass.name}.Property.#{property.enum}"
+ csharpClassName = getCSharpName(daliClass.name);
+
+
+ propertyName = "#{csharpClassName}.Property.#{property.enum}"
if property.childProperty
- propertyName = "#{daliClass.name}.ChildProperty.#{property.enum}"
+ propertyName = "#{csharpClassName}.ChildProperty.#{property.enum}"
hasChildProperties = true
end
- property.csharpGetter =" public #{propertyType} #{property.name} \n"\
- " { \n"\
- " get \n" \
+ property.csharpGetter =" public #{propertyType} #{property.name}\n"\
+ " {\n"\
+ " get\n" \
" {\n"\
" #{tempDeclaration}\n"\
" GetProperty( #{propertyName}).Get( #{propertyArg} temp );\n"\
if property.writable
#text.SetProperty(TextLabel.Property.HORIZONTAL_ALIGNMENT, new Property.Value("CENTER"));
- property.csharpSetter = " set \n" \
- " { \n"\
+ property.csharpSetter = " set\n" \
+ " {\n"\
" SetProperty( #{propertyName}, new Dali.Property.Value( value ) );\n" \
" }\n"\
" }\n"
else
property.csharpSetter = "}" # close the opening property declaration
end
+
+ #exception case <<<
+ if( property.name == "Behavior" )
+ property.csharpGetter =" public Layer.LayerBehavior #{property.name} \n"\
+ " { \n"\
+ " get \n" \
+ " {\n"\
+ " return GetBehavior();\n"\
+ " }\n"
+
+ property.csharpSetter = " set \n" \
+ " { \n"\
+ " SetBehavior( value );\n" \
+ " }\n"\
+ " }\n"
+ end
+ #exception case >>>
end
# write normal properties to the class's own csharp file
writePropertiesToCSharpFile( daliClass )
- # write child properties to Control.cs
+ # write child properties to View.cs ( on Control has child properties)
if (hasChildProperties)
writeChildPropertiesToCSharpFile( daliClass )
end
puts("Scanning folder: #{$daliCorePath}\n\n");
# Executed a recursive grep over dali-core for the DALI_PROPERTY macro
- result =`grep --include *.cpp -r "DALI_PROPERTY( \" #{$daliCorePath}`
+ result =`grep --include \\*.cpp -r "DALI_PROPERTY( \" #{$daliCorePath}`
# We now have a list of lines that look like this:
# DALI_PROPERTY_REGISTRATION
# DALI_ANIMATABLE_PROPERTY_REGISTRATION
# DALI_CHILD_PROPERTY_REGISTRATION
- result =`grep --include *.cpp -w 'Control::Impl::SetProperty\\|DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(\\|DALI_CHILD_PROPERTY_REGISTRATION(\\|DALI_ANIMATABLE_PROPERTY_REGISTRATION(\\|DALI_PROPERTY_REGISTRATION' -r #{$daliToolkitPath}`
+ result =`grep --include \\*.cpp -w 'Control::Impl::SetProperty\\|DALI_ANIMATABLE_PROPERTY_REGISTRATION_WITH_DEFAULT(\\|DALI_CHILD_PROPERTY_REGISTRATION(\\|DALI_ANIMATABLE_PROPERTY_REGISTRATION(\\|DALI_PROPERTY_REGISTRATION' -r #{$daliToolkitPath}`
if( result == "" )
puts("Error parsing #{$daliToolkitPath} no properties found")