int UtcDaliAnyGetType(void)
{
  TestApplication application;

  tet_infoline("Test GetType().");

  Any value;

  DALI_TEST_CHECK( typeid( void ) == value.GetType() );

  value = 5.f;

  DALI_TEST_CHECK( typeid( float ) == value.GetType() );
  END_TEST;
}
int UtcDaliAnyConstructors(void)
{
  TestApplication application;

  tet_infoline("Test Any constructors.");

  // Test default constructor.
  Any value;

  DALI_TEST_CHECK( typeid( void ) == value.GetType() );

  // Test constructor Any( const Type& )
  Any value1 = 4u;

  // Test constructor Any( const Any& )
  Any value2 = value1;

  // Test constructor Any( const Any& ) with a non initialized Any
  Any value3 = value;

  DALI_TEST_CHECK( typeid( unsigned int ) == value1.GetType() );
  DALI_TEST_CHECK( typeid( unsigned int ) == value2.GetType() );
  DALI_TEST_CHECK( typeid( void ) == value3.GetType() );

  unsigned int uiValue1 = 0u;
  unsigned int uiValue2 = 0u;
  value1.Get( uiValue1 );
  value2.Get( uiValue2 );

  DALI_TEST_EQUALS( uiValue1, uiValue2, TEST_LOCATION );
  END_TEST;
}
Esempio n. 3
0
bool FabricState::Set(Field field, ref<Scriptable> value) {
	ref<FabricEngine> fe = _fe;
	if(fe) {
		ThreadLock lock(&_lock);
		if(value.IsCastableTo<ScriptAny>()) {
			Any previousValue = fe->_state->GetValue(field);
			Any val = ref<ScriptAny>(value)->Unbox();
			
			// Retain value type if previous type was not null
			if(previousValue.GetType()!=Any::TypeNull) {
				val = val.Force(previousValue.GetType());
			}
			fe->_state->SetValue(field, val);
			_shouldCommit = true;
			return true;
		}
	}
	return false;
}
Esempio n. 4
0
unsigned int EcoreXRenderSurface::GetSurfaceId( Any surface ) const
{
  unsigned int surfaceId = 0;

  if ( surface.Empty() == false )
  {
    // check we have a valid type
    DALI_ASSERT_ALWAYS( ( (surface.GetType() == typeid (XWindow) ) ||
                          (surface.GetType() == typeid (Ecore_X_Window) ) )
                        && "Surface type is invalid" );

    if ( surface.GetType() == typeid (Ecore_X_Window) )
    {
      surfaceId = AnyCast<Ecore_X_Window>( surface );
    }
    else
    {
      surfaceId = AnyCast<XWindow>( surface );
    }
  }
  return surfaceId;
}
tbm_surface_h NativeImageSource::GetSurfaceFromAny( Any source ) const
{
  if( source.Empty() )
  {
    return NULL;
  }

  if( source.GetType() == typeid( tbm_surface_h ) )
  {
    return AnyCast< tbm_surface_h >( source );
  }
  else
  {
    return NULL;
  }
}