X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=plugins%2Fdali-swig%2Fproperty-wrapper.rb;h=e548f613de0a1b9b04e083970f8f1ca169f663e4;hp=5e60919d1df8cc21d847a070ed4de3ec9c8b3a04;hb=a2e3740073b4cb92846a68831ad5bb35b12ac69a;hpb=b34b7545bf6bb2526b2a0544868a4aec8ee16335 diff --git a/plugins/dali-swig/property-wrapper.rb b/plugins/dali-swig/property-wrapper.rb index 5e60919..e548f61 100755 --- a/plugins/dali-swig/property-wrapper.rb +++ b/plugins/dali-swig/property-wrapper.rb @@ -26,13 +26,28 @@ $typeTable = [ ["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] @@ -180,9 +195,13 @@ end def writePropertiesToCSharpFile( daliClass ) # open the CSharp file autogenerated by SWIG - swigFiles = $daliSwigPath + "/csharp/" + swigFiles = $daliSwigPath + "/automatic/csharp/" + + # some C++ classes are renamed for C# + className = getCSharpName( daliClass.name ) + + fileName =(swigFiles + className ) + ".cs" - fileName =(swigFiles+daliClass.name) + ".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 @@ -212,17 +231,17 @@ def writePropertiesToCSharpFile( daliClass ) 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 def writeChildPropertiesToCSharpFile( daliClass ) # open the CSharp file autogenerated by SWIG - swigFiles = $daliSwigPath + "/csharp/" + swigFiles = $daliSwigPath + "/automatic/csharp/" # Add all the child properties to Control - fileName = (swigFiles+"Control") + ".cs" + fileName = (swigFiles+"View") + ".cs" if( ! File.exist?(fileName) ) return @@ -252,7 +271,7 @@ def writeChildPropertiesToCSharpFile( daliClass ) 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 @@ -263,6 +282,7 @@ def writeCSharpData #puts ( daliClass.name ) + hasChildProperties = false for property in daliClass.properties @@ -279,10 +299,13 @@ def writeCSharpData 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 @@ -308,7 +331,7 @@ def writeCSharpData 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 @@ -360,7 +383,7 @@ def writeDaliCoreProperties 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: @@ -408,7 +431,7 @@ def writeDaliToolkitProperties # 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")