LLVM/Emscripten fixes
[platform/core/uifw/dali-core.git] / dali / internal / event / common / proxy-object.cpp
index 7a65d44..98910f5 100644 (file)
@@ -1,18 +1,19 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
 #include <dali/internal/event/common/proxy-object.h>
@@ -129,7 +130,7 @@ unsigned int ProxyObject::GetPropertyCount() const
 
   DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Default Properties: %d\n", count );
 
-  TypeInfo* typeInfo( GetTypeInfo() );
+  const TypeInfo* typeInfo( GetTypeInfo() );
   if ( typeInfo )
   {
     unsigned int manual( typeInfo->GetPropertyCount() );
@@ -162,7 +163,7 @@ const std::string& ProxyObject::GetPropertyName( Property::Index index ) const
 
   if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       return typeInfo->GetPropertyName( index );
@@ -189,7 +190,7 @@ Property::Index ProxyObject::GetPropertyIndex(const std::string& name) const
 
   if ( index == Property::INVALID_INDEX )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       index = typeInfo->GetPropertyIndex( name );
@@ -223,7 +224,7 @@ bool ProxyObject::IsPropertyWritable( Property::Index index ) const
 
   if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       return typeInfo->IsPropertyWritable( index );
@@ -309,7 +310,7 @@ Property::Type ProxyObject::GetPropertyType( Property::Index index ) const
 
   if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       return typeInfo->GetPropertyType( index );
@@ -342,7 +343,7 @@ void ProxyObject::SetProperty( Property::Index index, const Property::Value& pro
   }
   else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       typeInfo->SetProperty( this, index, propertyValue );
@@ -380,7 +381,7 @@ Property::Value ProxyObject::GetProperty(Property::Index index) const
   }
   else if ( ( index >= PROPERTY_REGISTRATION_START_INDEX ) && ( index <= PROPERTY_REGISTRATION_MAX_INDEX ) )
   {
-    TypeInfo* typeInfo( GetTypeInfo() );
+    const TypeInfo* typeInfo( GetTypeInfo() );
     if ( typeInfo )
     {
       value = typeInfo->GetProperty( this, index );
@@ -423,6 +424,15 @@ Property::Value ProxyObject::GetProperty(Property::Index index) const
           break;
         }
 
+        case Property::INTEGER:
+        {
+          AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry->second.GetSceneGraphProperty() );
+          DALI_ASSERT_DEBUG( NULL != property );
+
+          value = (*property)[ bufferIndex ];
+          break;
+        }
+
         case Property::VECTOR2:
         {
           AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry->second.GetSceneGraphProperty() );
@@ -498,7 +508,7 @@ void ProxyObject::GetPropertyIndices( Property::IndexContainer& indices ) const
   GetDefaultPropertyIndices( indices );
 
   // Manual Properties
