Add devel API to link an object (e.g. C# custom control) with its correct type-info 05/114505/2
authorRichard Huang <r.huang@samsung.com>
Mon, 13 Feb 2017 13:46:01 +0000 (13:46 +0000)
committerRichard Huang <r.huang@samsung.com>
Tue, 14 Feb 2017 11:35:12 +0000 (11:35 +0000)
Change-Id: I51407eab027b7a73d781b20d15f850ee40d05e92

automated-tests/src/dali/utc-Dali-Handle.cpp
dali/devel-api/object/handle-devel.cpp
dali/devel-api/object/handle-devel.h

index f06d9ab..464f504 100644 (file)
@@ -897,3 +897,27 @@ int UtcDaliHandleWeightNew(void)
 
   END_TEST;
 }
+
+int UtcDaliHandleSetTypeInfo(void)
+{
+  TestApplication application;
+  TypeRegistry typeRegistry = TypeRegistry::Get();
+
+  TypeInfo typeInfo = typeRegistry.GetTypeInfo( "Actor" );
+  DALI_TEST_CHECK( typeInfo );
+
+  Actor actor = Actor::DownCast(typeInfo.CreateInstance());
+  DALI_TEST_CHECK( actor );
+
+  DevelHandle::SetTypeInfo(actor, typeInfo);
+
+  TypeInfo newTypeInfo;
+  bool success = actor.GetTypeInfo( newTypeInfo );
+  DALI_TEST_CHECK( success );
+
+  DALI_TEST_CHECK(typeInfo.GetName() == newTypeInfo.GetName());
+  DALI_TEST_CHECK(typeInfo.GetBaseName() == newTypeInfo.GetBaseName());
+
+  END_TEST;
+}
+
index f1057fe..16a254e 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/public-api/object/property-key.h>
 #include <dali/internal/event/common/object-impl.h>
+#include <dali/internal/event/common/type-info-impl.h>
 
 namespace Dali
 {
@@ -43,6 +44,11 @@ Property::Index RegisterProperty( Handle handle, Property::Index key, const std:
   return GetImplementation( handle ).RegisterProperty( name, key, propertyValue );
 }
 
+void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo )
+{
+  GetImplementation( handle ).SetTypeInfo( &GetImplementation( typeInfo ) );
+}
+
 } // namespace DevelHandle
 
 } // namespace Dali
index 5a54a3d..1e7f20a 100644 (file)
@@ -98,6 +98,16 @@ DALI_IMPORT_API Property::Index GetPropertyIndex( const Handle& handle, Property
  */
 DALI_IMPORT_API Property::Index RegisterProperty( Handle handle, Property::Index key, const std::string& name, const Property::Value& propertyValue );
 
+/**
+ * @brief Set the type-info that the object is created by.
+ *
+ * @note This is particularly useful to link C# custom control with its correct type-info in the native side
+ *
+ * @param[in] handle The handle created by this TypeInfo.
+ * @param[in] typeInfo The TypeInfo that creates the handle.
+ */
+DALI_IMPORT_API void SetTypeInfo( Handle& handle, const TypeInfo& typeInfo );
+
 } // namespace DevelHandle
 
 } // namespace Dali