Making DALi core internals typesafe using guaranteed types; uint8_t, uint32_t
[platform/core/uifw/dali-core.git] / dali / internal / event / common / type-info-impl.cpp
index 1da80f0..cb69d1f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,7 +25,7 @@
 // INTERNAL INCLUDES
 #include <dali/integration-api/debug.h>
 #include <dali/internal/event/common/type-registry-impl.h>
-#include <dali/internal/event/common/proxy-object.h>
+#include <dali/internal/event/common/object-impl.h>
 
 using std::find_if;
 
@@ -74,6 +74,29 @@ private:
   const std::string& mFind;
 };
 
+/**
+ * Functor to find a matching property component index
+ */
+template <typename T>
+struct PropertyComponentFinder
+{
+  PropertyComponentFinder( Dali::Property::Index basePropertyIndex, const int find )
+  : mBasePropertyIndex( basePropertyIndex ),
+    mFind( find )
+  {
+  }
+
+  bool operator()(const T &p) const
+  {
+    return ( p.second.basePropertyIndex == mBasePropertyIndex && p.second.componentIndex == mFind );
+  }
+
+private:
+
+  Dali::Property::Index mBasePropertyIndex;
+  const int mFind;
+};
+
 } // namespace anon
 
 namespace Dali
@@ -83,7 +106,14 @@ namespace Internal
 {
 
 TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::TypeInfo::CreateFunction creator)
-  : mTypeName(name), mBaseTypeName(baseTypeName), mCreate(creator)
+  : mTypeName(name), mBaseTypeName(baseTypeName), mCSharpType(false), mCreate(creator)
+{
+  DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
+  DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
+}
+
+TypeInfo::TypeInfo(const std::string &name, const std::string &baseTypeName, Dali::CSharpTypeInfo::CreateFunction creator)
+  : mTypeName(name), mBaseTypeName(baseTypeName), mCSharpType(true), mCSharpCreate(creator)
 {
   DALI_ASSERT_ALWAYS(!name.empty() && "Type info construction must have a name");
   DALI_ASSERT_ALWAYS(!baseTypeName.empty() && "Type info construction must have a base type name");
@@ -99,23 +129,32 @@ BaseHandle TypeInfo::CreateInstance() const
 
   if(mCreate)
   {
-    ret = mCreate();
+    if ( mCSharpType )
+    {
+      // CSharp currently only registers one create function for all custom controls
+      // it uses the type name to decide which one to create
+      ret = *mCSharpCreate( mTypeName.c_str() );
+    }
+    else
+    {
+      ret = mCreate();
+    }
 
     if ( ret )
     {
       BaseObject& handle = ret.GetBaseObject();
-      ProxyObject *proxyObject = dynamic_cast<Internal::ProxyObject*>(&handle);
+      Object *object = dynamic_cast<Internal::Object*>(&handle);
 
-      if ( proxyObject )
+      if ( object )
       {
-        proxyObject->SetTypeInfo( this );
+        object->SetTypeInfo( this );
       }
     }
   }
   return ret;
 }
 
-bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const std::vector<Property::Value> &properties)
+  bool TypeInfo::DoActionTo(BaseObject *object, const std::string &actionName, const Property::Map &properties)
 {
   bool done = false;
 
@@ -151,8 +190,8 @@ bool TypeInfo::ConnectSignal( BaseObject* object, ConnectionTrackerInterface* co
 {
   bool connected( false );
 
-  ConnectorContainerV2::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
-                                                 PairFinder<std::string, ConnectionPairV2>(signalName) );
+  ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
+                                                 PairFinder<std::string, ConnectionPair>(signalName) );
 
   if( iter != mSignalConnectors.end() )
   {
@@ -177,66 +216,96 @@ Dali::TypeInfo::CreateFunction TypeInfo::GetCreator() const
   return mCreate;
 }
 
-void TypeInfo::GetActions( Dali::TypeInfo::NameContainer& ret ) const
+size_t TypeInfo::GetActionCount() const
 {
-  for(ActionContainer::const_iterator iter = mActions.begin(); iter != mActions.end(); ++iter)
-  {
-    ret.push_back(iter->first);
-  }
+  size_t count = mActions.size();
 
   Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
   while( base )
   {
-    for(ActionContainer::const_iterator iter = GetImplementation(base).mActions.begin();
-        iter != GetImplementation(base).mActions.end(); ++iter)
-    {
-      ret.push_back(iter->first);
-    }
-
+    count += GetImplementation(base).mActions.size();
     base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
   }
+
+  return count;
 }
 
-void TypeInfo::GetSignals(Dali::TypeInfo::NameContainer& ret) const
+std::string TypeInfo::GetActionName(size_t index) const
 {
-  for(ConnectorContainerV2::const_iterator iter = mSignalConnectors.begin(); iter != mSignalConnectors.end(); ++iter)
+  std::string name;
+
+  if( index < mActions.size() )
   {
-    ret.push_back(iter->first);
+    name = mActions[index].first;
   }
-
-  Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
-  while( base )
+  else
   {
-    for(ConnectorContainerV2::const_iterator iter = GetImplementation(base).mSignalConnectors.begin();
-        iter != GetImplementation(base).mSignalConnectors.end(); ++iter)
+    size_t count = mActions.size();
+
+    Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
+    while( base )
     {
-      ret.push_back(iter->first);
-    }
+      size_t baseCount = GetImplementation(base).mActions.size();
 
-    base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+      if( index < count + baseCount )
+      {
+        name = GetImplementation(base).mActions[ index - count ].first;
+        break;
+      }
+
+      count += baseCount;
+
+      base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+    }
   }
+
+  return name;
 }
 
-void TypeInfo::GetProperties( Dali::TypeInfo::NameContainer& ret ) const
+size_t TypeInfo::GetSignalCount() const
 {
-  Property::IndexContainer indices;
+  size_t count = mSignalConnectors.size();
 
-  GetPropertyIndices(indices);
+  Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
+  while( base )
+  {
+    count += GetImplementation(base).mSignalConnectors.size();
+    base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
+  }
 
-  ret.reserve(indices.size());
+  return count;
+}
 
-  for(Property::IndexContainer::iterator iter = indices.begin(); iter != indices.end(); ++iter)
+std::string TypeInfo::GetSignalName(size_t index) const
+{
+  std::string name;
+
+  if( index < mSignalConnectors.size() )
   {
-    const std::string& name = GetPropertyName( *iter );
-    if(name.size())
-    {
-      ret.push_back( name );
-    }
-    else
+    name = mSignalConnectors[index].first;
+  }
+  else
+  {
+    size_t count = mSignalConnectors.size();
+
+    Dali::TypeInfo base = Dali::TypeRegistry::Get().GetTypeInfo( mBaseTypeName );
+    while( base )
     {
-      DALI_LOG_WARNING("Property had no name\n");
+      size_t baseCount = GetImplementation(base).mSignalConnectors.size();
+
+      if( index < count + baseCount )
+      {
+        name = GetImplementation(base).mSignalConnectors[ index - count ].first;
+        break;
+      }
+
+      count += baseCount;
+
+      base = Dali::TypeRegistry::Get().GetTypeInfo( base.GetBaseName() );
     }
   }
+
+  return name;
 }
 
 void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const
@@ -248,14 +317,34 @@ void TypeInfo::GetPropertyIndices( Property::IndexContainer& indices ) const
     baseImpl.GetPropertyIndices( indices );
   }
 
