📄 package.cxx
字号:
// ----------------------------------------------------------------------------// Syntax: license_proc <tclcode>intCdlPackageBody::parse_license_proc(CdlInterpreter interp, int argc, const char* argv[]){ CYG_REPORT_FUNCNAMETYPE("parse_license_proc", "result %d"); int result = CdlParse::parse_tclcode_property(interp, argc, argv, CdlPropertyId_LicenseProc, 0, 0); CYG_REPORT_RETVAL(result); return result;}// ----------------------------------------------------------------------------boolCdlPackageBody::is_hardware_package() const{ CYG_REPORT_FUNCNAMETYPE("CdlPackage::is_hardware_package", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = false; if (has_property(CdlPropertyId_Hardware)) { result = true; } CYG_REPORT_RETVAL(result); return result;}boolCdlPackageBody::has_install_proc() const{ CYG_REPORT_FUNCNAMETYPE("CdlPackage::has_install_proc", "result 5d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = false; if (has_property(CdlPropertyId_InstallProc)) { result = true; } CYG_REPORT_RETVAL(result); return result;}const cdl_tcl_code&CdlPackageBody::get_install_proc() const{ CYG_REPORT_FUNCNAME("CdlPackage::get_install_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); static cdl_tcl_code null_result = ""; cdl_tcl_code& result = null_result; CdlProperty prop = get_property(CdlPropertyId_InstallProc); if (0 != prop) { CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); result = tclprop->get_code(); } CYG_REPORT_RETURN(); return result;}boolCdlPackageBody::has_license_proc() const{ CYG_REPORT_FUNCNAMETYPE("CdlPackage::has_install_proc", "result 5d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = false; if (has_property(CdlPropertyId_LicenseProc)) { result = true; } CYG_REPORT_RETVAL(result); return result;}const cdl_tcl_code&CdlPackageBody::get_license_proc() const{ CYG_REPORT_FUNCNAME("CdlPackage::get_install_proc"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); static cdl_tcl_code null_result = ""; cdl_tcl_code& result = null_result; CdlProperty prop = get_property(CdlPropertyId_LicenseProc); if (0 != prop) { CdlProperty_TclCode tclprop = dynamic_cast<CdlProperty_TclCode>(prop); result = tclprop->get_code(); } CYG_REPORT_RETURN(); return result;}//}}}//{{{ Propagation support // ----------------------------------------------------------------------------voidCdlPackageBody::update(CdlTransaction transaction, CdlUpdate update){ CYG_REPORT_FUNCNAME("CdlPackage::update"); this->CdlValuableBody::update(transaction, update); this->CdlContainerBody::update(transaction, update); CYG_REPORT_RETURN();}//}}}//{{{ Persistence support // ----------------------------------------------------------------------------voidCdlPackageBody::initialize_savefile_support(CdlToplevel toplevel){ CYG_REPORT_FUNCNAME("CdlPackage::initialize_savefile_support"); toplevel->add_savefile_command("cdl_package", 0, &savefile_package_command); CdlValuableBody::initialize_savefile_support(toplevel, "cdl_package");}voidCdlPackageBody::save(CdlInterpreter interp, Tcl_Channel chan, int indentation, bool minimal){ CYG_REPORT_FUNCNAME("CdlPackage::save"); CYG_REPORT_FUNCARG5XV(this, interp, chan, indentation, minimal); CYG_PRECONDITION_THISC(); CYG_PRECONDITION_CLASSC(interp); // For a minimal save there is sufficient data in the savefile header // to allow the package to be loaded. It is still necessary to output // a cdl_package command if there were additional savefile strings. if (!minimal || this->has_additional_savefile_information()) { // Start with the UserVisible data, which will result in a suitable set // of comments before the package definition itself. this->CdlUserVisibleBody::save(interp, chan, indentation, minimal); // Now output the line "cdl_package <name> {" // The name is guaranteed to be a valid C preprocessor symbol, so it // is not going to need any quoting. std::string data = std::string(indentation, ' ') + "cdl_package " + get_name() + " {\n"; std::string indent_string = std::string(indentation + 4, ' '); // The value associated with a package cannot be changed simply // by editing the savefile. Add a comment to that effect. if (!minimal) { data += indent_string + "# Packages cannot be added or removed, nor can their version be changed,\n"; data += indent_string + "# simply by editing their value. Instead the appropriate configuration\n"; data += indent_string + "# should be used to perform these actions.\n\n"; } // Output the command and the comment. interp->write_data(chan, data); // Deal with the value this->CdlValuableBody::save(interp, chan, indentation + 4, false, minimal); // And with any unrecognised data this->CdlNodeBody::save(interp, chan, indentation + 4, minimal); // Close the cdl_package body. A blank line is added here. data = "};\n\n"; interp->write_data(chan, data); } // Packages are containers, so dump the contents as well. this->CdlContainerBody::save(interp, chan, indentation, minimal); CYG_REPORT_RETURN();}intCdlPackageBody::savefile_package_command(CdlInterpreter interp, int argc, const char* argv[]){ CYG_REPORT_FUNCNAMETYPE("CdlPackage::savefile_package_command", "result %d"); CYG_PRECONDITION_CLASSC(interp); int result = TCL_OK; CdlToplevel toplevel = interp->get_toplevel(); CYG_ASSERT_CLASSC(toplevel); CdlConfiguration config = dynamic_cast<CdlConfiguration>(toplevel); CYG_ASSERT_CLASSC(config); std::vector<CdlInterpreterCommandEntry> subcommands; std::vector<CdlInterpreterCommandEntry>* toplevel_commands = 0; CdlNode old_node = 0; try { if (3 != argc) { CdlParse::report_error(interp, "", "Invalid cdl_package command in savefile, expecting two arguments."); } else { CdlNode current_node = config->lookup(argv[1]); if (0 == current_node) { CdlParse::report_error(interp, "", std::string("The savefile contains a cdl_package command for `") + argv[1] + "' which has not been loaded."); } else { config->get_savefile_subcommands("cdl_package", subcommands); toplevel_commands = interp->push_commands(subcommands); old_node = interp->push_node(current_node); std::string tcl_result; result = interp->eval(argv[2], tcl_result); interp->pop_commands(toplevel_commands); toplevel_commands = 0; interp->pop_node(old_node); old_node = 0; } } } catch(...) { if (0 != old_node) { interp->pop_node(old_node); } if (0 != toplevel_commands) { interp->pop_commands(toplevel_commands); } throw; } CYG_REPORT_RETVAL(result); return result;}//}}}//{{{ check_this() // ----------------------------------------------------------------------------boolCdlPackageBody::check_this(cyg_assert_class_zeal zeal) const{ if (CdlPackageBody_Magic != cdlpackagebody_cookie) { return false; } CYGDBG_MEMLEAK_CHECKTHIS(); return CdlNodeBody::check_this(zeal) && CdlContainerBody::check_this(zeal) && CdlLoadableBody::check_this(zeal) && CdlUserVisibleBody::check_this(zeal) && CdlValuableBody::check_this(zeal) && CdlParentableBody::check_this(zeal) && CdlBuildableBody::check_this(zeal) && CdlBuildLoadableBody::check_this(zeal) && CdlDefinableBody::check_this(zeal) && CdlDefineLoadableBody::check_this(zeal);}//}}}//{{{ Misc // ----------------------------------------------------------------------------std::stringCdlPackageBody::get_class_name() const{ CYG_REPORT_FUNCNAME("CdlPackage::get_class_name"); CYG_PRECONDITION_THISC(); CYG_REPORT_RETURN(); return "package";}// BLV: there is an argument for forcing hardware packages to// send their configuration data to a single header file// <pkgconf/hardware.h>, so that any code can #include a// single file to get hold of the hardware details. This// is suppressed for now while the details are sorted out.std::stringCdlPackageBody::get_config_header() const{ CYG_REPORT_FUNCNAME("CdlPackage::get_config_header"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_CLASSC(this); std::string result = "";#if 0 if (has_property(CdlPropertyId_Hardware)) { result = "hardware.h"; } else { result = CdlDefineLoadableBody::get_config_header(); }#else result = CdlDefineLoadableBody::get_config_header();#endif CYG_REPORT_RETURN(); return result;}boolCdlPackageBody::belongs_to_template() const{ CYG_REPORT_FUNCNAMETYPE("CdlPackage::belongs_to_template", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = loaded_for_template; CYG_REPORT_RETVAL(result); return result;}boolCdlPackageBody::belongs_to_hardware() const{ CYG_REPORT_FUNCNAMETYPE("CdlPackage::belongs_to_hardware", "result %d"); CYG_REPORT_FUNCARG1XV(this); CYG_PRECONDITION_THISC(); bool result = loaded_for_hardware; CYG_REPORT_RETVAL(result); return result;}//}}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -