Ejemplo n.º 1
0
void
InputParameters::checkParams(const std::string &prefix)
{
  std::string l_prefix = this->have_parameter<std::string>("long_name") ? this->get<std::string>("long_name") : prefix;

  std::ostringstream oss;
  // Required parameters
  for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it)
  {
    if (!isParamValid(it->first) && isParamRequired(it->first))
    {
      // The parameter is required but missing
      if (oss.str().empty())
        oss << "The following required parameters are missing:" << std::endl;
      oss << l_prefix << "/" << it->first << std::endl;
      oss << "\tDoc String: \"" + getDocString(it->first) + "\"" << std::endl;
    }
  }

  // Range checked parameters
  for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it)
  {
    std::string long_name(l_prefix + "/" + it->first);

    dynamicCastRangeCheck(Real, Real,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(int,  long,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(long, long,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(unsigned int, long, long_name, it->first, it->second, oss);
  }

  if (!oss.str().empty())
    mooseError(oss.str());
}
Ejemplo n.º 2
0
void
InputParameters::checkParams(const std::string & parsing_syntax)
{
  std::string l_prefix = this->have_parameter<std::string>("_object_name") ? this->get<std::string>("_object_name") : parsing_syntax;

  std::ostringstream oss;
  // Required parameters
  for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it)
  {
    if (!isParamValid(it->first) && isParamRequired(it->first))
    {
      // The parameter is required but missing
      if (oss.str().empty())
        oss << "The following required parameters are missing:" << std::endl;
      oss << l_prefix << "/" << it->first << std::endl;
      oss << "\tDoc String: \"" + getDocString(it->first) + "\"" << std::endl;
    }
  }

  // Range checked parameters
  for (InputParameters::const_iterator it = this->begin(); it != this->end(); ++it)
  {
    std::string long_name(l_prefix + "/" + it->first);

    dynamicCastRangeCheck(Real, Real,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(int,  long,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(long, long,         long_name, it->first, it->second, oss);
    dynamicCastRangeCheck(unsigned int, long, long_name, it->first, it->second, oss);
  }

  if (!oss.str().empty())
    mooseError(oss.str());

  // Controllable parameters
  for (std::set<std::string>::const_iterator it = _controllable_params.begin(); it != _controllable_params.end(); ++it)
  {
    // Check that parameter is valid
    if (!isParamValid(*it))
      mooseError("The parameter '" << *it << "' is not a valid parameter for the object " << l_prefix << " thus cannot be marked as controllable.");

    if (isPrivate(*it))
      mooseError("The parameter, '" << *it << "', in " << l_prefix << " is a private parameter and cannot be marked as controllable");

    checkMooseType(NonlinearVariableName, *it);
    checkMooseType(AuxVariableName, *it);
    checkMooseType(VariableName, *it);
    checkMooseType(BoundaryName, *it);
    checkMooseType(SubdomainName, *it);
    checkMooseType(PostprocessorName, *it);
    checkMooseType(VectorPostprocessorName, *it);
    checkMooseType(UserObjectName, *it);
    checkMooseType(MaterialPropertyName, *it);
  }
}
Ejemplo n.º 3
0
static void exportScope( const EngineExportScope* scope, SimXMLDocument* xml, bool addNode )
{
   if( addNode )
   {
      if( isExportFiltered( scope ) )
         return;
         
      xml->pushNewElement( "EngineExportScope" );
      
         xml->setAttribute( "name", scope->getExportName() );
         xml->setAttribute( "docs", getDocString( scope ) );
   }

   // Dump all contained exports.
   
   xml->pushNewElement( "exports" );
   
      for( const EngineExport* exportInfo = scope->getExports(); exportInfo != NULL; exportInfo = exportInfo->getNextExport() )
      {
         switch( exportInfo->getExportKind() )
         {
            case EngineExportKindScope:
               exportScope( static_cast< const EngineExportScope* >( exportInfo ), xml, true );
               break;
               
            case EngineExportKindFunction:
               exportFunction( static_cast< const EngineFunctionInfo* >( exportInfo ), xml );
               break;
               
            case EngineExportKindType:
               exportType( static_cast< const EngineTypeInfo* >( exportInfo ), xml );
               break;
               
            default:
               break;
         }
      }
      
   xml->popElement();
   
   if( addNode )
      xml->popElement();
}
Ejemplo n.º 4
0
static void exportType( const EngineTypeInfo* type, SimXMLDocument* xml )
{
   // Don't export anonymous types.
   if( !type->getTypeName()[ 0 ] )
      return;
      
   if( isExportFiltered( type ) )
      return;
      
   const char* nodeName = NULL;
   switch( type->getTypeKind() )
   {
      case EngineTypeKindPrimitive:
         nodeName = "EnginePrimitiveType";
         break;
         
      case EngineTypeKindEnum:
         nodeName = "EngineEnumType";
         break;
         
      case EngineTypeKindBitfield:
         nodeName = "EngineBitfieldType";
         break;
         
      case EngineTypeKindStruct:
         nodeName = "EngineStructType";
         break;
         
      case EngineTypeKindClass:
         nodeName = "EngineClassType";
         break;
      
      default:
         return;
   }
   
   xml->pushNewElement( nodeName );

      xml->setAttribute( "name", type->getTypeName() );
      xml->setAttribute( "size", String::ToString( type->getInstanceSize() ) );
      xml->setAttribute( "isAbstract", type->isAbstract() ? "1" : "0" );
      xml->setAttribute( "isInstantiable", type->isInstantiable() ? "1" : "0" );
      xml->setAttribute( "isDisposable", type->isDisposable() ? "1" : "0" );
      xml->setAttribute( "isSingleton", type->isSingleton() ? "1" : "0" );
      xml->setAttribute( "docs", getDocString( type ) );
      
      if( type->getSuperType() )
         xml->setAttribute( "superType", getTypeName( type->getSuperType() ) );
      
      if( type->getEnumTable() )
      {
         xml->pushNewElement( "enums" );
         
            const EngineEnumTable& table = *( type->getEnumTable() );
            const U32 numValues = table.getNumValues();
            
            for( U32 i = 0; i < numValues; ++ i )
            {
               xml->pushNewElement( "EngineEnum" );
               
                  xml->setAttribute( "name", table[ i ].getName() );
                  xml->setAttribute( "value", String::ToString( table[ i ].getInt() ) );
                  xml->setAttribute( "docs", table[ i ].getDocString() ? table[ i ].getDocString() : "" );
                  
               xml->popElement();
            }
            
         xml->popElement();
      }
      else if( type->getFieldTable() )
      {
         xml->pushNewElement( "fields" );
         
            const EngineFieldTable& table = *( type->getFieldTable() );
            const U32 numFields = table.getNumFields();
            
            for( U32 i = 0; i < numFields; ++ i )
            {
               const EngineFieldTable::Field& field = table[ i ];
               
               xml->pushNewElement( "EngineField" );
               
                  xml->setAttribute( "name", field.getName() );
                  xml->setAttribute( "type", getTypeName( field.getType() ) );
                  xml->setAttribute( "offset", String::ToString( field.getOffset() ) );
                  xml->setAttribute( "indexedSize", String::ToString( field.getNumElements() ) );
                  xml->setAttribute( "docs", field.getDocString() ? field.getDocString() : "" );
               
               xml->popElement();
            }
         
         xml->popElement();
      }
      else if( type->getPropertyTable() )
      {
         xml->pushNewElement( "properties" );
         
            const EnginePropertyTable& table = *( type->getPropertyTable() );
            const U32 numProperties = table.getNumProperties();
            U32 groupNestingDepth = 0;
            
            for( U32 i = 0; i < numProperties; ++ i )
            {
               const EnginePropertyTable::Property& property = table[ i ];
               
               if( property.isGroupBegin() )
               {
                  groupNestingDepth ++;
                  xml->pushNewElement( "EnginePropertyGroup" );
                  
                     xml->setAttribute( "name", property.getName() );
                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
                     
                     xml->pushNewElement( "properties" );
               }
               else if( property.isGroupEnd() )
               {
                  groupNestingDepth --;
                  xml->popElement();
                  xml->popElement();
               }
               else
               {
                  xml->pushNewElement( "EngineProperty" );
                  
                     xml->setAttribute( "name", property.getName() );
                     xml->setAttribute( "indexedSize", String::ToString( property.getNumElements() ) );
                     xml->setAttribute( "isConstant", property.isConstant() ? "1" : "0" );
                     xml->setAttribute( "isTransient", property.isTransient() ? "1" : "0" );
                     xml->setAttribute( "isVisible", property.hideInInspectors() ? "0" : "1" );
                     xml->setAttribute( "docs", property.getDocString() ? property.getDocString() : "" );
                  
                  xml->popElement();
               }
            }
         
         AssertFatal( !groupNestingDepth, "exportType - Property group nesting mismatch!" );
         xml->popElement();
      }      
      exportScope( type, xml );
      
   xml->popElement();
}
Ejemplo n.º 5
0
static void exportFunction( const EngineFunctionInfo* function, SimXMLDocument* xml )
{
   if( isExportFiltered( function ) )
      return;
      
   xml->pushNewElement( "EngineFunction" );
      
      xml->setAttribute( "name", function->getExportName() );
      xml->setAttribute( "returnType", getTypeName( function->getReturnType() ) );
      xml->setAttribute( "symbol", function->getBindingName() );
      xml->setAttribute( "isCallback", function->isCallout() ? "1" : "0" );
      xml->setAttribute( "isVariadic", function->getFunctionType()->isVariadic() ? "1" : "0" );
      xml->setAttribute( "docs", getDocString( function ) );
      
      xml->pushNewElement( "arguments" );
      
         const U32 numArguments = function->getNumArguments();
         const U32 numDefaultArguments = ( function->getDefaultArguments() ? function->getDefaultArguments()->mNumDefaultArgs : 0 );
         const U32 firstDefaultArg = numArguments - numDefaultArguments;
         
         Vector< String > argumentNames = parseFunctionArgumentNames( function );
         const U32 numArgumentNames = argumentNames.size();
         
         // Accumulated offset in function argument frame vector.
         U32 argFrameOffset = 0;
         
         for( U32 i = 0; i < numArguments; ++ i )
         {
            xml->pushNewElement( "EngineFunctionArgument" );
            const EngineTypeInfo* type = function->getArgumentType( i );
            AssertFatal( type != NULL, "exportFunction - Argument cannot have type void!" );
            
            String argName;
            if( i < numArgumentNames )
               argName = argumentNames[ i ];
               
            xml->setAttribute( "name", argName );
            xml->setAttribute( "type", getTypeName( type ) );
            
            if( i >= firstDefaultArg )
            {
               String defaultValue = getDefaultArgumentValue( function, type, argFrameOffset );
               xml->setAttribute( "defaultValue", defaultValue );
            }

            xml->popElement();
            
            if( type->getTypeKind() == EngineTypeKindStruct )
               argFrameOffset += type->getInstanceSize();
            else
               argFrameOffset += type->getValueSize();
               
            #ifdef _PACK_BUG_WORKAROUNDS
            if( argFrameOffset % 4 > 0 )
               argFrameOffset += 4 - ( argFrameOffset % 4 );
            #endif
         }
         
      xml->popElement();
         
   xml->popElement();
}