-  if ( ! mRegisteredProperties.empty() )
+  AppendProperties( indices, mRegisteredProperties );
+}
+
+void TypeInfo::GetChildPropertyIndices( Property::IndexContainer& indices ) const
+{
+  Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+  if ( base )
   {
-    indices.reserve( indices.size() + mRegisteredProperties.size() );
+    const TypeInfo& baseImpl( GetImplementation( base ) );
+    baseImpl.GetChildPropertyIndices( indices );
+  }
 
-    const RegisteredPropertyContainer::const_iterator endIter = mRegisteredProperties.end();
-    for ( RegisteredPropertyContainer::const_iterator iter = mRegisteredProperties.begin(); iter != endIter; ++iter )
+  AppendProperties( indices, mRegisteredChildProperties );
+}
+
+/**
+ * Append the indices in RegisteredProperties to the given index container.
+ */
+void TypeInfo::AppendProperties( Dali::Property::IndexContainer& indices,
+                                 const TypeInfo::RegisteredPropertyContainer& registeredProperties ) const
+{
+  if ( ! registeredProperties.empty() )
+  {
+    indices.Reserve( indices.Size() + registeredProperties.size() );
+
+    for( auto&& elem : registeredProperties )
     {
-      indices.push_back( iter->first );
+      indices.PushBack( elem.first );
     }
   }
 }
@@ -276,7 +365,7 @@ const std::string& TypeInfo::GetPropertyName( Property::Index index ) const
     return GetImplementation(base).GetPropertyName( index );
   }
 
-  DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as ProxyObject
+  DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
 }
 
 void TypeInfo::AddActionFunction( const std::string &actionName, Dali::TypeInfo::ActionFunction function )
@@ -296,12 +385,12 @@ void TypeInfo::AddActionFunction( const std::string &actionName, Dali::TypeInfo:
     }
     else
     {
-      DALI_LOG_WARNING("Action already exists in TypeRegistry Type", actionName.c_str());
+      DALI_LOG_WARNING("Action already exists in TypeRegistry Type\n", actionName.c_str());
     }
   }
 }
 
-void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunctionV2 function )
+void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeInfo::SignalConnectorFunction function )
 {
   if( NULL == function)
   {
@@ -309,16 +398,16 @@ void TypeInfo::AddConnectorFunction( const std::string& signalName, Dali::TypeIn
   }
   else
   {
-    ConnectorContainerV2::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
-                                                   PairFinder<std::string, ConnectionPairV2>(signalName) );
+    ConnectorContainer::iterator iter = find_if( mSignalConnectors.begin(), mSignalConnectors.end(),
+                                                   PairFinder<std::string, ConnectionPair>(signalName) );
 
     if( iter == mSignalConnectors.end() )
     {
-      mSignalConnectors.push_back( ConnectionPairV2( signalName, function ) );
+      mSignalConnectors.push_back( ConnectionPair( signalName, function ) );
     }
     else
     {
-      DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function", signalName.c_str());
+      DALI_LOG_WARNING("Signal name already exists in TypeRegistry Type for signal connector function\n", signalName.c_str());
     }
   }
 }
@@ -338,7 +427,7 @@ void TypeInfo::AddProperty( const std::string& name, Property::Index index, Prop
 
     if ( iter == mRegisteredProperties.end() )
     {
-      mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name ) ) );
+      mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
     }
     else
     {
@@ -347,15 +436,113 @@ void TypeInfo::AddProperty( const std::string& name, Property::Index index, Prop
   }
 }
 
