本文整理汇总了C++中UnitPtr::destroy方法的典型用法代码示例。如果您正苦于以下问题:C++ UnitPtr::destroy方法的具体用法?C++ UnitPtr::destroy怎么用?C++ UnitPtr::destroy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnitPtr
的用法示例。
在下文中一共展示了UnitPtr::destroy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: out
//.........这里部分代码省略.........
{
cppArgs.push_back("-D" + *i);
}
}
if(opts.isSet("U"))
{
vector<string> optargs = opts.argVec("U");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
cppArgs.push_back("-U" + *i);
}
}
if(opts.isSet("I"))
{
includePaths = opts.argVec("I");
for(vector<string>::const_iterator i = includePaths.begin(); i != includePaths.end(); ++i)
{
cppArgs.push_back("-I" + *i);
}
}
debug = opts.isSet("d") || opts.isSet("debug");
all = opts.isSet("all");
checksum = opts.isSet("checksum");
bool ignoreRedefs = false;
bool keepComments = true;
for(vector<string>::const_iterator p = files.begin(); p != files.end(); ++p)
{
string file = *p;
Slice::PreprocessorPtr icecpp = Slice::Preprocessor::create("icecpp", file, cppArgs);
FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__");
if(cppHandle == 0)
{
PyErr_Format(PyExc_RuntimeError, "Slice preprocessing failed for `%s'", cmd);
return 0;
}
UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all, ice, underscore);
int parseStatus = u->parse(file, cppHandle, debug);
if(!icecpp->close() || parseStatus == EXIT_FAILURE)
{
PyErr_Format(PyExc_RuntimeError, "Slice parsing failed for `%s'", cmd);
u->destroy();
return 0;
}
//
// Generate the Python code into a string stream.
//
ostringstream codeStream;
IceUtilInternal::Output out(codeStream);
out.setUseTab(false);
//
// Emit a Python magic comment to set the file encoding.
// It must be the first or second line.
//
out << "# -*- coding: utf-8 -*-\n";
generate(u, all, checksum, includePaths, out);
u->destroy();
string code = codeStream.str();
//
// We need to invoke Ice.updateModules() so that all of the types we've just generated
// are made "public".
//
code += "\nIce.updateModules()\n";
PyObjectHandle src = Py_CompileString(const_cast<char*>(code.c_str()), const_cast<char*>(file.c_str()),
Py_file_input);
if(!src.get())
{
return 0;
}
PyObjectHandle globals = PyDict_New();
if(!globals.get())
{
return 0;
}
PyDict_SetItemString(globals.get(), "__builtins__", PyEval_GetBuiltins());
#if PY_VERSION_HEX >= 0x03000000
PyObjectHandle val = PyEval_EvalCode(src.get(), globals.get(), 0);
#else
PyObjectHandle val = PyEval_EvalCode(reinterpret_cast<PyCodeObject*>(src.get()), globals.get(), 0);
#endif
if(!val.get())
{
return 0;
}
}
Py_INCREF(Py_None);
return Py_None;
}
示例2: hidden
//.........这里部分代码省略.........
//}
//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;
}
示例3: if
//.........这里部分代码省略.........
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--ice") == 0)
{
ice = true;
for(int i = idx ; i + 1 < argc ; ++i)
{
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--case-sensitive") == 0)
{
caseSensitive = true;
for(int i = idx ; i + 1 < argc ; ++i)
{
argv[i] = argv[i + 1];
}
--argc;
}
else if(strcmp(argv[idx], "--output-dir") == 0)
{
if(idx + 1 >= argc)
{
cerr << argv[0] << ": argument expected for`" << argv[idx] << "'" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
output = argv[idx + 1];
for(int i = idx ; i + 2 < argc ; ++i)
{
argv[i] = argv[i + 2];
}
argc -= 2;
}
else if(argv[idx][0] == '-')
{
cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
else
{
++idx;
}
}
if(argc < 2)
{
cerr << argv[0] << ": no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
UnitPtr p = Unit::createUnit(true, false, ice, caseSensitive);
int status = EXIT_SUCCESS;
for(idx = 1 ; idx < argc ; ++idx)
{
Preprocessor icecpp(argv[0], argv[idx], cppArgs);
FILE* cppHandle = icecpp.preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
int parseStatus = u->parse(cppHandle, debug);
if(!icecpp.close())
{
u->destroy();
return EXIT_FAILURE;
}
if(parseStatus == EXIT_FAILURE)
{
status = EXIT_FAILURE;
}
else
{
Gen gen(argv[0], icecpp.getBaseName(), output);
if(!gen)
{
u->destroy();
return EXIT_FAILURE;
}
gen.generate(u);
}
u->destroy();
}
return status;
}
示例4: FileException
//.........这里部分代码省略.........
getErrorStream() << argv[0] << ": error: no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
for(i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(Preprocessor::PHP, includePaths))
{
return EXIT_FAILURE;
}
if(!icecpp->close())
{
return EXIT_FAILURE;
}
}
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
{
char buf[4096];
while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
{
if(fputs(buf, stdout) == EOF)
示例5: icecpp
//.........这里部分代码省略.........
string output = opts.optArg("output-dir");
string dllExport = opts.optArg("dll-export");
bool impl = opts.isSet("impl");
bool depend = opts.isSet("depend");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool caseSensitive = opts.isSet("case-sensitive");
if(args.empty())
{
cerr << argv[0] << ": no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
for(i = args.begin(); i != args.end(); ++i)
{
if(depend)
{
Preprocessor icecpp(argv[0], *i, cppArgs);
icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths);
}
else
{
Preprocessor icecpp(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp.preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
{
char buf[4096];
while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
{
if(fputs(buf, stdout) == EOF)
{
return EXIT_FAILURE;
}
}
if(!icecpp.close())
{
return EXIT_FAILURE;
}
}
else
{
UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
int parseStatus = u->parse(*i, cppHandle, debug, Slice::IceE);
if(!icecpp.close())
{
u->destroy();
return EXIT_FAILURE;
}
if(parseStatus == EXIT_FAILURE)
{
status = EXIT_FAILURE;
}
else
{
Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
includePaths, dllExport, output, impl, ice);
if(!gen)
{
u->destroy();
return EXIT_FAILURE;
}
gen.generate(u);
}
u->destroy();
}
}
{
IceUtil::StaticMutex::Lock lock(_mutex);
if(_interrupted)
{
return EXIT_FAILURE;
}
}
}
return status;
}
示例6: gen
//.........这里部分代码省略.........
ChecksumMap checksums;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
if(dependxml)
{
cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
for(i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(depend ? Preprocessor::Java : Preprocessor::JavaXML, includePaths))
{
return EXIT_FAILURE;
}
if(!icecpp->close())
{
return EXIT_FAILURE;
}
}
else
{
ostringstream os;
if(listGenerated)
{
Slice::setErrorStream(os);
}
FileTracker::instance()->setSource(*i);
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(true);
if(cppHandle == 0)
{
if(listGenerated)
示例7: FileException
//.........这里部分代码省略.........
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
bool keepComments = true;
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2PY__");
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(Preprocessor::Python, includePaths,
"-D__SLICE2PY__", "", prefix))
{
return EXIT_FAILURE;
}
if(!icecpp->close())
{
return EXIT_FAILURE;
}
}
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(keepComments, "-D__SLICE2PY__");
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
{
char buf[4096];
while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
{
示例8: if
//.........这里部分代码省略.........
}
else if(dependxml)
{
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
//
// Create a copy of args without the duplicates.
//
vector<string> sources;
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
vector<string>::iterator p = find(sources.begin(), sources.end(), *i);
if(p == sources.end())
{
sources.push_back(*i);
}
}
for(vector<string>::const_iterator i = sources.begin(); i != sources.end();)
{
if(depend || dependJSON || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2JS__");
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
return EXIT_FAILURE;
}
bool last = (++i == sources.end());
if(!icecpp->printMakefileDependencies(os,
depend ? Preprocessor::JavaScript : (dependJSON ? Preprocessor::JavaScriptJSON : Preprocessor::SliceXML),
includePaths,
"-D__SLICE2JS__"))
{
return EXIT_FAILURE;
}
if(!icecpp->close())
{
return EXIT_FAILURE;
}
if(dependJSON)
{
if(!last)
{
os << ",";
}
os << "\n";
}
}
else
{
示例9: icecpp
//.........这里部分代码省略.........
string output = opts.optArg("output-dir");
string dllExport = opts.optArg("dll-export");
bool impl = opts.isSet("impl");
bool depend = opts.isSet("depend");
bool debug = opts.isSet("debug");
bool ice = opts.isSet("ice");
bool checksum = opts.isSet("checksum");
bool stream = opts.isSet("stream");
bool caseSensitive = opts.isSet("case-sensitive");
// alexm: custom options
string module = opts.optArg("module");
bool genUtil = opts.isSet("util");
bool genLog = opts.isSet("log");
if ( !depend && !genUtil && !genLog )
{
cerr << argv[0] << ": no output type specified" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
if ( genUtil && genLog )
{
cerr << argv[0] << ": more than one output type specified" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
// alexm: end custom options
if(args.empty())
{
cerr << argv[0] << ": no input file" << endl;
usage(argv[0]);
return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
for(i = args.begin(); i != args.end(); ++i)
{
if(depend)
{
Preprocessor icecpp(argv[0], *i, cppArgs);
icecpp.printMakefileDependencies(Preprocessor::CPlusPlus, includePaths);
}
else
{
Preprocessor icecpp(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp.preprocess(false);
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
int parseStatus = u->parse(*i, cppHandle, debug);
if(!icecpp.close())
{
u->destroy();
return EXIT_FAILURE;
}
if(parseStatus == EXIT_FAILURE)
{
status = EXIT_FAILURE;
}
else
{
slice2orca::Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
includePaths, dllExport, output, impl, checksum, stream, ice,
module, genUtil, genLog );
if(!gen)
{
u->destroy();
return EXIT_FAILURE;
}
gen.generate(u);
}
u->destroy();
}
}
return status;
}
示例10: out
//.........这里部分代码省略.........
IceUtil::CtrlCHandler ctrlCHandler;
ctrlCHandler.setCallback(interruptedCallback);
DependOutputUtil out(dependFile);
if(dependxml)
{
out.os() << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<dependencies>" << endl;
}
for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
//
// Ignore duplicates.
//
vector<string>::iterator p = find(args.begin(), args.end(), *i);
if(p != i)
{
continue;
}
if(depend || dependxml)
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(false, "-D__SLICE2CS__");
if(cppHandle == 0)
{
out.cleanup();
return EXIT_FAILURE;
}
UnitPtr u = Unit::createUnit(false, false, ice, underscore);
int parseStatus = u->parse(*i, cppHandle, debug);
u->destroy();
if(parseStatus == EXIT_FAILURE)
{
out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->printMakefileDependencies(out.os(), depend ? Preprocessor::CSharp : Preprocessor::SliceXML, includePaths,
"-D__SLICE2CS__"))
{
out.cleanup();
return EXIT_FAILURE;
}
if(!icecpp->close())
{
out.cleanup();
return EXIT_FAILURE;
}
}
else
{
PreprocessorPtr icecpp = Preprocessor::create(argv[0], *i, cppArgs);
FILE* cppHandle = icecpp->preprocess(true, "-D__SLICE2CS__");
if(cppHandle == 0)
{
return EXIT_FAILURE;
}
if(preprocess)
{
char buf[4096];