Exemple #1
0
// PopulateProperty
//------------------------------------------------------------------------------
bool Function::PopulateProperty( NodeGraph & nodeGraph,
								 const BFFIterator & iter,
								 void * base,
								 const ReflectedProperty & property,
								 const BFFVariable * variable ) const
{
	// Handle missing but required
	if ( variable == nullptr )
	{
		const bool required = ( property.HasMetaData< Meta_Optional >() == nullptr );
		if ( required )
		{
			Error::Error_1101_MissingProperty( iter, this, AStackString<>( property.GetName() ) );
			return false;
		}

		return true; // missing but not required
	}

	const PropertyType pt = property.GetType();
	switch ( pt )
	{
		case PT_ASTRING:
		{
			if ( property.IsArray() )
			{
				return PopulateArrayOfStrings( nodeGraph, iter, base, property, variable );
			}
			else
			{
				return PopulateString( nodeGraph, iter, base, property, variable );
			}
		}
		case PT_BOOL:
		{
			return PopulateBool( iter, base, property, variable );
		}
		case PT_UINT32:
		{
			return PopulateUInt32( iter, base, property, variable );
		}
		case PT_STRUCT:
		{
			if ( property.IsArray() )
			{
				return PopulateArrayOfStructs( nodeGraph, iter, base, property, variable );
			}
		}
		default:
		{
            break;
		}
	}
	ASSERT( false ); // Unsupported type
	return false;
}
Exemple #2
0
bool Function::PopulateProperties( const BFFIterator & iter, Node * node ) const
{
	const ReflectionInfo * const ri = node->GetReflectionInfoV();
	const ReflectionIter end = ri->End();
	for ( ReflectionIter it = ri->Begin(); it != end; ++it )
	{
		const ReflectedProperty & property = *it;

		// Format "Name" as ".Name" - TODO:C Would be good to eliminate this string copy
		AStackString<> propertyName( "." );
		propertyName += property.GetName();

		// Find the value for this property from the BFF
		const BFFVariable * v = BFFStackFrame::GetVar( propertyName );

		// Handle missing but required
		if ( v == nullptr )
		{
			const bool required = ( property.HasMetaData< Meta_Optional >() == nullptr );
			if ( required )
			{
				Error::Error_1101_MissingProperty( iter, this, propertyName );
				return false;
			}

			continue; // missing but not required
		}

		const PropertyType pt = property.GetType();
		switch ( pt )
		{
			case PT_ASTRING:
			{
				if ( property.IsArray() )
				{
					if ( !PopulateArrayOfStrings( iter, node, property, v ) )
					{
						return false;
					}
				}
				else
				{
					if ( !PopulateString( iter, node, property, v ) )
					{
						return false;
					}
				}
				break;
			}
			case PT_BOOL:
			{
				if ( !PopulateBool( iter, node, property, v ) )
				{
					return false;
				}
				break;
			}
			case PT_UINT32:
			{
				if ( !PopulateUInt32( iter, node, property, v ) )
				{
					return false;
				}
				break;
			}
			default:
			{
				ASSERT( false ); // Unsupported type
				break;
			}
		}
	}
	return true;
}