-  TypeInfo* typeInfo( GetTypeInfo() );
+  const TypeInfo* typeInfo( GetTypeInfo() );
   if ( typeInfo )
   {
     typeInfo->GetPropertyIndices( indices );
@@ -539,6 +549,12 @@ Property::Index ProxyObject::RegisterProperty( std::string name, const Property:
       break;
     }
 
+    case Property::INTEGER:
+    {
+      newProperty.reset(new AnimatableProperty<int>( propertyValue.Get<int>()));
+      break;
+    }
+
     case Property::VECTOR2:
     {
       newProperty.reset(new AnimatableProperty<Vector2>( propertyValue.Get<Vector2>()));
@@ -810,6 +826,16 @@ void ProxyObject::SetCustomProperty( Property::Index index, const CustomProperty
       break;
     }
 
+    case Property::INTEGER:
+    {
+      AnimatableProperty<int>* property = dynamic_cast< AnimatableProperty<int>* >( entry.GetSceneGraphProperty() );
+      DALI_ASSERT_DEBUG( NULL != property );
+
+      // property is being used in a separate thread; queue a message to set the property
+      BakeMessage<int>( Stage::GetCurrent()->GetUpdateInterface(), *property, value.Get<int>() );
+      break;
+    }
+
     case Property::VECTOR2:
     {
       AnimatableProperty<Vector2>* property = dynamic_cast< AnimatableProperty<Vector2>* >( entry.GetSceneGraphProperty() );
@@ -888,7 +914,7 @@ CustomPropertyLookup& ProxyObject::GetCustomPropertyLookup() const
   return *mCustomProperties;
 }
 
-TypeInfo* ProxyObject::GetTypeInfo() const
+const TypeInfo* ProxyObject::GetTypeInfo() const
 {
   if ( !mTypeInfo )
   {
@@ -907,31 +933,35 @@ TypeInfo* ProxyObject::GetTypeInfo() const
 
 void ProxyObject::RemoveConstraint( ActiveConstraint& constraint, bool isInScenegraph )
 {
-  if( isInScenegraph )
+  // guard against constraint sending messages during core destruction
+  if ( Stage::IsInstalled() )
   {
-    ActiveConstraintBase& baseConstraint = GetImplementation( constraint );
-    baseConstraint.BeginRemove();
-    if ( baseConstraint.IsRemoving() )
+    if( isInScenegraph )
     {
-      if( !mRemovedConstraints )
+      ActiveConstraintBase& baseConstraint = GetImplementation( constraint );
+      baseConstraint.BeginRemove();
+      if ( baseConstraint.IsRemoving() )
       {
-        mRemovedConstraints = new ActiveConstraintContainer;
+        if( !mRemovedConstraints )
+        {
+          mRemovedConstraints = new ActiveConstraintContainer;
+        }
+        // Wait for remove animation before destroying active-constraints
+        mRemovedConstraints->push_back( constraint );
       }
-      // Wait for remove animation before destroying active-constraints
-      mRemovedConstraints->push_back( constraint );
     }
-  }
-  else if( mRemovedConstraints )
-  {
-    delete mRemovedConstraints;
-    mRemovedConstraints = NULL;
+    else if( mRemovedConstraints )
+    {
+      delete mRemovedConstraints;
+      mRemovedConstraints = NULL;
+    }
   }
 }
 
-
 void ProxyObject::RemoveConstraint( Dali::ActiveConstraint activeConstraint )
 {
-  if( mConstraints )
+  // guard against constraint sending messages during core destruction
+  if( mConstraints && Stage::IsInstalled() )
   {
     bool isInSceneGraph( NULL != GetSceneObject() );
     if( isInSceneGraph )
@@ -946,14 +976,12 @@ void ProxyObject::RemoveConstraint( Dali::ActiveConstraint activeConstraint )
       mConstraints->erase( it );
     }
   }
-
 }
 
-
-
 void ProxyObject::RemoveConstraints( unsigned int tag )
 {
-  if( mConstraints )
+  // guard against constraint sending messages during core destruction
+  if( mConstraints && Stage::IsInstalled() )
   {
     bool isInSceneGraph( NULL != GetSceneObject() );
     if( isInSceneGraph )
@@ -980,7 +1008,8 @@ void ProxyObject::RemoveConstraints( unsigned int tag )
 
 void ProxyObject::RemoveConstraints()
 {
-  if( mConstraints )
+  // guard against constraint sending messages during core destruction
+  if( mConstraints && Stage::IsInstalled() )
   {
     // If we have nothing in the scene-graph, just clear constraint containers
     const SceneGraph::PropertyOwner* propertyOwner = GetSceneObject();
@@ -1006,7 +1035,7 @@ void ProxyObject::RemoveConstraints()
   }
 }
 
-void ProxyObject::SetTypeInfo( TypeInfo* typeInfo )
+void ProxyObject::SetTypeInfo( const TypeInfo* typeInfo )
 {
   mTypeInfo = typeInfo;
 }