Ejemplo n.º 1
0
// PopulateStringHelper
//------------------------------------------------------------------------------
bool Function::PopulateStringHelper( const BFFIterator & iter, const Meta_Path * pathMD, const Meta_File * fileMD, const BFFVariable * variable, const AString & string, Array< AString > & outStrings ) const
{
	// Full paths to files can support aliases
	if ( fileMD && ( !fileMD->IsRelative() ) )
	{
		// Is it an Alias?
		Node * node = FBuild::Get().GetDependencyGraph().FindNode( string );
		if ( node && ( node->GetType() == Node::ALIAS_NODE ) )
		{
			AliasNode * aliasNode = node->CastTo< AliasNode >();
			for ( const auto& aliasedNode : aliasNode->GetAliasedNodes() )
			{
				if ( !PopulateStringHelper( iter, pathMD, fileMD, variable, aliasedNode.GetNode()->GetName(), outStrings ) )
				{
					return false; // PopulateStringHelper will have emitted an error
				}
			}
			return true;
		}

		// Not an alias - fall through to normal handling
	}

	AStackString<> stringToFix( string );
	if ( !PopulatePathAndFileHelper( iter, pathMD, fileMD, variable->GetName(), stringToFix ) )
	{
		return false; // PopulatePathAndFileHelper will have emitted an error
	}
	outStrings.Append( stringToFix );
	return true;
}
Ejemplo n.º 2
0
bool Function::PopulateString( const BFFIterator & iter, Node * node, const ReflectedProperty & property, const BFFVariable * variable ) const
{
	if ( variable->IsString() )
	{
		// Handle empty strings
		if ( variable->GetString().IsEmpty() )
		{
			Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() );
			return false;
		}

		AStackString<> string( variable->GetString() );

		// Path/File fixup needed?
		if ( !PopulatePathAndFileHelper( iter,
											property.HasMetaData< Meta_Path >(), 
											property.HasMetaData< Meta_File >(), 
											variable->GetName(),
											variable->GetString(),
											string ) )
		{
			return false;
		}

		// String to String
		property.SetProperty( node, string );
		return true;
	}

	Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING );
	return false;
}
Ejemplo n.º 3
0
bool Function::GetNameForNode( const BFFIterator & iter, const ReflectionInfo * ri, AString & name ) const
{
	// get object MetaData
	const Meta_Name * nameMD = ri->HasMetaData< Meta_Name >();
	ASSERT( nameMD ); // should not call this on types without this MetaData

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

	// Find the value for this property from the BFF
	const BFFVariable * variable = BFFStackFrame::GetVar( propertyName );
	if ( variable->IsString() )
	{
		// Handle empty strings
		if ( variable->GetString().IsEmpty() )
		{
			Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() );
			return false;
		}

		AStackString<> string( variable->GetString() );

		// Path/File fixup needed?
		if ( !PopulatePathAndFileHelper( iter,
										 ri->HasMetaData< Meta_Path >(), 
										 ri->HasMetaData< Meta_File >(), 
										 variable->GetName(),
										 variable->GetString(),
										 string ) )
		{
			return false;
		}

		// Check that name isn't already used
		NodeGraph & ng = FBuild::Get().GetDependencyGraph();
		if ( ng.FindNode( string ) )
		{
			Error::Error_1100_AlreadyDefined( iter, this, string );
			return false;
		}

		name = string;
		return true;
	}

	Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING );
	return false;
}
Ejemplo n.º 4
0
bool Function::PopulateArrayOfStrings( const BFFIterator & iter, Node * node, const ReflectedProperty & property, const BFFVariable * variable ) const
{
	// Array to Array
	if ( variable->IsArrayOfStrings() )
	{
		Array< AString > strings( variable->GetArrayOfStrings() );

		Array< AString >::Iter end = strings.End();
		for ( Array< AString >::Iter it = strings.Begin();
				it != end;
				++it )
		{
			AString & string = *it;

			// Path/File fixup needed?
			if ( !PopulatePathAndFileHelper( iter,
											 property.HasMetaData< Meta_Path >(), 
											 property.HasMetaData< Meta_File >(), 
											 variable->GetName(),
											 variable->GetArrayOfStrings()[ it - strings.Begin() ],
											 string ) )
			{
				return false;
			}
		}

		property.SetProperty( node, strings );
		return true;
	}

	if ( variable->IsString() )
	{
		// Handle empty strings
		if ( variable->GetString().IsEmpty() )
		{
			Error::Error_1004_EmptyStringPropertyNotAllowed( iter, this, variable->GetName().Get() );
			return false;
		}

		AStackString<> string( variable->GetString() );

		// Path/File fixup needed?
		if ( !PopulatePathAndFileHelper( iter, 
										 property.HasMetaData< Meta_Path >(), 
										 property.HasMetaData< Meta_File >(), 
										 variable->GetName(),
										 variable->GetString(),
										 string ) )
		{
			return false;
		}

		// Make array with 1 string
		Array< AString > strings( 1, false );
		strings.Append( string );
		property.SetProperty( node, strings );
		return true;
	}

	Error::Error_1050_PropertyMustBeOfType( iter, this, variable->GetName().Get(), variable->GetType(), BFFVariable::VAR_STRING, BFFVariable::VAR_ARRAY_OF_STRINGS );
	return false;
}