-unsigned int TypeInfo::GetPropertyCount() const
+void TypeInfo::AddProperty( const std::string& name, Property::Index index, Property::Type type, Dali::CSharpTypeInfo::SetPropertyFunction setFunc, Dali::CSharpTypeInfo::GetPropertyFunction getFunc)
 {
-  unsigned int count( mRegisteredProperties.size() );
+
+  // The setter can be empty as a property can be read-only.
+
+  if ( NULL == getFunc )
+  {
+    DALI_ASSERT_ALWAYS( ! "GetProperty Function is empty" );
+  }
+  else
+  {
+    RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                          PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+
+    if ( iter == mRegisteredProperties.end() )
+    {
+      mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, setFunc, getFunc, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+    }
+    else
+    {
+      DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+    }
+  }
+
+}
+
+
+void TypeInfo::AddAnimatableProperty( const std::string& name, Property::Index index, Property::Type type )
+{
+  RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                        PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+
+  if ( iter == mRegisteredProperties.end() )
+  {
+    mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+  }
+  else
+  {
+    DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+  }
+}
+
+void TypeInfo::AddAnimatableProperty( const std::string& name, Property::Index index, const Property::Value& defaultValue )
+{
+  RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                        PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+
+  if ( iter == mRegisteredProperties.end() )
+  {
+    mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( defaultValue.GetType(), name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+    mPropertyDefaultValues.push_back( PropertyDefaultValuePair( index, defaultValue ) );
+  }
+  else
+  {
+    DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+  }
+}
+
+void TypeInfo::AddAnimatablePropertyComponent( const std::string& name, Property::Index index, Property::Index baseIndex, unsigned int componentIndex )
+{
+  Property::Type type = GetPropertyType( baseIndex );
+  DALI_ASSERT_ALWAYS( ( type == Property::VECTOR2 || type == Property::VECTOR3 || type == Property::VECTOR4 ) && "Base property does not support component" );
+
+  bool success = false;
+
+  RegisteredPropertyContainer::iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                        PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+
+  if ( iter == mRegisteredProperties.end() )
+  {
+    iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                    PropertyComponentFinder< RegisteredPropertyPair >( baseIndex, componentIndex ) );
+
+    if ( iter == mRegisteredProperties.end() )
+    {
+      mRegisteredProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, baseIndex, componentIndex ) ) );
+      success = true;
+    }
+  }
+
+  DALI_ASSERT_ALWAYS( success && "Property component already registered" );
+}
+
+void TypeInfo::AddChildProperty( const std::string& name, Property::Index index, Property::Type type )
+{
+  RegisteredPropertyContainer::iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
+                                                        PairFinder< Property::Index, RegisteredPropertyPair>(index) );
+
+  if ( iter == mRegisteredChildProperties.end() )
+  {
+    mRegisteredChildProperties.push_back( RegisteredPropertyPair( index, RegisteredProperty( type, name, Property::INVALID_INDEX, Property::INVALID_COMPONENT_INDEX ) ) );
+  }
+  else
+  {
+    DALI_ASSERT_ALWAYS( ! "Property index already added to Type" );
+  }
+}
+
+uint32_t TypeInfo::GetPropertyCount() const
+{
+  uint32_t count = static_cast<uint32_t>( mRegisteredProperties.size() );
 
   Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
   while ( base )
   {
     const TypeInfo& baseImpl( GetImplementation(base) );
-    count += baseImpl.mRegisteredProperties.size();
+    count += static_cast<uint32_t>( baseImpl.mRegisteredProperties.size() );
     base = TypeRegistry::Get()->GetTypeInfo( baseImpl.mBaseTypeName );
   }
 
@@ -386,6 +573,125 @@ Property::Index TypeInfo::GetPropertyIndex( const std::string& name ) const
   return index;
 }
 
