예제 #1
0
void
PackageVisitor::createModules(const UnitPtr& unit, const string& module, const string& dir)
{
    StringList modules;
    PackageVisitor v(modules);
    unit->visit(&v, false);

    for(StringList::iterator p = modules.begin(); p != modules.end(); ++p)
    {
        vector<string> v;
        if(!IceUtilInternal::splitString(*p, ".", v))
        {
            assert(false);
        }
        string currentModule;
        string path = dir.empty() ? "." : dir;
        for(vector<string>::iterator q = v.begin(); q != v.end(); ++q)
        {
            if(q != v.begin())
            {
                addSubmodule(path, currentModule, *q);
                currentModule += ".";
            }

            currentModule += *q;
            path += "/" + *q;
            createDirectory(path);

            addModule(path, currentModule, module);
        }
    }
}
예제 #2
0
파일: Util.cpp 프로젝트: ming-hai/freeze
void
FreezeScript::collectCompactIds(const UnitPtr& u, const FreezeScript::CompactIdResolverIPtr& r)
{
    class Visitor : public ParserVisitor
    {
    public:

        Visitor(const FreezeScript::CompactIdResolverIPtr& resolver) : _r(resolver)
        {
        }

        virtual bool visitClassDefStart(const ClassDefPtr& p)
        {
            if(p->compactId() != -1)
            {
                _r->add(p->compactId(), p->scoped());
            }
            return true;
        }

        FreezeScript::CompactIdResolverIPtr _r;
    };

    Visitor v(r);
    u->visit(&v, false);
}
예제 #3
0
파일: Checksum.cpp 프로젝트: wuhua988/icm
Slice::ChecksumMap Slice::createChecksums(const UnitPtr& u)
{
  ChecksumMap result;

  ChecksumVisitor visitor(result);
  u->visit(&visitor, false);

  return result;
}
예제 #4
0
void
Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<string>& includePaths, Output& out)
{
    out << nl << "require 'Ice'";

    if(!all)
    {
        vector<string> paths = includePaths;
        for(vector<string>::iterator p = paths.begin(); p != paths.end(); ++p)
        {
            *p = fullPath(*p);
        }

        StringList includes = un->includeFiles();
        for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
        {
            string file = changeInclude(*q, paths);
            out << nl << "require '" << file << ".rb'";
        }
    }

    CodeVisitor codeVisitor(out);
    un->visit(&codeVisitor, false);

    if(checksum)
    {
        ChecksumMap checksums = createChecksums(un);
        if(!checksums.empty())
        {
            out << sp;
            for(ChecksumMap::const_iterator p = checksums.begin(); p != checksums.end(); ++p)
            {
                out << nl << "::Ice::SliceChecksums[\"" << p->first << "\"] = \"";
                ostringstream str;
                str.flags(ios_base::hex);
                str.fill('0');
                for(vector<unsigned char>::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
                {
                    str << (int)(*q);
                }
                out << str.str() << "\"";
            }
        }
    }

    out << nl; // Trailing newline.
}
예제 #5
0
파일: main.cpp 프로젝트: manics/slice2rst
int
main(int argc, char* argv[])
{
    vector<string> cppArgs;
    //bool preprocess;
    //string include;
    //string output;
    //string dllExport;
    //bool impl;
    //bool depend;
    //bool debug;
    //bool ice;
    //bool checksum;
    //bool stream;
    //bool caseSensitive;

    string inputFilename;

#ifdef false
    po::variables_map vm;

    //try
    //{

    po::options_description hidden("Hidden options");
    hidden.add_options()
        ("input-file", po::value< vector<string> >(), "input file")
        ;


    po::options_description allowed("Allowed options");
    allowed.add_options()
        ("help", "produce help message")
        ("output", po::value<std::string>(), "output file name")
        ;

    po::options_description cmdline("Command line options");
    cmdline.add(allowed).add(hidden);

    po::positional_options_description p;
    p.add("input-file", -1);

    po::store(po::command_line_parser(argc, argv).
              options(cmdline).positional(p).run(), vm);

    po::notify(vm);

    if (vm.count("help"))
    {
        cout << allowed << "\n";
        return 1;
    }

    if ( vm.count("input-file"))
    {
        vector<string> sv = vm["input-file"].as<vector<string> >();
        //for (vector<string>::iterator i=sv.begin(); i!=sv.end(); i++)
        //{
        //cout << *i << "\n";
        //}

        inputFilename = sv[0];
    }

    if (vm.count("output"))
    {
        cout << "Output filename is " << vm["output"].as<std::string>() << "\n";
    }

    //}
    //catch(...)
    //{
    //cout << "CRAP!\n";
    //}


    cout << "Input file is \"" << inputFilename << "\"\n";

#endif

    IceUtilInternal::Options opts;
    opts.addOpt("h", "help");
    opts.addOpt("I", "", IceUtilInternal::Options::NeedArg, "",
                IceUtilInternal::Options::Repeat);


    vector<string> args;
    try
    {
        args = opts.parse(argc, argv);
    }
    catch(const IceUtilInternal::BadOptException& e)
    {
        cerr << argv[0] << ": " << e.reason << endl;
        usage(argv[0]);
        return EXIT_FAILURE;
    }

    if(opts.isSet("h") || opts.isSet("help"))
    {
        usage(argv[0]);
        return EXIT_SUCCESS;
    }

    vector<string> includePaths;
    includePaths = opts.argVec("I");
    for (vector<string>::const_iterator i=includePaths.begin(); i!=includePaths.end(); ++i)
    {
        cppArgs.push_back("-I" + Preprocessor::normalizeIncludePath(*i));
    }

    if(args.empty())
    {
        cerr << argv[0] << ": no input file" << endl;
        usage(argv[0]);
        return EXIT_FAILURE;
    }

    int status = EXIT_SUCCESS;

    vector<string>::const_iterator i = args.begin();
    std::string filename = *i;
#if ICE_INT_VERSION / 100 < 304
    Preprocessor* icecpp = new Preprocessor(argv[0], *i, cppArgs);
#else
    PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
#endif

    FILE* cppHandle = icecpp->preprocess(true);

    if (cppHandle == 0)
    {
        return EXIT_FAILURE;
    }

//#if ICE_INT_VERSION / 100 < 304
    bool ignRedefs = false;
    bool all = false;
    bool allowIcePrefix = false;
    bool caseSensitive = true;
    //StringList defaultGlobalMetadata;
    UnitPtr u = Unit::createUnit(ignRedefs, all, allowIcePrefix, caseSensitive);
//#else
//      UnitPtr u = Unit::createUnit(false, false, false);
//#endif

    int parseStatus = u->parse(*i, cppHandle, false);

    if ( parseStatus == EXIT_FAILURE )
    {
        cerr << "Parsing failed";
        exit(0);
    }

    if(!icecpp->close())
    {
        u->destroy();
        return EXIT_FAILURE;
    }


    BasicClassLinkHandler linker;
    RstGen rstGen(linker);
    u->visit(&rstGen, true);

    u->destroy();

    return status;
}
예제 #6
0
파일: ObjCUtil.cpp 프로젝트: joshmoore/ice
void
Slice::ObjCGenerator::validateMetaData(const UnitPtr& u)
{
    MetaDataVisitor visitor;
    u->visit(&visitor, true);
}