コード例 #1
0
void CXBindingsCppObjectsGenerator::DoGenerateMacroForChildEnumerator( CXBindingsRuleInfo& ruleInfo , CXBindingsArrayGrammarChildInfo& childs , CXBindings& , CXBindingsGeneratorOptions& )
{
    /** @todo manage here enumaration for types different from a string */
    if( childs.size() > 0 ) {
        std::string child_enum_list;
        std::string child_string_enum_list;

        for( unsigned int i = 0; i < childs.size() ; ++i ) {
            if( i == 0 )
                child_enum_list += "\t$(ns)" + childs[i].properties[ruleInfo.variable.content] + " = 0,\n" ;
            else
                child_enum_list += "\t$(ns)" + childs[i].properties[ruleInfo.variable.content] + ",\n" ;


            std::string str = GetMacro("string_composer") ;
            SetMacro("content",childs[i].properties[ruleInfo.variable.content]) ;
            DoReplaceMacros( str );

            if( i < childs.size()-1 )
                child_string_enum_list += "\t"  + str + ",\n" ;
            else
                child_string_enum_list += "\t"   + str;
        }

        SetMacro( "child_enum_list" , child_enum_list ) ;
        SetMacro( "child_string_enum_list" , child_string_enum_list ) ;
    }

}
コード例 #2
0
//---------------------------------------------------------------------------
void __fastcall TDBAwareForm::ComboBox2Change(TObject *Sender)
{
  AnsiString order;

  switch (ComboBox2->ItemIndex) {
    case 0: {
      order = "ORDERS.\"SaleDate\"";
      break;
    }
    case 1: {
      order = "ORDERS.\"ShipDate\"";
      break;
    }
    case 2: {
      order = "ORDERS.\"CustNo\"";
      break;
    }
    case 3: {
      order = "ORDERS.\"EmpNo\"";
      break;
    }
    default: return;
  }
  SetMacro("ORDER", order);
}
コード例 #3
0
bool CXBindingsGenerator::GenerateCode( CXBindingsGeneratorOptions& options )
{
	SetDefaultMacros(options);

	m_grammar = (CXBindings*) CXBindingsXmlReader::Get()->LoadFile(options.grammarFile);

	if( m_grammar == NULL )
		CXB_THROW( "Error reading your grammar file : " + options.grammarFile );

	m_interpreterInfo = m_interpreter.DoExtractObjectsInformation(options.baseFile,*m_grammar,options);
	m_genfile = (CXBindingsGeneratorFile*) CXBindingsXmlReader::Get()->LoadFile(options.interpreterFile);
	
	if( m_genfile == NULL )
		CXB_THROW("Error reading your file :" + options.interpreterFile );

	// push all var nodes extracted from the genfile as macros for the Generator
	CXBindingsArrayGrammarGeneratorFileVar& vars = m_genfile->GetVariables( );
	for( unsigned int i = 0; i < vars.size() ; ++i )
		SetMacro( vars[i].GetName() , vars[i].GetContent() );


	CXBindingsStringStringMap& types = m_genfile->GetTypeInfo().GetTypes();
	m_baseTypes = types;

	return DoGenerateCode( options );
}
コード例 #4
0
//---------------------------------------------------------------------------
void __fastcall TDBAwareForm::DBGrid1TitleBtnClick(TObject *Sender, long ACol,
        TField *Field)
{
  if (Field != NULL) {
    SetMacro("ORDER", Field->FieldName);
    ComboBox2->ItemIndex = -1;
  }
}
コード例 #5
0
//---------------------------------------------------------------------------
void __fastcall TDBAwareForm::rxDBLookupCombo2Change(TObject *Sender)
{
  AnsiString s;

  s = "0=0";
  if (rxDBLookupCombo2->Value != "") {
    s = "ORDERS.\"CustNo\"=" + rxDBLookupCombo2->Value;
  }
  SetMacro("CUSTOMER", s);
}
コード例 #6
0
ファイル: mij.c プロジェクト: Volkanite/Push
VOID Mij_SetProfile( MOTIONINJOY_APP_OPTION* Configuration )
{
    HANDLE driverHandle;
    IO_STATUS_BLOCK isb;
    BOOLEAN setTestMacro = FALSE;

    if (setTestMacro)
    {
        MOTIONINJOY_MACRO macro;

        Memory_Clear(&macro, sizeof(MOTIONINJOY_MACRO));

        macro.Duration = 800; //800 milli-seconds
        Memory_Copy(macro.Command, SomeMacro, sizeof(macro.Command));

        macro.ButtonIntervals[0][10] = 0x01; //0ms
        macro.ButtonIntervals[1][10] = 0x02; //100ms
        macro.ButtonIntervals[2][10] = 0x04; //200ms
        macro.ButtonIntervals[3][10] = 0x08; //300ms
        macro.ButtonIntervals[4][10] = 0x10; //400ms
        macro.ButtonIntervals[5][10] = 0x20; //500ms

        SetMacro(1, &macro);
    }

    File_Create(
        &driverHandle,
        L"\\\\.\\MIJFilter",
        SYNCHRONIZE | FILE_READ_DATA | FILE_WRITE_DATA,
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        FILE_OPEN,
        FILE_SYNCHRONOUS_IO_NONALERT,
        NULL
        );

    if (setTestMacro)
        Configuration->InputOption.Maping.Triangle = Macro1; //set triangle button to macro

    NtDeviceIoControlFile(driverHandle, NULL, NULL, NULL, &isb, IOCTL_MIJ_SET_CONFIG_OPTIONS, Configuration, 256, NULL, 0);
    File_Close(driverHandle);
}
コード例 #7
0
ファイル: dlgManageMacros.cpp プロジェクト: GHnubsST/pgadmin3
void dlgManageMacros::OnSave(wxCommandEvent &ev)
{
	if (!thisMacroChanged)
		return;
	SetMacro(false);
}
コード例 #8
0
ファイル: dlgManageMacros.cpp プロジェクト: GHnubsST/pgadmin3
void dlgManageMacros::OnOK(wxCommandEvent &ev)
{
	if (thisMacroChanged)
		SetMacro(true);
	EndModal(wxID_OK);
}
コード例 #9
0
CXBindingsFileInfo CXBindingsCppObjectsGenerator::DoGenerateRuleCodeFor( CXBindingsRuleInfo& ruleInfo , CXBindings& , CXBindingsGeneratorOptions& options )
{
    CXBindingsFileInfo res;

    //wxLogMessage( "\t\t Rule make is : ") + ruleInfo.make  ;
    //wxLogMessage( "\t\t Rule name is : ") + ruleInfo.name.content  ;
    //wxLogMessage( "\t\t Rule type is : ") + ruleInfo.type.content  ;



    CXBindingsStringStringMap& types = m_genfile->GetTypeInfo().GetTypes();
    std::string realType = ruleInfo.type.content;
    std::string typeTemplate = ruleInfo.type.stemplate;

    CXBindingsGeneratorFileTemplate* arrayTemplate = NULL;

    CXBindingsStringStringMap::iterator it = types.find( realType );

    realType = GetRealType( realType  , options );

    std::string typeExt = realType;
    if( !IsKnownType( realType ) )
        typeExt = GetRealType( realType , options );

    if( it != types.end() ) {
        realType = it->second;
        typeExt = realType;
    }

    std::string savedType = typeExt;

    if( typeTemplate == "array")    {
        typeExt = "std::vector< " + typeExt + " >" ;
        arrayTemplate = m_genfile->FindTemplate( "array_addons")  ;
    }


    if( ruleInfo.make == "import")    {

        // We have to add here all informations about the object from which this one is derived
        // this information is contained in the realType variable

        /* for each element in the info object of the grammar */
        CXBindings& grammar = m_interpreterInfo.grammar;
        CXBindingsInfo& info = grammar.GetInfo();
        CXBindingsArrayString genOrder = info.GetGeneration().GetObjects();

        /* The first thing to do is to estabilsh the generation objects dependecy list
         * So that object will be generated in the right order...
         */
        CXBindingsArrayString dependencies;

        for( unsigned int i = 0; i < genOrder.size() ; ++i ) {

            CXBindingsArrayGrammarObjectInfoMap& objectsInfoMap = m_interpreterInfo.objects;
            CXBindingsArrayGrammarObjectInfo& objectsInfo = objectsInfoMap[genOrder[i]];

            for( unsigned int j = 0; j < objectsInfo.size() ; ++j ) {

                std::string name = objectsInfo[j].properties["name" ];

                name = GetRealType( name , options );

                if( name == savedType )  {
                    std::pair< std::string , CXBindingsFileInfo> inf( name , m_objectInfos[name] );
                    res.bases.push_back( inf );

                    return res;
                }

            }
        }

        std::pair< std::string , CXBindingsFileInfo> inf( savedType , m_objectInfos[savedType] );
        res.bases.push_back( inf );

        return res;
    }

    std::string nameExt = ruleInfo.name.content;
    nameExt = GetPropertyExtension( nameExt , options );
    SetMacro( "name_extension" , nameExt)  ;

    SetMacro( "name" , ruleInfo.name.content)  ;
    SetMacro( "type" , typeExt)  ;
    SetMacro( "real_type" , savedType)  ;
    SetMacro( "variable" , ruleInfo.variable.content)  ;

    CXBindingsGeneratorFileTemplate* rTemplate = m_genfile->FindTemplate( ruleInfo.make );

    if( rTemplate == NULL )
        CXB_THROW( "Error cannot find template : " + ruleInfo.make)  ;

    if( ruleInfo.make == "property" || ruleInfo.make ==  "attribute" )    {
        std::pair< std::string , std::string > mpair( ruleInfo.name.content , typeExt );
        res.properties.push_back( mpair );
    }

    if( ruleInfo.make == "property" || ruleInfo.make == "attribute" || ruleInfo.make == "variant_accessor"  || ruleInfo.make == "variant_array_accessor")  {
        std::pair< std::string , std::string > mpair( ruleInfo.name.content , savedType );
        res.dependencies.push_back( mpair );
    }

    CXBindingsArrayGrammarGeneratorFileObjectPart& objects = rTemplate->GetObjects();

    for( unsigned int i = 0; i < objects.size() ; ++i ) {

        std::string content = objects[i].GetContent();
        DoReplaceMacros( content );

        if( objects[i].GetFile() =="header")
        {
            if( objects[i].GetPermission() == "private")
                res.headerPrivateInfo += content;
            else if( objects[i].GetPermission() == "protected")
                res.headerProtectedInfo += content;
            else
                res.headerPublicInfo += content;
        }
        else
            res.srcInfo += content;
    }

    if( arrayTemplate != NULL ) {
        CXBindingsArrayGrammarGeneratorFileObjectPart& objectsArray = arrayTemplate->GetObjects();

        for( unsigned int i = 0; i < objectsArray.size() ; ++i ) {

            std::string content = objectsArray[i].GetContent();
            DoReplaceMacros( content );

            if( objectsArray[i].GetFile() =="header")
            {
                if( objectsArray[i].GetPermission() == "private")
                    res.headerPrivateInfo += content;
                else if( objectsArray[i].GetPermission() == "protected")
                    res.headerProtectedInfo += content;
                else
                    res.headerPublicInfo += content;
            }
            else
                res.srcInfo += content;
        }
    }

    return res;

}
コード例 #10
0
bool CXBindingsCppObjectsGenerator::DoGenerateCode( CXBindingsGeneratorOptions& options )
{
    /* for each element in the info object of the grammar */
    CXBindings& grammar = m_interpreterInfo.grammar;
    CXBindingsInfo& info = grammar.GetInfo();
    CXBindingsArrayString genOrder = info.GetGeneration().GetObjects();
    CXBindingsArrayString templates = info.GetGeneration().GetTemplates();

    /* The first thing to do is to estabilsh the generation objects dependecy list
     * So that object will be generated in the right order...
     */
    CXBindingsArrayString dependencies = DoCreateDependencyList( options );

    /** @todo here generate object in their dependencies order is this really usefull .??? */
    for( unsigned int k = 0; k < dependencies.size() ; ++k ) {
        for( unsigned int i = 0; i < genOrder.size() ; ++i ) {

            CXBindingsArrayGrammarObjectInfoMap& objectsInfoMap = m_interpreterInfo.objects;
            CXBindingsArrayGrammarObjectInfo& objectsInfo = objectsInfoMap[genOrder[i]];

            for( unsigned int j = 0; j < objectsInfo.size() ; ++j ) {

                std::string realName = objectsInfo[j].properties["name"];
                realName = GetRealType( realName , options );

                if( realName == dependencies[k] )  {
                    DoGenerateCodeFor( objectsInfo[j] , grammar , options );
                    break;
                }
            }
        }
    }

    /** The last step is to generate the globals file and the other files for given objects */

    std::string hdrDir = options.genDir + "/include" ;
    std::string srcDir = options.genDir + "/src" ;
    CXBindingsMakeDirRecursively(hdrDir+"/") ;
    CXBindingsMakeDirRecursively(srcDir+"/") ;

    /* First generate globals file definitions */
    std::string global_file = GetMacro( "global_file")  ;
    std::string global_file_src = GetMacro( "global_file_src")  ;
    std::string filename = options.ns + "_globals" ;
    SetMacro( "filename" , filename) ;
    SetMacro( "globals_code" , m_globalInfo.headerPublicInfo) ;
    SetMacro( "globals_code_src" , m_globalInfo.srcInfo) ;

    DoReplaceMacros( global_file );
    DoReplaceMacros( global_file_src );
    SaveFile( hdrDir + "/" + filename + ".h"  , global_file );
    SaveFile( srcDir + "/" + filename + ".cpp"  , global_file_src) ;

    // Generate additional files
    CXBindingsArrayGrammarGeneratorFileAddin& addins = m_genfile->GetAddins();
    for( unsigned int i = 0; i < addins.size() ; ++i ) {
        std::string fname = addins[i].GetName();
        std::string header = addins[i].GetHeader();
        std::string source = addins[i].GetSource();

        if( !header.empty() ) {
            DoReplaceMacros( header );
            SaveFile( hdrDir + "/" + fname + ".h"  , header)  ;
        }
        if( !source.empty() ) {
            DoReplaceMacros( source );
            SaveFile( srcDir + "/" + fname + ".cpp"  , source) ;
        }
    }

    // Save generated objects code
    CXBindingsFileInfoMap::iterator it = m_objectInfos.begin();
    for( ; it != m_objectInfos.end() ; ++it )
    {
        if( m_objectFiles[it->first] !=filename && !m_objectFiles[it->first].empty() )
        {
            std::string srcFile = srcDir + "/" + m_objectFiles[it->first] + ".cpp" ;
            std::string hdrFile = hdrDir + "/" + m_objectFiles[it->first] + ".h" ;

            if( !it->second.srcInfo.empty() ) {
                SaveFile( srcFile , it->second.srcInfo );
            }

            SaveFile( hdrFile , it->second.headerPublicInfo );
        }

    }
    return false;
}
コード例 #11
0
void CXBindingsCppObjectsGenerator::DoCreateParametersMacrosFor( CXBindingsFileInfo& file , CXBindingsFileParametersMacros& parameters , CXBindingsGeneratorOptions& options )
{
    for( unsigned int i = 0; i < file.properties.size() ; ++i )
    {
        std::string pName = file.properties[i].first;
        std::string pType = file.properties[i].second;

        //wxLogMessage( pName + " - ") + pType  ;

        std::string nameExt = GetPropertyExtension( pName , options );

        SetMacro( "content_type" , pType) ;
        SetMacro( "content" , pName) ;
        SetMacro( "content_ext" , nameExt) ;
        std::string str,str2;

        str = GetMacro("ctor_var_composer") ;
        str2 = GetMacro( "ctor_var_composer2")  ;
        DoReplaceMacros(str);
        DoReplaceMacros(str2);

        if( parameters.parameters_copy_list.empty() && !str.empty() ) {
            parameters.parameters_ctor_list += str;
            parameters.parameters_ctor_list2 += str2;
        }
        else if( !str.empty() ) {
            parameters.parameters_ctor_list += " ,"  + str;
            parameters.parameters_ctor_list2 += " ,"  + str2;
        }

        str = GetMacro("var_eqop_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_eqop_list += str;

        str = GetMacro("var_definit_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_default_init_list += str;

        str = GetMacro("var_init_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_init_list += str;

        str = GetMacro("var_copy_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_copy_list += str;

        str = GetMacro("var_doc_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_doc_list += str;

        str = GetMacro("var_property_composer") ;
        DoReplaceMacros(str);
        parameters.parameters_property_table += str;

        if( i < file.properties.size()-1 )
            parameters.parameters_property_table += "\n" ;

        str = GetMacro("var_eqeqop_composer") ;
        DoReplaceMacros(str);

        if( i == 0 && parameters.parameters_eqeqop_list.empty() ) {
            parameters.parameters_eqeqop_list += "\t"  + str;
        }
        else {
            parameters.parameters_eqeqop_list += " &&\n\t"  + str;
        }

    }

}
コード例 #12
0
void CXBindingsCppObjectsGenerator::DoGenerateCodeFor(
    CXBindingsObjectInfo& objectInfo ,
    CXBindings& grammar ,
    CXBindingsGeneratorOptions& options )
{

    // STEP 0 : APPEND OBJECT PROPERTIES IN THE MACRO MAP
    CXBindingsStringStringMap& properties = objectInfo.properties;

    //wxLogMessage( "\t STEP O : Calculating Object preliminar informations : ") + properties["name" ]  ;

    //wxLogMessage( "\t\t STEP O.1 : Appending Object macro : ") + properties["name" ]  ;

    if( properties["name"].empty() )
        CXB_THROW( "Error object with no name cannot continue...")  ;

    std::string objectName = properties["name" ];
    objectName = GetRealType( objectName , options );

    std::string upName;
    upName += objectName;
    to_upper( upName );

    SetMacro( "object" , objectName);
    SetMacro( "OBJECT" , upName) ;

    // @todo here the file is not preoprely set
    /* First set up some macros for the given file */
    // filename macros
    std::string filename = m_objectFiles[objectName];
    SetMacro( "filename" , filename) ;

    // STEP 1 : CHECK CHILD CONTAINERS AND RULES
    //wxLogMessage( "\t STEP 1 : Checking for existing rules in the child containers ... ")  ;
    CXBindingsArrayGrammarChildContainerInfo& ccInfo = objectInfo.childs;

    //std::string msg = std::string::Format( "\t\t Found %d childcontainers...") , ccInfo.size()  ;
    //wxLogMessage( msg );

    CXBindingsFileInfo objectFileInfo;

    for( unsigned int i = 0; i < ccInfo.size() ; ++i ) {
        objectFileInfo += DoGenerateChildContainerCodeFor( ccInfo[i] , grammar , options );
    }

    //wxLogMessage( "\t END STEP 1")  ;

    // STEP 2 : CHECK CATEGORIES AND RULES
    //wxLogMessage( "\t STEP 2 : Checking for existing rules in the child categories ... ")  ;
    CXBindingsArrayGrammarCategoryInfo& catInfo = objectInfo.categories;

    //msg = std::string::Format( "\t\t Found %d categories...") , catInfo.size()  ;
    //wxLogMessage( msg );

    for( unsigned int i = 0; i < catInfo.size() ; ++i ) {
        objectFileInfo += DoGenerateCategoryCodeFor( catInfo[i] , grammar , options );
    }

    //wxLogMessage( "\t END STEP 2")  ;

    CXBindingsArrayGrammarChildInfo& childs = objectInfo.childInfos;
    for( unsigned int j = 0; j < childs.size() ; ++j ) {

        CXBindingsFileInfo ruleContent = DoGenerateChildRuleCodeFor( childs[j] , grammar , options );
        objectFileInfo += ruleContent;
    }

    //wxLogMessage( "\t STEP 3 : create additional object macros for the given object if exists ... ")  ;

    // Append codes in the childs_header_public_code
    std::string childs_header_public_code = objectFileInfo.headerPublicInfo;
    SetMacro( "childs_header_public_code" , childs_header_public_code);

    std::string childs_header_private_code;
    childs_header_private_code = objectFileInfo.headerPrivateInfo;
    SetMacro( "childs_header_private_code" , childs_header_private_code) ;

    std::string childs_header_protected_code;
    childs_header_protected_code = objectFileInfo.headerProtectedInfo,
    SetMacro( "childs_header_protected_code" , childs_header_protected_code) ;

    std::string childs_src_code = objectFileInfo.srcInfo;
    SetMacro( "childs_src_code" , childs_src_code) ;

    // Finally build the missing macrods for doc comments and other parameters info
    CXBindingsFileParametersMacros params;

    /* once all parameters list have been generated, we need to create the macros of derived
     * objects. This is very important in order to treat the inherit template from the various
     * rules/
     */
    std::string object_bases;
    std::string object_bases_default_ctor;
    std::string object_bases_init_list;
    std::string object_bases_copy_list;
    std::string object_bases_list;

    for( unsigned int i = 0; i < objectFileInfo.bases.size() ; ++i ) {
        std::string pName = objectFileInfo.bases[i].first;
        CXBindingsFileInfo& inf = objectFileInfo.bases[i].second;

        pName = GetRealType( pName , options );

        CXBindingsFileParametersMacros localp;
        localp.parameters_eqeqop_list = params.parameters_eqeqop_list;
        DoCreateParametersMacrosFor( inf , localp , options );

        params.parameters_doc_list += localp.parameters_doc_list;
        params.parameters_ctor_list += localp.parameters_ctor_list;
        params.parameters_eqop_list += localp.parameters_eqop_list;
        params.parameters_eqeqop_list = localp.parameters_eqeqop_list;

        //wxLogMessage( localp.parameters_doc_list );

        if( i != 0 ) {
            object_bases += " , public "  + pName;
            object_bases_list += " , "  + pName;
            object_bases_default_ctor += ",\n\t\t" + pName + "()" ;
            object_bases_copy_list += ",\n\t\t" + pName + "(rhs)" ;
            object_bases_init_list += ",\n\t\t" + pName + "(" + localp.parameters_ctor_list2 + ")" ;
        }
        else {
            object_bases += " public "  + pName;
            object_bases_list += pName;
            object_bases_default_ctor += "\t\t" + pName + "()" ;
            object_bases_copy_list += "\t\t" + pName + "(rhs)" ;
            object_bases_init_list += " \t\t" + pName + "(" + localp.parameters_ctor_list2 + ")" ;
        }
    }

    if( object_bases.empty() ) {
        object_bases = "public $(base_object)" ;
        object_bases_default_ctor = "\t\t$(base_object)()" ;
        object_bases_copy_list = "\t\t$(base_object)()" ;
        object_bases_list = "$(base_object)" ;
        object_bases_init_list = "\t\t$(base_object)()" ;
    }

    SetMacro( "object_bases" , object_bases ) ;
    SetMacro( "object_bases_list" , object_bases_list) ;
    SetMacro( "object_bases_default_ctor" , object_bases_default_ctor) ;
    SetMacro( "object_bases_init_list" , object_bases_init_list) ;
    SetMacro( "object_bases_copy_list" , object_bases_copy_list) ;

    DoCreateParametersMacrosFor( objectFileInfo , params , options );

    if( params.parameters_eqeqop_list.empty() )
        params.parameters_eqeqop_list = "\t\ttrue";

    SetMacro( "parameters_doc_list" , params.parameters_doc_list ) ;
    SetMacro( "parameters_ctor_list" , params.parameters_ctor_list ) ;
    SetMacro( "parameters_dtor_list" , params.parameters_dtor_list ) ;
    SetMacro( "parameters_init_list" , params.parameters_init_list ) ;
    SetMacro( "parameters_default_init_list" , params.parameters_default_init_list ) ;
    SetMacro( "parameters_copy_list" , params.parameters_copy_list ) ;
    SetMacro( "parameters_eqop_list" , params.parameters_eqop_list ) ;
    SetMacro( "parameters_eqeqop_list" , params.parameters_eqeqop_list ) ;
    SetMacro( "parameters_property_table" , params.parameters_property_table ) ;

    if( params.parameters_doc_list.empty() ) {
        SetMacro( "object_ctors" , "$(object_simple_ctor_header)" )  ;
    } else {
        SetMacro( "object_ctors" , "$(object_complex_ctor_header)" )  ;
    }
    /* The next step is very important !
     * First we have to establish all direct dependencies in the given property list
     * and all dependencies of the given bases.
     * Once this is done, we can get the dependency list and include list to put in the
     * source file*/

    std::string local_includes = "#include \"" + options.ns + "_globals"  + ".h\"\n" ;
    std::string object_imports;

    CXBindingsArrayString lc;
    CXBindingsArrayString oi;

    CXBindingsArrayString currObj;
    currObj.push_back(objectName);
    DoGetIncludesListFor(lc,oi,currObj,objectFileInfo,options);

    for( unsigned int i = 0; i < lc.size() ; ++i ) {
        local_includes += lc[i];
        object_imports += oi[i];
    }

    if( filename != options.ns + "_globals")
    {
        object_imports += "class " + objectName + ";\n" ;
    }

    SetMacro( "local_includes" , local_includes) ;
    SetMacro( "object_imports" , object_imports) ;
    //wxLogMessage( "\t\t\t local_includes is :") + local_includes  ;
    //wxLogMessage( "\t\t\t object_imports is :") + object_imports  ;


    //wxLogMessage( "\t END STEP 3...")  ;

    // STEP 4 : CHECK EXISTING RULES IN THE GIVEN OBJECT
    //wxLogMessage( "\t STEP 4 : Checking for existing rules in the object ... ")  ;
    CXBindingsArrayGrammarRuleInfo& rules = objectInfo.rules;

    //msg = std::string::Format( "\t\t Found %d rules...") , rules.size()  ;
    //wxLogMessage( msg );

    CXBindingsFileInfo FinalInfo;

    for( unsigned int i = 0; i < rules.size() ; ++i ) {

        CXBindingsFileInfo ruleContent = DoGenerateRuleCodeFor( rules[i] , grammar , options );
        FinalInfo += ruleContent;
    }

    if( filename ==options.ns + "_globals")
        m_globalInfo += objectFileInfo;

    objectFileInfo.headerPublicInfo = stdEmptyString;
    objectFileInfo.headerProtectedInfo = stdEmptyString;
    objectFileInfo.headerPrivateInfo = stdEmptyString;
    objectFileInfo.srcInfo = stdEmptyString;

    FinalInfo += objectFileInfo;
    //std::cout << objectName << std::endl;
    m_objectInfos[objectName] = FinalInfo;

    //wxLogMessage( "\t END STEP 4...")  ;
}
コード例 #13
0
void CXBindingsCppHandlersGenerator::DoCreateParametersMacrosFor( CXBindingsHandlerFileInfo& file , CXBindingsHandlerFileParametersMacros& parameters  , CXBindingsGeneratorOptions& options)
{
	for( unsigned int i = 0; i < file.properties.size() ; ++i )
	{
		std::string pName = file.properties[i].first;
		std::string pType = file.properties[i].second;

		//wxLogMessage( pName + " - ") + pType  ;
		
		std::string nameExt = pName;
		nameExt = GetPropertyExtension( nameExt , options );
		
		SetMacro( "name_extension", nameExt) ;
		SetMacro( "name" , pName) ;
		SetMacro( "type" , pType) ;
	    
        std::string ot = pType;
		/* Here we have to get the types of each properties and if it's not an object
		 * get the "real" type of the given properties (i.e : a typedef or an enumeration)
		 */
		 
		/* first check if the type is known or not */
		CXBindingsStringStringMap::iterator it = m_types.find( pName );
		if( it != m_types.end() )
			pType = it->second;
			
		//wxLogMessage( pName + " - ") + pType  ;
		
		CXBindingsGeneratorFileTemplate* preader = NULL;
		CXBindingsGeneratorFileTemplate* pwriter = NULL;
		
		std::string trName = "property_reader_"  + pType;
		std::string twName = "property_writer_"  + pType;
		
		preader = m_genfile->FindTemplate( trName );
		pwriter = m_genfile->FindTemplate( twName );
			
		if( preader == NULL || pwriter == NULL )
			CXB_THROW( "Error cannot find property reader and writer template for object of type : " + pType + " for variable " + pName + " original type is " + ot);
			
		CXBindingsArrayGrammarGeneratorFileObjectPart& objects = preader->GetObjects();

		for( unsigned int j = 0; j < objects.size() ; ++j ) {
			
			std::string content = objects[j].GetContent();
			DoReplaceMacros( content );

			if( objects[j].GetFile() =="src")    {
				parameters.property_readers += content;
			}
		}
		
		CXBindingsArrayGrammarGeneratorFileObjectPart& objectsw = pwriter->GetObjects();

		for( unsigned int j = 0; j < objectsw.size() ; ++j ) {
			
			std::string content = objectsw[j].GetContent();
			DoReplaceMacros( content );

			if( objectsw[j].GetFile() =="src")    {
				parameters.property_writers += content;
			}
		}
	}
	
	for( unsigned int i = 0; i < file.attributes.size() ; ++i )
	{
		std::string pName = file.attributes[i].first;
		std::string pType = file.attributes[i].second;

		//wxLogMessage( pName + " - ") + pType  ;
		
		std::string nameExt = pName;
		nameExt = GetPropertyExtension( nameExt , options );
		
		SetMacro( "name_extension" , nameExt) ;
		SetMacro( "name" , pName) ;
		SetMacro( "type" , pType) ;
		
		/* Here we have to get the types of each attributes and if it's not an object
		 * get the "real" type of the given attributes (i.e : a typedef or an enumeration)
		 */
		
        /* first check if the type is known or not */
		CXBindingsStringStringMap::iterator it = m_types.find( pName );
		if( it != m_types.end() )
			pType = it->second;
		
		//wxLogMessage( pName + " - ") + pType  ;
		
		CXBindingsGeneratorFileTemplate* preader = NULL;
		CXBindingsGeneratorFileTemplate* pwriter = NULL;
	    
		std::string trName = "attribute_reader_"  + pType;
		std::string twName = "attribute_writer_"  + pType;
		
		preader = m_genfile->FindTemplate( trName );
		pwriter = m_genfile->FindTemplate( twName );
			
		if( preader == NULL || pwriter == NULL )
			CXB_THROW( "Error cannot find attribute reader and writer template for object of type : " + pType) ;
			
		CXBindingsArrayGrammarGeneratorFileObjectPart& objects = preader->GetObjects();

		for( unsigned int j = 0; j < objects.size() ; ++j ) {
			
			std::string content = objects[j].GetContent();
			DoReplaceMacros( content );

			if( objects[j].GetFile() =="src")    {
				parameters.attribute_readers += content;
			}
		}
		
		CXBindingsArrayGrammarGeneratorFileObjectPart& objectsw = pwriter->GetObjects();

		for( unsigned int j = 0; j < objectsw.size() ; ++j ) {
			
			std::string content = objectsw[j].GetContent();
			DoReplaceMacros( content );

			if( objectsw[j].GetFile() =="src")    {
				parameters.attribute_writers += content;
			}
		}
	}

}
コード例 #14
0
void CXBindingsCppHandlersGenerator::DoGenerateCodeFor( CXBindingsObjectInfo& objectInfo , CXBindings& grammar , CXBindingsGeneratorOptions& options )
{

	// STEP 0 : APPEND OBJECT PROPERTIES IN THE MACRO MAP
	CXBindingsStringStringMap& properties = objectInfo.properties;
	
    if( properties["name"].empty() ) 
		CXB_THROW( "Error object with no name cannot continue...")  ;

	std::string objectName = properties["name" ];
	objectName = GetRealType( objectName , options );
	
	std::string upName; 
	upName += objectName;
	to_upper( upName );
	
	SetMacro( "object" , objectName );
	SetMacro( "OBJECT" , upName );

	// @todo here the file is not preoprely set
	/* First set up some macros for the given file */
	// filename macros
	std::string filename = objectName + "XmlHandler" ;
	SetMacro( "filename" , filename) ;

	// STEP 1 : CHECK CHILD CONTAINERS AND RULES
    CXBindingsArrayGrammarChildContainerInfo& ccInfo = objectInfo.childs;
	CXBindingsHandlerFileInfo objectFileInfo;
	
	for( unsigned int i = 0; i < ccInfo.size() ; ++i ) {
	 	objectFileInfo += DoGenerateChildContainerCodeFor( ccInfo[i] , grammar , options ); 	
	}
		
	// STEP 2 : CHECK CATEGORIES AND RULES
    CXBindingsArrayGrammarCategoryInfo& catInfo = objectInfo.categories;
	for( unsigned int i = 0; i < catInfo.size() ; ++i ) {
		objectFileInfo += DoGenerateCategoryCodeFor( catInfo[i] , grammar , options );
	}
		
	CXBindingsArrayGrammarChildInfo& childs = objectInfo.childInfos;
	for( unsigned int j = 0; j < childs.size() ; ++j ) {

		CXBindingsHandlerFileInfo ruleContent = DoGenerateChildRuleCodeFor( childs[j] , grammar , options );
		objectFileInfo += ruleContent;
	}

	// Finally build the missing macrods for doc comments and other parameters info
	CXBindingsHandlerFileParametersMacros params;
	
	/* once all parameters list have been generated, we need to create the macros of derived
	 * objects. This is very important in order to treat the inherit template from the various
	 * rules/
	 */
	for( unsigned int i = 0; i < objectFileInfo.bases.size() ; ++i ) {
		std::string pName = objectFileInfo.bases[i].first;
		CXBindingsHandlerFileInfo& inf = objectFileInfo.bases[i].second;

		CXBindingsHandlerFileParametersMacros localp;
		DoCreateParametersMacrosFor( inf , localp , options );

		params += localp;
	}
	
	DoCreateParametersMacrosFor( objectFileInfo , params , options );

	SetMacro( "objects_attribute_readers" , params.attribute_readers) ;
	SetMacro( "objects_attribute_writers" , params.attribute_writers) ;
	SetMacro( "objects_property_readers" , params.property_readers) ;
	SetMacro( "objects_property_writers" , params.property_writers) ;
	
	
	/* The next step is very important ! 
	 * First we have to establish all direct dependencies in the given property list
	 * and all dependencies of the given bases.
	 * Once this is done, we can get the dependency list and include list to put in the 
	 * source file*/
	
	std::string local_includes;
	std::string object_imports;
	
	CXBindingsArrayString lc;
	CXBindingsArrayString currObj;
	currObj.push_back(objectName);
	DoGetIncludesListFor(lc,currObj,objectFileInfo,options);
	
	for( unsigned int i = 0; i < lc.size() ; ++i ) {
		local_includes += lc[i];
	}
	
	SetMacro( "local_includes" , local_includes) ;
	//wxLogMessage( "\t\t\t local_includes is :") + local_includes  ;

		
	//wxLogMessage( "\t END STEP 3...")  ;

	// STEP 4 : CHECK EXISTING RULES IN THE GIVEN OBJECT
	//wxLogMessage( "\t STEP 4 : Checking for existing rules in the object ... ")  ;
	CXBindingsArrayGrammarRuleInfo& rules = objectInfo.rules;
	
	//msg = std::string::Format( "\t\t Found %d rules...") , rules.size()  ;
	//wxLogMessage( msg );

	CXBindingsHandlerFileInfo FinalInfo;
	
	if( filename ==options.ns + "_globals")   {
		//wxLogMessage( "Object is a typedef or an enumeration, no handler needs to be generated for.") ;
		return;
	}
	
	CXBindingsGeneratorFileTemplate* rTemplate = m_genfile->FindTemplate( "object")  ;

	if( rTemplate == NULL )
		CXB_THROW( "Error cannot find template object")  ;
	
	std::string objectNodeName = properties["name" ];
	boost::replace_all(objectNodeName,"Type","");

	SetMacro( "object_node_name" , objectNodeName) ;
	
	CXBindingsArrayGrammarGeneratorFileObjectPart& objects = rTemplate->GetObjects();

	for( unsigned int i = 0; i < objects.size() ; ++i ) {
		
		std::string content = objects[i].GetContent();
		DoReplaceMacros( content );

		if( objects[i].GetFile() =="header")   
		{
			FinalInfo.headerInfo += content;
		}
		else
			FinalInfo.srcInfo += content;
		
		//wxLogMessage( "\t\t\t Generated rule content is : ") + content  ;
	}
	
	FinalInfo += objectFileInfo;
	m_objectInfos[objectName] = FinalInfo;

	//wxLogMessage( "\t END STEP 4...")  ;
}
コード例 #15
0
ファイル: ogrfmelayerdb.cpp プロジェクト: bbradbury/lib_gdal
int OGRFMELayerDB::CreateReader()

{
    FME_MsgNum    err;
    IFMESession  *poSession = poDS->GetFMESession();
    FME_UInt32   i;

    CPLAssert( poReader == NULL && nPreviousFeature == -1 );

/* -------------------------------------------------------------------- */
/*      Make a copy of the user directives, so we won't be altering     */
/*      the originals.                                                  */
/* -------------------------------------------------------------------- */
    IFMEStringArray  *poUDC = poSession->createStringArray();

    for( i = 0; i < poUserDirectives->entries(); i++ )
        poUDC->append( (*poUserDirectives)(i) );

/* -------------------------------------------------------------------- */
/*      Update the IDLIST to just select the desired table.             */
/* -------------------------------------------------------------------- */

    for( i = 0; i < poUDC->entries(); i++ )
    {
        if( EQUAL((const char *) (*poUDC)(i),"IDLIST") )
        {
            IFMEString    *poIDList = poSession->createString();
            *poIDList = GetLayerDefn()->GetName();
            poUDC->setElement( i+1, *poIDList );
            poSession->destroyString( poIDList );
            break;
        }
    }

    if( i == poUDC->entries() )
    {
        poUDC->append( "IDLIST" );
        poUDC->append( GetLayerDefn()->GetName() );
    }
/* -------------------------------------------------------------------- */
/*      Update the macros for source information, if needed.            */
/* -------------------------------------------------------------------- */
    if( m_poFilterGeom != NULL )
    {
        const char *pszDirective = "RUNTIME_MACROS";

        if( !poUDC->contains(pszDirective) )
        {
            poUDC->append(pszDirective);
            poUDC->append("");
        }
        for( i = 0; i < poUDC->entries(); i++ )
        {
            if( EQUAL((const char *) (*poUDC)(i),pszDirective) )
            {
                IFMEString  *poMacroValue = poSession->createString();
                char      szSEARCH_ENVELOPE[1024];
                OGREnvelope      oEnvelope;

                poUDC->getElement( i+1, *poMacroValue );

                m_poFilterGeom->getEnvelope( &oEnvelope );

                if( STARTS_WITH_CI(pszReaderName, "SDE") )
                {
                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinX );
                    SetMacro( poMacroValue, "_SDE3MINX", szSEARCH_ENVELOPE );

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinY );
                    SetMacro( poMacroValue, "_SDE3MINY", szSEARCH_ENVELOPE );

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxX );
                    SetMacro( poMacroValue, "_SDE3MAXX", szSEARCH_ENVELOPE );

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxY );
                    SetMacro( poMacroValue, "_SDE3MAXY", szSEARCH_ENVELOPE );
                }
                else
                {
                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinX );
                    SetMacro( poMacroValue, "_ORACLE_MINX", szSEARCH_ENVELOPE);

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinY );
                    SetMacro( poMacroValue, "_ORACLE_MINY", szSEARCH_ENVELOPE);

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxX );
                    SetMacro( poMacroValue, "_ORACLE_MAXX", szSEARCH_ENVELOPE);

                    sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxY );
                    SetMacro( poMacroValue, "_ORACLE_MAXY", szSEARCH_ENVELOPE);
                }

                poUDC->setElement( i+1, *poMacroValue );

                CPLDebug( "FMEOLEDB", "Update %s to:\n%s",
                          pszDirective, poMacroValue->data() );

                poSession->destroyString( poMacroValue );
                break;
            }
        }
    }