+Property::Index TypeInfo::GetBasePropertyIndex( Property::Index index ) const
+{
+  Property::Index basePropertyIndex = Property::INVALID_INDEX;
+
+  RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                          PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+
+  if ( iter != mRegisteredProperties.end() )
+  {
+    basePropertyIndex = iter->second.basePropertyIndex;
+  }
+  else
+  {
+    Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+    if ( base )
+    {
+      basePropertyIndex = GetImplementation(base).GetBasePropertyIndex( index );
+    }
+  }
+
+  return basePropertyIndex;
+}
+
+int TypeInfo::GetComponentIndex( Property::Index index ) const
+{
+  int componentIndex = Property::INVALID_COMPONENT_INDEX;
+
+  RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
+                                                          PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+
+  if ( iter != mRegisteredProperties.end() )
+  {
+    componentIndex = iter->second.componentIndex;
+  }
+  else
+  {
+    Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+    if ( base )
+    {
+      componentIndex = GetImplementation(base).GetComponentIndex( index );
+    }
+  }
+
+  return componentIndex;
+}
+
+Property::Index TypeInfo::GetChildPropertyIndex( const std::string& name ) const
+{
+  Property::Index index = Property::INVALID_INDEX;
+
+  // Slow but should not be done that often
+  RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
+                                                          PropertyNameFinder< RegisteredPropertyPair >( name ) );
+
+  if ( iter != mRegisteredChildProperties.end() )
+  {
+    index = iter->first;
+  }
+  else
+  {
+    Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+    if ( base )
+    {
+      index = GetImplementation(base).GetChildPropertyIndex( name );
+    }
+  }
+
+  return index;
+}
+
+const std::string& TypeInfo::GetChildPropertyName( Property::Index index ) const
+{
+  RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
+                                                          PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+
+  if ( iter != mRegisteredChildProperties.end() )
+  {
+    return iter->second.name;
+  }
+
+  Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+  if ( base )
+  {
+    return GetImplementation(base).GetChildPropertyName( index );
+  }
+
+  DALI_LOG_WARNING("Cannot find property index");
+
+  static std::string emptyString;
+  return emptyString;
+}
+
+Property::Type TypeInfo::GetChildPropertyType( Property::Index index ) const
+{
+  Property::Type type( Property::NONE );
+
+  RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredChildProperties.begin(), mRegisteredChildProperties.end(),
+                                                          PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
+
+  if ( iter != mRegisteredChildProperties.end() )
+  {
+    type = iter->second.type;
+  }
+  else
+  {
+    Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
+    if ( base )
+    {
+      type = GetImplementation(base).GetChildPropertyType( index );
+    }
+    else
+    {
+      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
+    }
+  }
+
+  return type;
+}
+
 bool TypeInfo::IsPropertyWritable( Property::Index index ) const
 {
   bool writable( false );
@@ -395,7 +701,14 @@ bool TypeInfo::IsPropertyWritable( Property::Index index ) const
 
   if ( iter != mRegisteredProperties.end() )
   {
-    writable = iter->second.setFunc ? true : false;
+    if( ( index >= ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX ) && ( index <= ANIMATABLE_PROPERTY_REGISTRATION_MAX_INDEX ) )
+    {
+      writable = true; // animatable property is writable
+    }
+    else
+    {
+      writable = iter->second.setFunc ? true : false;
+    }
   }
   else
   {
@@ -406,7 +719,7 @@ bool TypeInfo::IsPropertyWritable( Property::Index index ) const
     }
     else
     {
-      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as ProxyObject
+      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
     }
   }
 
@@ -422,7 +735,15 @@ Property::Type TypeInfo::GetPropertyType( Property::Index index ) const
 
   if ( iter != mRegisteredProperties.end() )
   {
-    type = iter->second.type;
+    if( iter->second.componentIndex == Property::INVALID_COMPONENT_INDEX )
+    {
+      type = iter->second.type;
+    }
+    else
+    {
+      // If component index is set, then we should return FLOAT
+      type = Property::FLOAT;
+    }
   }
   else
   {
@@ -433,13 +754,27 @@ Property::Type TypeInfo::GetPropertyType( Property::Index index ) const
     }
     else
     {
-      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as ProxyObject
+      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
     }
   }
 
   return type;
 }
 
