static bool CreateCustomNamedInitCalled = false;
-BaseHandle* CreateCustomNamedInit(void)
+
+
+BaseHandle* CreateCustomNamedInit(const char* const typeName )
{
CreateCustomNamedInitCalled = true;
bool setPropertyCalled = false;
bool getPropertyCalled = false;
int intPropertyValue = 0;
-void SetProperty( BaseObject* object, Property::Index* index, Property::Value* value )
+
+void SetProperty( BaseObject* object, const char* const propertyName , Property::Value* value )
{
value->Get( intPropertyValue );
setPropertyCalled = true;
}
-Property::Value* GetProperty( BaseObject* object, Property::Index* index )
+
+Property::Value* GetProperty( BaseObject* object, const char* const propertyName )
{
getPropertyCalled = true;
Property::Value* x = new Property::Value( 10 );
TestApplication application;
- CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit );
- GetImplementation(Dali::TypeRegistry::Get()).CallInitFunctions();
+ Dali::TypeInfo info = Dali::TypeRegistry::Get().GetTypeInfo( "CSharpControl" );
+
+ info.CreateInstance();
DALI_TEST_EQUALS( CreateCustomNamedInitCalled, true, TEST_LOCATION );
{
TestApplication application;
+
CreateCustomNamedInitCalled = false;
- CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit, false);
+ CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit );
GetImplementation(Dali::TypeRegistry::Get()).CallInitFunctions();
{
TestApplication application;
- CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit );
// should cause an assert because we're registering same type twice
try
{
- CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit );
tet_result( TET_FAIL );
}
catch ( DaliException& e )
TestApplication application;
CreateCustomNamedInitCalled = false;
- CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit, false);
+ CSharpTypeRegistry::RegisterType( "CSharpControl", typeid( Dali::Actor), &CreateCustomNamedInit );
TypeInfo info = Dali::TypeRegistry::Get().GetTypeInfo( "CSharpControl");
-
-
BaseHandle handle = info.CreateInstance();
DALI_TEST_EQUALS( CreateCustomNamedInitCalled, true, TEST_LOCATION );
{
TestApplication application;
- CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit );
bool registered = CSharpTypeRegistry::RegisterProperty( "DateControl",
TestApplication application;
// register the same property twice
- CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit );
bool registered = CSharpTypeRegistry::RegisterProperty( "DateControl",
TestApplication application;
// register the same property twice
- CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit );;
Property::Index index(100001);
TestApplication application;
// register the same property twice
- CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit, true );
+ CSharpTypeRegistry::RegisterType( "DateControl", typeid( Dali::Actor), &CreateCustomNamedInit );
Property::Index index(100001);
namespace CSharpTypeInfo
{
- typedef BaseHandle* (*CreateFunction)(); ///< Function signature for creating an instance of the associated object type
+ /**
+ * @brief Call back used to create an instance of the associated object type
+ *
+ * @param[in] typeName The type name of the object to be created.
+ * @return Pointer to a BaseHandle
+ */
+ typedef BaseHandle* (*CreateFunction)(const char* const typeName);
/**
* @brief Callback to set an event-thread only property.
*
* @param[in] object The object whose property should be set.
- * @param[in] index The index of the property being set.
+ * @param[in] propertyName The name of the property required.
* @param[in] value The new value of the property for the object specified.
* @see PropertyRegistration.
*/
- typedef void (*SetPropertyFunction)( BaseObject* object, Property::Index* index, Property::Value* value );
+ typedef void (*SetPropertyFunction)( BaseObject* object, const char* const propertyName , Property::Value* value );
/**
* @brief Callback to get the value of an event-thread only property.
*
* @param[in] object The object whose property value is required.
- * @param[in] index The index of the property required.
+ * @param[in] propertyName The name of the property required.
* @return The current value of the property for the object specified.
* @see PropertyRegistration.
*/
- typedef Property::Value* (*GetPropertyFunction)( BaseObject* object, Property::Index* index );
+ typedef Property::Value* (*GetPropertyFunction)( BaseObject* object, const char* const propertyName );
}
namespace CSharpTypeRegistry
{
-bool RegisterType( const std::string& name, const std::type_info& baseType, CSharpTypeInfo::CreateFunction f, bool callCreateOnInit )
+bool RegisterType( const std::string& name, const std::type_info& baseType, CSharpTypeInfo::CreateFunction f )
{
Internal::TypeRegistry *impl = Internal::TypeRegistry::Get();
- return impl->Register( name, baseType, f, callCreateOnInit );
+ return impl->Register( name, baseType, f );
}
bool RegisterProperty( const std::string& objectName,
* @param [in] name the name of the type to be registered
* @param [in] baseType the base type info of registerType
* @param [in] f registerType instance creation function
- * @param [in] callCreateOnInit If true the creation function is called as part of Dali initialisation
* @return true if the name could be registered.
*/
DALI_IMPORT_API bool RegisterType( const std::string& name,
const std::type_info& baseType,
- CSharpTypeInfo::CreateFunction f,
- bool callCreateOnInit );
+ CSharpTypeInfo::CreateFunction f );
/**
* Register an event-thread only property with a type (used by C# Custom controls)
{
if ( mCSharpType )
{
- ret = *mCSharpCreate();
+ // 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
{
{
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
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
{
{
if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
{
- // CSharp can't return any object by value, it can return pointers.
- // CSharp has ownership of the pointer contents, which is fine because we are returning by value
- int index = (iter->first );
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), &index ));
+ // 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
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() )
{
if( mCSharpType ) // using csharp property get which returns a pointer to a Property::Value
{
- // CSharp can't return any object by value, it can return pointers.
- // CSharp has ownership of the pointer contents, which is fine because we are returning by value
- int index = (iter->first );
- return *( iter->second.cSharpGetFunc( const_cast< BaseObject* >( object ), &index ));
+ // 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
}
bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
- Dali::CSharpTypeInfo::CreateFunction createInstance, bool callCreateOnInit )
+ Dali::CSharpTypeInfo::CreateFunction createInstance )
{
bool ret = false;
DALI_LOG_WARNING("Duplicate name for TypeRegistry for '%s'\n", + uniqueTypeName.c_str());
DALI_ASSERT_ALWAYS(!"Duplicate type name for Type Registation");
}
- if( callCreateOnInit )
- {
- mCSharpInitFunctions.push_back(createInstance);
- }
+
return ret;
}
{
(*iter)();
}
- for( CSharpInitFunctions::const_iterator iter = mCSharpInitFunctions.begin(); iter != mCSharpInitFunctions.end(); ++iter)
- {
- (*iter)();
- }
}
std::string TypeRegistry::RegistrationName( const std::type_info& registerType )
* @param [in] name The name type to be registered (must be unique)
* @param [in] baseTypeInfo Type info for its base class
* @param [in] createInstance Instance creation function
- * @param [in] callCreateOnInit If true call createInstance on dali initialisation
* @return true if the name could be registered.
*/
bool Register( const std::string& name, const std::type_info& baseTypeInfo,
- Dali::CSharpTypeInfo::CreateFunction createInstance, bool callCreateOnInit );
+ Dali::CSharpTypeInfo::CreateFunction createInstance );
/*
* Register a signal connector function to a type
typedef std::vector<Dali::TypeInfo::CreateFunction> InitFunctions;
InitFunctions mInitFunctions;
- typedef std::vector<Dali::CSharpTypeInfo::CreateFunction> CSharpInitFunctions;
- CSharpInitFunctions mCSharpInitFunctions;
-
private:
TypeRegistry();
~TypeRegistry();