/* -------------------------------------------------------------------- */
/*      Create new reader with desired constraints.                     */
/* -------------------------------------------------------------------- */
    poReader = poSession->createReader(pszReaderName, FME_FALSE, poUDC);
    poSession->destroyStringArray( poUDC );
    if( poReader == NULL )
    {
        CPLFMEError( poSession,
                     "Failed to create reader of type `%s'.\n",
                     pszReaderName );
        return FALSE;
    }

/* -------------------------------------------------------------------- */
/*      Setup constraints applied in open().                            */
/* -------------------------------------------------------------------- */
    IFMEStringArray     *poParms = poSession->createStringArray();

    if( pszAttributeFilter != NULL && strlen(pszAttributeFilter) > 0 )
    {
        if( STARTS_WITH_CI(pszReaderName, "SDE") )
            poParms->append( "WHERE" );
        else
            poParms->append( "WHERE_CLAUSE" );

        poParms->append( pszAttributeFilter );
    }
#ifdef notdef
    if( m_poFilterGeom != NULL )
    {
        char      szSEARCH_ENVELOPE[1024];
        OGREnvelope      oEnvelope;

        m_poFilterGeom->getEnvelope( &oEnvelope );

        sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinX );
        poParms->append( "SEARCH_ENVELOPE" );
        poParms->append( szSEARCH_ENVELOPE );

        sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MinY );
        poParms->append( "SEARCH_ENVELOPE" );
        poParms->append( szSEARCH_ENVELOPE );

        sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxX );
        poParms->append( "SEARCH_ENVELOPE" );
        poParms->append( szSEARCH_ENVELOPE );

        sprintf( szSEARCH_ENVELOPE, "%.16f", oEnvelope.MaxY );
        poParms->append( "SEARCH_ENVELOPE" );
        poParms->append( szSEARCH_ENVELOPE );
    }
#endif

    for( i = 0; i < poParms->entries(); i++ )
    {
        CPLDebug( "FMEOLEDB", "openParms[%d] = %s",
                  i, (const char *) (*poParms)(i) );
    }

/* -------------------------------------------------------------------- */
/*      Now try to open the dataset.                                    */
/* -------------------------------------------------------------------- */
    err = poReader->open( pszDataset, *poParms );
    if( err )
    {
        CPLFMEError( poSession,
                     "Failed to open dataset `%s' with reader of type `%s'.\n",
                     pszDataset, pszReaderName );
        return FALSE;
    }

    poSession->destroyStringArray( poParms );

    return TRUE;
}