+Property::Value TypeInfo::GetPropertyDefaultValue( Property::Index index ) const
+{
+  PropertyDefaultValueContainer::const_iterator iter = find_if( mPropertyDefaultValues.begin(), mPropertyDefaultValues.end(),
+                                                    PairFinder< Property::Index, PropertyDefaultValuePair >( index ) );
+  if( iter !=  mPropertyDefaultValues.end() )
+  {
+    return iter->second;
+  }
+  else
+  {
+    return Property::Value( GetPropertyType( index ) );
+  }
+}
+
 void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Property::Value& value ) const
 {
   RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
@@ -448,7 +783,17 @@ void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Pro
   {
     if( iter->second.setFunc )
     {
-      iter->second.setFunc( object, index, value );
+      if( mCSharpType )
+      {
+        // CSharp wants a property name not an index
+        const std::string& name = (iter->second).name;
+
+        iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value) );
+      }
+      else
+      {
+        iter->second.setFunc( object, index, value );
+      }
     }
   }
   else
@@ -460,7 +805,7 @@ void TypeInfo::SetProperty( BaseObject *object, Property::Index index, const Pro
     }
     else
     {
-      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as ProxyObject
+      DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
     }
   }
 }
@@ -472,7 +817,16 @@ void TypeInfo::SetProperty( BaseObject *object, const std::string& name, const P
   if ( iter != mRegisteredProperties.end() )
   {
     DALI_ASSERT_ALWAYS( iter->second.setFunc && "Trying to write to a read-only property" );
-    iter->second.setFunc( object, iter->first, value );
+
+    if( mCSharpType )
+    {
+      // CSharp wants a property name not an index
+      iter->second.cSharpSetFunc( object,name.c_str(), const_cast< Property::Value* >(&value ));
+    }
+    else
+    {
+      iter->second.setFunc( object, iter->first, value );
+    }
   }
   else
   {
@@ -494,8 +848,21 @@ Property::Value TypeInfo::GetProperty( const BaseObject *object, Property::Index
                                                           PairFinder< Property::Index, RegisteredPropertyPair >( index ) );
   if( iter != mRegisteredProperties.end() )
   {
-    // Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
-    return iter->second.getFunc( const_cast< BaseObject* >( object ), index );
+    if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+    {
+      // CSharp wants a property name not an index
+      // CSharp callback can't return an object by value, it can only return a pointer
+      // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
+      const std::string& name = (iter->second).name;
+
+      return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str()) );
+
+    }
+    else
+    {
+      // Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
+      return iter->second.getFunc( const_cast< BaseObject* >( object ), index );
+    }
   }
 
   Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );
@@ -504,17 +871,31 @@ Property::Value TypeInfo::GetProperty( const BaseObject *object, Property::Index
     return GetImplementation( base ).GetProperty( object, index );
   }
 
-  DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as ProxyObject
+  DALI_ASSERT_ALWAYS( ! "Cannot find property index" ); // use the same assert as Object
 }
 
 Property::Value TypeInfo::GetProperty( const BaseObject *object, const std::string& name ) const
 {
   RegisteredPropertyContainer::const_iterator iter = find_if( mRegisteredProperties.begin(), mRegisteredProperties.end(),
-                                                          PropertyNameFinder< RegisteredPropertyPair >( name ) );
+                                                            PropertyNameFinder< RegisteredPropertyPair >( name ) );
+
+
+
   if( iter != mRegisteredProperties.end() )
   {
-    // Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
-    return iter->second.getFunc( const_cast< BaseObject* >( object ), iter->first );
+    if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
+    {
+       // CSharp wants a property name not an index
+       // CSharp callback can't return an object by value, it can only return a pointer
+       // CSharp has ownership of the pointer contents, which is fine because we are returning by from this function by value
+       return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), name.c_str() ));
+
+    }
+    else
+    {
+      // Need to remove the constness here as CustomActor will not be able to call Downcast with a const pointer to the object
+      return iter->second.getFunc( const_cast< BaseObject* >( object ), iter->first );
+    }
   }
 
   Dali::TypeInfo base = TypeRegistry::Get()->GetTypeInfo( mBaseTypeName );