Refactored Macro and MacroCollection into lym library for better reuse.

This commit is contained in:
Matthias Koefferlein 2017-08-22 23:39:55 +02:00
parent 9633a1b9af
commit cbc5697253
29 changed files with 643 additions and 594 deletions

View File

@ -10,6 +10,7 @@ SUBDIRS = \
gsi \ gsi \
db \ db \
rdb \ rdb \
lym \
laybasic \ laybasic \
lay \ lay \
ant \ ant \
@ -45,23 +46,23 @@ ant.depends += laybasic
img.depends += laybasic img.depends += laybasic
edt.depends += laybasic edt.depends += laybasic
buddies.depends += db tl gsi ut lym.depends += tl gsi
lay.depends += laybasic ant img edt
equals(HAVE_RUBY, "1") { equals(HAVE_RUBY, "1") {
lay.depends += rba lym.depends += rba
} else { } else {
lay.depends += rbastub lym.depends += rbastub
} }
equals(HAVE_PYTHON, "1") { equals(HAVE_PYTHON, "1") {
lay.depends += pya lym.depends += pya
} else { } else {
lay.depends += pyastub lym.depends += pyastub
} }
lay.depends += laybasic ant img edt lym
lib.depends += db lib.depends += db
buddies.depends += db tl gsi ut
equals(HAVE_QTBINDINGS, "1") { equals(HAVE_QTBINDINGS, "1") {
SUBDIRS += gsiqt SUBDIRS += gsiqt
gsiqt.depends += gsi gsiqt.depends += gsi

View File

@ -6,6 +6,7 @@ include($$PWD/../klayout.pri)
TARGET = klayout TARGET = klayout
include($$PWD/../app.pri) include($$PWD/../app.pri)
include($$PWD/../with_all_libs.pri)
HEADERS = \ HEADERS = \
@ -16,10 +17,6 @@ SOURCES = \
RESOURCES = \ RESOURCES = \
INCLUDEPATH += ../tl ../gsi ../db ../rdb ../laybasic ../lay ../ext ../img ../ant ../lib ../version
DEPENDPATH += ../tl ../gsi ../db ../rdb ../laybasic ../lay ../ext ../img ../ant ../lib ../version
LIBS += $$PYTHONLIBFILE $$RUBYLIBFILE -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_laybasic -lklayout_lay -lklayout_ant -lklayout_img -lklayout_edt -lklayout_ext -lklayout_lib
win32 { win32 {
windres.target = klayout_rc.o windres.target = klayout_rc.o
@ -32,34 +29,3 @@ win32 {
LIBS += $$windres.target LIBS += $$windres.target
} }
# Note: this accounts for UI-generated headers placed into the output folders in
# shadow builds:
INCLUDEPATH += $$DESTDIR/laybasic $$OUT_PWD/../lay
DEPENDPATH += $$DESTDIR/laybasic $$OUT_PWD/../lay
equals(HAVE_QTBINDINGS, "1") {
INCLUDEPATH += ../gsiqt
DEPENDPATH += ../gsiqt
LIBS += -lklayout_gsiqt
}
equals(HAVE_RUBY, "1") {
INCLUDEPATH += ../rba
DEPENDPATH += ../rba
LIBS += -lklayout_rba
} else {
INCLUDEPATH += ../rbastub
DEPENDPATH += ../rbastub
LIBS += -lklayout_rbastub
}
equals(HAVE_PYTHON, "1") {
INCLUDEPATH += ../pya
DEPENDPATH += ../pya
LIBS += -lklayout_pya
} else {
INCLUDEPATH += ../pyastub
DEPENDPATH += ../pyastub
LIBS += -lklayout_pyastub
}

View File

@ -19,12 +19,10 @@ HEADERS = \
layHelpSource.h \ layHelpSource.h \
layLayoutStatisticsForm.h \ layLayoutStatisticsForm.h \
layLogViewerDialog.h \ layLogViewerDialog.h \
layMacro.h \
layMacroEditorDialog.h \ layMacroEditorDialog.h \
layMacroEditorPage.h \ layMacroEditorPage.h \
layMacroEditorSetupDialog.h \ layMacroEditorSetupDialog.h \
layMacroEditorTree.h \ layMacroEditorTree.h \
layMacroInterpreter.h \
layMacroPropertiesDialog.h \ layMacroPropertiesDialog.h \
layMacroVariableView.h \ layMacroVariableView.h \
layMainConfigPages.h \ layMainConfigPages.h \
@ -113,7 +111,6 @@ FORMS = \
SOURCES = \ SOURCES = \
gsiDeclLayApplication.cc \ gsiDeclLayApplication.cc \
gsiDeclLayHelpDialog.cc \ gsiDeclLayHelpDialog.cc \
gsiDeclLayMacro.cc \
gsiDeclLayMainWindow.cc \ gsiDeclLayMainWindow.cc \
layApplication.cc \ layApplication.cc \
layClipDialog.cc \ layClipDialog.cc \
@ -126,12 +123,10 @@ SOURCES = \
layHelpSource.cc \ layHelpSource.cc \
layLayoutStatisticsForm.cc \ layLayoutStatisticsForm.cc \
layLogViewerDialog.cc \ layLogViewerDialog.cc \
layMacro.cc \
layMacroEditorDialog.cc \ layMacroEditorDialog.cc \
layMacroEditorPage.cc \ layMacroEditorPage.cc \
layMacroEditorSetupDialog.cc \ layMacroEditorSetupDialog.cc \
layMacroEditorTree.cc \ layMacroEditorTree.cc \
layMacroInterpreter.cc \
layMacroPropertiesDialog.cc \ layMacroPropertiesDialog.cc \
layMacroVariableView.cc \ layMacroVariableView.cc \
layMainConfigPages.cc \ layMainConfigPages.cc \
@ -174,9 +169,9 @@ RESOURCES = layBuildInMacros.qrc \
layResources.qrc \ layResources.qrc \
laySaltTemplates.qrc laySaltTemplates.qrc
INCLUDEPATH += ../tl ../gsi ../db ../rdb ../laybasic ../ant ../img ../edt INCLUDEPATH += ../tl ../gsi ../db ../rdb ../lym ../laybasic ../ant ../img ../edt
DEPENDPATH += ../tl ../gsi ../db ../rdb ../laybasic ../ant ../img ../edt DEPENDPATH += ../tl ../gsi ../db ../rdb ../lym ../laybasic ../ant ../img ../edt
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt
win32 { win32 {
# for stack trace support: # for stack trace support:

View File

@ -29,7 +29,6 @@
#include "layMacroEditorDialog.h" #include "layMacroEditorDialog.h"
#include "layNativePlugin.h" #include "layNativePlugin.h"
#include "layVersion.h" #include "layVersion.h"
#include "layMacro.h"
#include "laySignalHandler.h" #include "laySignalHandler.h"
#include "layRuntimeErrorForm.h" #include "layRuntimeErrorForm.h"
#include "layProgress.h" #include "layProgress.h"
@ -38,6 +37,7 @@
#include "layMacroController.h" #include "layMacroController.h"
#include "layTechnologyController.h" #include "layTechnologyController.h"
#include "laySaltController.h" #include "laySaltController.h"
#include "lymMacro.h"
#include "gtf.h" #include "gtf.h"
#include "gsiDecl.h" #include "gsiDecl.h"
#include "gsiInterpreter.h" #include "gsiInterpreter.h"
@ -795,11 +795,11 @@ Application::Application (int &argc, char **argv, bool non_ui_mode)
} }
// run all early autorun macros // run all early autorun macros
lay::MacroCollection::root ().autorun_early (); lym::MacroCollection::root ().autorun_early ();
// rescan the folders because early autorun macros might have added // rescan the folders because early autorun macros might have added
// suffixes through the MacroInterpreter interface. // suffixes through the MacroInterpreter interface.
lay::MacroCollection::root ().rescan (); lym::MacroCollection::root ().rescan ();
if (mp_qapp_gui) { if (mp_qapp_gui) {
mp_mw = new lay::MainWindow (mp_qapp_gui, "main_window"); mp_mw = new lay::MainWindow (mp_qapp_gui, "main_window");
@ -1119,7 +1119,7 @@ Application::run ()
BEGIN_PROTECTED BEGIN_PROTECTED
std::auto_ptr<lay::Macro> macro (new lay::Macro ()); std::auto_ptr<lym::Macro> macro (new lym::Macro ());
macro->load_from (*m); macro->load_from (*m);
macro->set_file_path (*m); macro->set_file_path (*m);
if (macro->show_in_menu ()) { if (macro->show_in_menu ()) {
@ -1147,7 +1147,7 @@ Application::run ()
} }
// run all autorun macros // run all autorun macros
lay::MacroCollection::root ().autorun (); lym::MacroCollection::root ().autorun ();
if (mp_mw) { if (mp_mw) {
@ -1236,7 +1236,7 @@ Application::run ()
if (! m_run_macro.empty ()) { if (! m_run_macro.empty ()) {
tl::log << "Run macro '" << m_run_macro << "'"; tl::log << "Run macro '" << m_run_macro << "'";
lay::Macro macro; lym::Macro macro;
macro.load_from (m_run_macro); macro.load_from (m_run_macro);
macro.set_file_path (m_run_macro); macro.set_file_path (m_run_macro);
result = macro.run (); result = macro.run ();

View File

@ -50,6 +50,11 @@ namespace tl
class DeferredMethodScheduler; class DeferredMethodScheduler;
} }
namespace lym
{
class MacroCollection;
}
namespace lay namespace lay
{ {
@ -57,7 +62,6 @@ class MainWindow;
class PluginRoot; class PluginRoot;
class ProgressReporter; class ProgressReporter;
class ProgressBar; class ProgressBar;
class MacroCollection;
/** /**
* @brief A tiny struct describing a native plugin * @brief A tiny struct describing a native plugin
@ -285,7 +289,7 @@ public:
* *
* Returns a vector of new macro folders. * Returns a vector of new macro folders.
*/ */
std::vector<lay::MacroCollection *> sync_tech_macro_locations (); std::vector<lym::MacroCollection *> sync_tech_macro_locations ();
/** /**
* @brief Obtain the KLayout installation path * @brief Obtain the KLayout installation path

View File

@ -24,11 +24,12 @@
#include "layTechnologyController.h" #include "layTechnologyController.h"
#include "laySaltController.h" #include "laySaltController.h"
#include "layMacroEditorDialog.h" #include "layMacroEditorDialog.h"
#include "layMacroInterpreter.h"
#include "layMainWindow.h" #include "layMainWindow.h"
#include "layMainConfigPages.h" #include "layMainConfigPages.h"
#include "layConfig.h" #include "layConfig.h"
#include "layApplication.h" #include "layApplication.h"
#include "lymMacroInterpreter.h"
#include "lymMacro.h"
#include <QDir> #include <QDir>
#include <QUrl> #include <QUrl>
@ -45,7 +46,7 @@ MacroController::MacroController ()
dm_sync_files (this, &MacroController::sync_files) dm_sync_files (this, &MacroController::sync_files)
{ {
connect (&m_temp_macros, SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ())); connect (&m_temp_macros, SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
connect (&m_temp_macros, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ())); connect (&m_temp_macros, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
} }
void void
@ -54,8 +55,8 @@ MacroController::load ()
// Scan built-in macros // Scan built-in macros
// These macros are always taken, even if there are no macros requested (they are required to // These macros are always taken, even if there are no macros requested (they are required to
// fully form the API). // fully form the API).
lay::MacroCollection::root ().add_folder (tl::to_string (QObject::tr ("Built-In")), ":/built-in-macros", "macros", true); lym::MacroCollection::root ().add_folder (tl::to_string (QObject::tr ("Built-In")), ":/built-in-macros", "macros", true);
lay::MacroCollection::root ().add_folder (tl::to_string (QObject::tr ("Built-In")), ":/built-in-pymacros", "pymacros", true); lym::MacroCollection::root ().add_folder (tl::to_string (QObject::tr ("Built-In")), ":/built-in-pymacros", "pymacros", true);
// TODO: consider adding "drc" dynamically and allow more dynamic categories // TODO: consider adding "drc" dynamically and allow more dynamic categories
m_macro_categories.push_back (std::pair<std::string, std::string> ("macros", tl::to_string (QObject::tr ("Ruby")))); m_macro_categories.push_back (std::pair<std::string, std::string> ("macros", tl::to_string (QObject::tr ("Ruby"))));
@ -68,7 +69,7 @@ MacroController::load ()
for (size_t c = 0; c < m_macro_categories.size (); ++c) { for (size_t c = 0; c < m_macro_categories.size (); ++c) {
if (p->cat.empty () || p->cat == m_macro_categories [c].first) { if (p->cat.empty () || p->cat == m_macro_categories [c].first) {
std::string mp = tl::to_string (QDir (tl::to_qstring (p->path)).absoluteFilePath (tl::to_qstring (m_macro_categories [c].first))); std::string mp = tl::to_string (QDir (tl::to_qstring (p->path)).absoluteFilePath (tl::to_qstring (m_macro_categories [c].first)));
lay::MacroCollection::root ().add_folder (p->description, mp, m_macro_categories [c].first, p->readonly); lym::MacroCollection::root ().add_folder (p->description, mp, m_macro_categories [c].first, p->readonly);
} }
} }
@ -84,7 +85,7 @@ MacroController::initialized (lay::PluginRoot *root)
{ {
mp_mw = dynamic_cast <lay::MainWindow *> (root); mp_mw = dynamic_cast <lay::MainWindow *> (root);
if (mp_mw) { if (mp_mw) {
mp_macro_editor = new lay::MacroEditorDialog (mp_mw, &lay::MacroCollection::root ()); mp_macro_editor = new lay::MacroEditorDialog (mp_mw, &lym::MacroCollection::root ());
mp_macro_editor->setModal (false); mp_macro_editor->setModal (false);
} }
@ -94,8 +95,8 @@ MacroController::initialized (lay::PluginRoot *root)
connect (m_file_watcher, SIGNAL (fileRemoved (const QString &)), this, SLOT (file_watcher_triggered ())); connect (m_file_watcher, SIGNAL (fileRemoved (const QString &)), this, SLOT (file_watcher_triggered ()));
} }
connect (&lay::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ())); connect (&lym::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
connect (&lay::MacroCollection::root (), SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ())); connect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
if (lay::TechnologyController::instance ()) { if (lay::TechnologyController::instance ()) {
connect (lay::TechnologyController::instance (), SIGNAL (active_technology_changed ()), this, SLOT (macro_collection_changed ())); connect (lay::TechnologyController::instance (), SIGNAL (active_technology_changed ()), this, SLOT (macro_collection_changed ()));
connect (lay::TechnologyController::instance (), SIGNAL (technologies_edited ()), this, SLOT (sync_with_external_sources ())); connect (lay::TechnologyController::instance (), SIGNAL (technologies_edited ()), this, SLOT (sync_with_external_sources ()));
@ -115,8 +116,8 @@ MacroController::initialized (lay::PluginRoot *root)
void void
MacroController::uninitialize (lay::PluginRoot * /*root*/) MacroController::uninitialize (lay::PluginRoot * /*root*/)
{ {
disconnect (&lay::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ())); disconnect (&lym::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
disconnect (&lay::MacroCollection::root (), SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ())); disconnect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
if (lay::TechnologyController::instance ()) { if (lay::TechnologyController::instance ()) {
disconnect (lay::TechnologyController::instance (), SIGNAL (active_technology_changed ()), this, SLOT (macro_collection_changed ())); disconnect (lay::TechnologyController::instance (), SIGNAL (active_technology_changed ()), this, SLOT (macro_collection_changed ()));
disconnect (lay::TechnologyController::instance (), SIGNAL (technologies_edited ()), this, SLOT (sync_with_external_sources ())); disconnect (lay::TechnologyController::instance (), SIGNAL (technologies_edited ()), this, SLOT (sync_with_external_sources ()));
@ -188,7 +189,7 @@ MacroController::accepts_drop (const std::string &path_or_url) const
} }
// check the suffixes in the DSL interpreter declarations // check the suffixes in the DSL interpreter declarations
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (suffix == tl::to_qstring (cls->suffix ())) { if (suffix == tl::to_qstring (cls->suffix ())) {
return true; return true;
} }
@ -211,7 +212,7 @@ MacroController::drop_url (const std::string &path_or_url)
} }
// load and run macro // load and run macro
std::auto_ptr<lay::Macro> macro (new lay::Macro ()); std::auto_ptr<lym::Macro> macro (new lym::Macro ());
macro->load_from (path); macro->load_from (path);
macro->set_file_path (path); macro->set_file_path (path);
@ -349,7 +350,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
} }
} }
external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].first, lay::MacroCollection::TechFolder, readonly_paths.find (t->first) != readonly_paths.end ())); external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].first, lym::MacroCollection::TechFolder, readonly_paths.find (t->first) != readonly_paths.end ()));
} }
@ -376,7 +377,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
if (macro_dir.exists ()) { if (macro_dir.exists ()) {
std::string description = tl::to_string (tr ("Package %1").arg (tl::to_qstring (g->name ()))); std::string description = tl::to_string (tr ("Package %1").arg (tl::to_qstring (g->name ())));
external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].first, lay::MacroCollection::SaltFolder, g->is_readonly ())); external_paths.push_back (ExternalPathDescriptor (tl::to_string (macro_dir.path ()), description, macro_categories () [c].first, lym::MacroCollection::SaltFolder, g->is_readonly ()));
} }
@ -388,7 +389,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
// delete macro collections which are no longer required or update description // delete macro collections which are no longer required or update description
std::vector<lay::MacroCollection *> folders_to_delete; std::vector<lym::MacroCollection *> folders_to_delete;
// determine the paths that will be in use // determine the paths that will be in use
std::map<std::string, const ExternalPathDescriptor *> new_folders_by_path; std::map<std::string, const ExternalPathDescriptor *> new_folders_by_path;
@ -402,11 +403,11 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
prev_folders_by_path.insert (std::make_pair (p->path, p.operator-> ())); prev_folders_by_path.insert (std::make_pair (p->path, p.operator-> ()));
} }
lay::MacroCollection *root = &lay::MacroCollection::root (); lym::MacroCollection *root = &lym::MacroCollection::root ();
for (lay::MacroCollection::child_iterator m = root->begin_children (); m != root->end_children (); ++m) { for (lym::MacroCollection::child_iterator m = root->begin_children (); m != root->end_children (); ++m) {
if (m->second->virtual_mode () == lay::MacroCollection::TechFolder || if (m->second->virtual_mode () == lym::MacroCollection::TechFolder ||
m->second->virtual_mode () == lay::MacroCollection::SaltFolder) { m->second->virtual_mode () == lym::MacroCollection::SaltFolder) {
std::map<std::string, const ExternalPathDescriptor *>::const_iterator u = new_folders_by_path.find (m->second->path ()); std::map<std::string, const ExternalPathDescriptor *>::const_iterator u = new_folders_by_path.find (m->second->path ());
if (u == new_folders_by_path.end ()) { if (u == new_folders_by_path.end ()) {
// no longer used // no longer used
@ -417,7 +418,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
} }
} }
for (std::vector<lay::MacroCollection *>::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { for (std::vector<lym::MacroCollection *>::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) {
if (tl::verbosity () >= 20) { if (tl::verbosity () >= 20) {
tl::info << "Removing macro folder " << (*m)->path () << ", category '" << (*m)->category () << "' because no longer in use"; tl::info << "Removing macro folder " << (*m)->path () << ", category '" << (*m)->category () << "' because no longer in use";
} }
@ -446,7 +447,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
// add new folders // add new folders
std::vector<lay::MacroCollection *> new_folders; std::vector<lym::MacroCollection *> new_folders;
for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) { for (std::vector<ExternalPathDescriptor>::const_iterator p = m_external_paths.begin (); p != m_external_paths.end (); ++p) {
@ -463,7 +464,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
// In that case, the add_folder method will return 0. // In that case, the add_folder method will return 0.
// TODO: is it wise to make this writeable? // TODO: is it wise to make this writeable?
lay::MacroCollection *mc = lay::MacroCollection::root ().add_folder (p->description, p->path, p->cat, p->readonly); lym::MacroCollection *mc = lym::MacroCollection::root ().add_folder (p->description, p->path, p->cat, p->readonly);
if (mc) { if (mc) {
mc->set_virtual_mode (p->type); mc->set_virtual_mode (p->type);
new_folders.push_back (mc); new_folders.push_back (mc);
@ -477,13 +478,13 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
tl::NoDeferredMethods silent; tl::NoDeferredMethods silent;
bool has_autorun = false; bool has_autorun = false;
for (std::vector<lay::MacroCollection *>::const_iterator m = new_folders.begin (); m != new_folders.end () && ! has_autorun; ++m) { for (std::vector<lym::MacroCollection *>::const_iterator m = new_folders.begin (); m != new_folders.end () && ! has_autorun; ++m) {
has_autorun = (*m)->has_autorun (); has_autorun = (*m)->has_autorun ();
} }
if (has_autorun) { if (has_autorun) {
if (! ask_before_autorun || QMessageBox::question (mp_mw, QObject::tr ("Run Macros"), QObject::tr ("Some macros associated with new items are configured to run automatically.\n\nChoose 'Yes' to run these macros now. Choose 'No' to not run them."), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { if (! ask_before_autorun || QMessageBox::question (mp_mw, QObject::tr ("Run Macros"), QObject::tr ("Some macros associated with new items are configured to run automatically.\n\nChoose 'Yes' to run these macros now. Choose 'No' to not run them."), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
for (std::vector<lay::MacroCollection *>::const_iterator m = new_folders.begin (); m != new_folders.end (); ++m) { for (std::vector<lym::MacroCollection *>::const_iterator m = new_folders.begin (); m != new_folders.end (); ++m) {
(*m)->autorun (); (*m)->autorun ();
} }
} }
@ -499,19 +500,19 @@ MacroController::add_path (const std::string &path, const std::string &descripti
} }
void void
MacroController::add_temp_macro (lay::Macro *m) MacroController::add_temp_macro (lym::Macro *m)
{ {
m_temp_macros.add_unspecific (m); m_temp_macros.add_unspecific (m);
} }
void void
MacroController::add_macro_items_to_menu (lay::MacroCollection &collection, int &n, std::set<std::string> &groups, const lay::Technology *tech, std::vector<std::pair<std::string, std::string> > *key_bindings) MacroController::add_macro_items_to_menu (lym::MacroCollection &collection, int &n, std::set<std::string> &groups, const lay::Technology *tech, std::vector<std::pair<std::string, std::string> > *key_bindings)
{ {
for (lay::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) {
// check whether the macro collection is associated with the selected technology (if there is one) // check whether the macro collection is associated with the selected technology (if there is one)
bool consider = false; bool consider = false;
if (! tech || c->second->virtual_mode () != lay::MacroCollection::TechFolder) { if (! tech || c->second->virtual_mode () != lym::MacroCollection::TechFolder) {
consider = true; consider = true;
} else { } else {
const std::vector<std::pair<std::string, std::string> > &mc = macro_categories (); const std::vector<std::pair<std::string, std::string> > &mc = macro_categories ();
@ -526,7 +527,7 @@ MacroController::add_macro_items_to_menu (lay::MacroCollection &collection, int
} }
for (lay::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) {
std::string sc = tl::trim (c->second->shortcut ()); std::string sc = tl::trim (c->second->shortcut ());
@ -558,7 +559,7 @@ MacroController::add_macro_items_to_menu (lay::MacroCollection &collection, int
m_action_to_macro.insert (std::make_pair (a.qaction (), c->second)); m_action_to_macro.insert (std::make_pair (a.qaction (), c->second));
MacroSignalAdaptor *adaptor = new MacroSignalAdaptor (a.qaction (), c->second); lym::MacroSignalAdaptor *adaptor = new lym::MacroSignalAdaptor (a.qaction (), c->second);
QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ())); QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ()));
// store the key bindings in the array // store the key bindings in the array
@ -581,7 +582,7 @@ MacroController::add_macro_items_to_menu (lay::MacroCollection &collection, int
m_macro_actions.push_back (a); m_macro_actions.push_back (a);
mp_mw->addAction (a.qaction ()); mp_mw->addAction (a.qaction ());
MacroSignalAdaptor *adaptor = new MacroSignalAdaptor (a.qaction (), c->second); lym::MacroSignalAdaptor *adaptor = new lym::MacroSignalAdaptor (a.qaction (), c->second);
QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ())); QObject::connect (a.qaction (), SIGNAL (triggered ()), adaptor, SLOT (run ()));
} }
@ -649,7 +650,7 @@ MacroController::do_update_menu_with_macros ()
int n = 1; int n = 1;
std::set<std::string> groups; std::set<std::string> groups;
add_macro_items_to_menu (m_temp_macros, n, groups, tech, 0); add_macro_items_to_menu (m_temp_macros, n, groups, tech, 0);
add_macro_items_to_menu (lay::MacroCollection::root (), n, groups, tech, &new_key_bindings); add_macro_items_to_menu (lym::MacroCollection::root (), n, groups, tech, &new_key_bindings);
// update the key bindings if required // update the key bindings if required
std::sort (new_key_bindings.begin (), new_key_bindings.end ()); std::sort (new_key_bindings.begin (), new_key_bindings.end ());
@ -665,9 +666,9 @@ MacroController::file_watcher_triggered ()
} }
static void static void
add_collections_to_file_watcher (const lay::MacroCollection &collection, tl::FileSystemWatcher *watcher) add_collections_to_file_watcher (const lym::MacroCollection &collection, tl::FileSystemWatcher *watcher)
{ {
for (lay::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) {
if (! c->second->path ().empty () && c->second->path ()[0] != ':') { if (! c->second->path ().empty () && c->second->path ()[0] != ':') {
watcher->add_file (c->second->path ()); watcher->add_file (c->second->path ());
add_collections_to_file_watcher (*c->second, watcher); add_collections_to_file_watcher (*c->second, watcher);
@ -680,7 +681,7 @@ MacroController::sync_file_watcher ()
{ {
m_file_watcher->clear (); m_file_watcher->clear ();
m_file_watcher->enable (false); m_file_watcher->enable (false);
add_collections_to_file_watcher (lay::MacroCollection::root (), m_file_watcher); add_collections_to_file_watcher (lym::MacroCollection::root (), m_file_watcher);
m_file_watcher->enable (true); m_file_watcher->enable (true);
} }
@ -688,7 +689,7 @@ void
MacroController::sync_files () MacroController::sync_files ()
{ {
tl::log << tl::to_string (tr ("Detected file system change in macro folders - updating")); tl::log << tl::to_string (tr ("Detected file system change in macro folders - updating"));
lay::MacroCollection::root ().reload (); lym::MacroCollection::root ().reload ();
} }
MacroController * MacroController *

View File

@ -26,7 +26,7 @@
#include "layCommon.h" #include "layCommon.h"
#include "layPlugin.h" #include "layPlugin.h"
#include "layMacro.h" #include "lymMacro.h"
#include "tlObject.h" #include "tlObject.h"
#include "tlDeferredExecution.h" #include "tlDeferredExecution.h"
#include "tlFileSystemWatcher.h" #include "tlFileSystemWatcher.h"
@ -142,7 +142,7 @@ public:
* menu building. Hence they are stored temporarily. * menu building. Hence they are stored temporarily.
* The MainWindow object will become owner of the macro object. * The MainWindow object will become owner of the macro object.
*/ */
void add_temp_macro (lay::Macro *m); void add_temp_macro (lym::Macro *m);
/** /**
* @brief Obtain the list of macro categories * @brief Obtain the list of macro categories
@ -180,7 +180,7 @@ private:
*/ */
struct ExternalPathDescriptor struct ExternalPathDescriptor
{ {
ExternalPathDescriptor (const std::string &_path, const std::string &_description, const std::string &_cat, lay::MacroCollection::FolderType _type, bool _readonly) ExternalPathDescriptor (const std::string &_path, const std::string &_description, const std::string &_cat, lym::MacroCollection::FolderType _type, bool _readonly)
: path (_path), description (_description), cat (_cat), type (_type), readonly (_readonly) : path (_path), description (_description), cat (_cat), type (_type), readonly (_readonly)
{ {
// .. nothing yet .. // .. nothing yet ..
@ -189,7 +189,7 @@ private:
std::string path; std::string path;
std::string description; std::string description;
std::string cat; std::string cat;
lay::MacroCollection::FolderType type; lym::MacroCollection::FolderType type;
bool readonly; bool readonly;
}; };
@ -214,8 +214,8 @@ private:
lay::MainWindow *mp_mw; lay::MainWindow *mp_mw;
bool m_no_implicit_macros; bool m_no_implicit_macros;
std::vector<lay::Action> m_macro_actions; std::vector<lay::Action> m_macro_actions;
std::map<QAction *, lay::Macro *> m_action_to_macro; std::map<QAction *, lym::Macro *> m_action_to_macro;
lay::MacroCollection m_temp_macros; lym::MacroCollection m_temp_macros;
std::vector< std::pair<std::string, std::string> > m_macro_categories; std::vector< std::pair<std::string, std::string> > m_macro_categories;
std::vector<InternalPathDescriptor> m_internal_paths; std::vector<InternalPathDescriptor> m_internal_paths;
std::vector<ExternalPathDescriptor> m_external_paths; std::vector<ExternalPathDescriptor> m_external_paths;
@ -227,7 +227,7 @@ private:
tl::DeferredMethod<MacroController> dm_sync_files; tl::DeferredMethod<MacroController> dm_sync_files;
void sync_implicit_macros (bool ask_before_autorun); void sync_implicit_macros (bool ask_before_autorun);
void add_macro_items_to_menu (lay::MacroCollection &collection, int &n, std::set<std::string> &groups, const lay::Technology *tech, std::vector<std::pair<std::string, std::string> > *key_bindings); void add_macro_items_to_menu (lym::MacroCollection &collection, int &n, std::set<std::string> &groups, const lay::Technology *tech, std::vector<std::pair<std::string, std::string> > *key_bindings);
void do_update_menu_with_macros (); void do_update_menu_with_macros ();
void do_sync_with_external_sources (); void do_sync_with_external_sources ();
void sync_file_watcher (); void sync_file_watcher ();

View File

@ -27,7 +27,6 @@
#include "layMacroEditorDialog.h" #include "layMacroEditorDialog.h"
#include "layMacroEditorSetupDialog.h" #include "layMacroEditorSetupDialog.h"
#include "layMacroPropertiesDialog.h" #include "layMacroPropertiesDialog.h"
#include "layMacroInterpreter.h"
#include "layFileDialog.h" #include "layFileDialog.h"
#include "layMainWindow.h" #include "layMainWindow.h"
#include "layHelpDialog.h" #include "layHelpDialog.h"
@ -39,6 +38,7 @@
#include "layConfig.h" #include "layConfig.h"
#include "layWidgets.h" #include "layWidgets.h"
#include "layProgress.h" #include "layProgress.h"
#include "lymMacroInterpreter.h"
#include "tlString.h" #include "tlString.h"
#include "tlClassRegistry.h" #include "tlClassRegistry.h"
#include "tlExceptions.h" #include "tlExceptions.h"
@ -85,7 +85,7 @@ class MacroTemplateSelectionDialog
: public QDialog, private Ui::MacroTemplateSelectionDialog : public QDialog, private Ui::MacroTemplateSelectionDialog
{ {
public: public:
MacroTemplateSelectionDialog (QWidget *parent, const std::vector<lay::Macro *> &templates, const std::string &cat) MacroTemplateSelectionDialog (QWidget *parent, const std::vector<lym::Macro *> &templates, const std::string &cat)
: QDialog (parent) : QDialog (parent)
{ {
setupUi (this); setupUi (this);
@ -101,7 +101,7 @@ public:
// Build a tree from the templates. Groups are formed by prepending a group title in the description // Build a tree from the templates. Groups are formed by prepending a group title in the description
// separated from the actual description by ";;" // separated from the actual description by ";;"
int index = 0; int index = 0;
for (std::vector<lay::Macro *>::const_iterator t = templates.begin (); t != templates.end (); ++t, ++index) { for (std::vector<lym::Macro *>::const_iterator t = templates.begin (); t != templates.end (); ++t, ++index) {
const std::string &c = (*t)->category (); const std::string &c = (*t)->category ();
@ -225,7 +225,7 @@ public:
static lay::MacroEditorDialog *s_macro_editor_instance = 0; static lay::MacroEditorDialog *s_macro_editor_instance = 0;
MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection *root) MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lym::MacroCollection *root)
: QDialog (0 /*show as individual top widget*/, Qt::Window), : QDialog (0 /*show as individual top widget*/, Qt::Window),
mp_root (root), mp_root (root),
m_first_show (true), m_in_processing (false), m_debugging_on (true), m_first_show (true), m_in_processing (false), m_debugging_on (true),
@ -262,10 +262,10 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
Ui::MacroEditorDialog::setupUi (this); Ui::MacroEditorDialog::setupUi (this);
connect (mp_root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed (Macro *))); connect (mp_root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed (lym::Macro *)));
connect (mp_root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *))); connect (mp_root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (mp_root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *))); connect (mp_root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (mp_root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed (MacroCollection *))); connect (mp_root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed (lym::MacroCollection *)));
m_categories = lay::MacroController::instance ()->macro_categories (); m_categories = lay::MacroController::instance ()->macro_categories ();
@ -313,11 +313,11 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
macro_tree->setItemDelegate (new EditRoleDelegate (macro_tree)); macro_tree->setItemDelegate (new EditRoleDelegate (macro_tree));
connect (macro_tree, SIGNAL (macro_double_clicked (lay::Macro *)), this, SLOT (item_double_clicked (lay::Macro *))); connect (macro_tree, SIGNAL (macro_double_clicked (lym::Macro *)), this, SLOT (item_double_clicked (lym::Macro *)));
connect (macro_tree, SIGNAL (move_macro (lay::Macro *, lay::MacroCollection *)), this, SLOT (move_macro (lay::Macro *, lay::MacroCollection *))); connect (macro_tree, SIGNAL (move_macro (lym::Macro *, lym::MacroCollection *)), this, SLOT (move_macro (lym::Macro *, lym::MacroCollection *)));
connect (macro_tree, SIGNAL (move_folder (lay::MacroCollection *, lay::MacroCollection *)), this, SLOT (move_folder (lay::MacroCollection *, lay::MacroCollection *))); connect (macro_tree, SIGNAL (move_folder (lym::MacroCollection *, lym::MacroCollection *)), this, SLOT (move_folder (lym::MacroCollection *, lym::MacroCollection *)));
connect (macro_tree, SIGNAL (folder_renamed (lay::MacroCollection *)), this, SLOT (folder_renamed (lay::MacroCollection *))); connect (macro_tree, SIGNAL (folder_renamed (lym::MacroCollection *)), this, SLOT (folder_renamed (lym::MacroCollection *)));
connect (macro_tree, SIGNAL (macro_renamed (lay::Macro *)), this, SLOT (macro_renamed (lay::Macro *))); connect (macro_tree, SIGNAL (macro_renamed (lym::Macro *)), this, SLOT (macro_renamed (lym::Macro *)));
} }
@ -492,7 +492,7 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
data = QByteArray ((const char *)res.data (), (int)res.size ()); data = QByteArray ((const char *)res.data (), (int)res.size ());
} }
Macro *m = new Macro (); lym::Macro *m = new lym::Macro ();
try { try {
m->rename (tl::to_string (QFileInfo (QUrl (tl::to_qstring (url)).path ()).baseName ())); m->rename (tl::to_string (QFileInfo (QUrl (tl::to_qstring (url)).path ()).baseName ()));
@ -538,7 +538,7 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
filters << QString::fromUtf8 ("*.py"); filters << QString::fromUtf8 ("*.py");
// add the suffixes in the DSL interpreter declarations // add the suffixes in the DSL interpreter declarations
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (! cls->suffix ().empty ()) { if (! cls->suffix ().empty ()) {
filters << tl::to_qstring ("*." + cls->suffix ()); filters << tl::to_qstring ("*." + cls->suffix ());
} }
@ -547,7 +547,7 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
QStringList files = dir.entryList (filters, QDir::Files); QStringList files = dir.entryList (filters, QDir::Files);
for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) {
Macro *m = new Macro (); lym::Macro *m = new lym::Macro ();
try { try {
m->rename (tl::to_string (QFileInfo (*f).baseName ())); m->rename (tl::to_string (QFileInfo (*f).baseName ()));
@ -567,11 +567,11 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
} }
// finally fetch the templates of the DSL interpreters // finally fetch the templates of the DSL interpreters
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
size_t n = m_macro_templates.size (); size_t n = m_macro_templates.size ();
cls->get_templates (m_macro_templates); cls->get_templates (m_macro_templates);
if (tl::verbosity () >= 20) { if (tl::verbosity () >= 20) {
for (std::vector<lay::Macro *>::const_iterator t = m_macro_templates.begin () + n; t != m_macro_templates.end (); ++t) { for (std::vector<lym::Macro *>::const_iterator t = m_macro_templates.begin () + n; t != m_macro_templates.end (); ++t) {
tl::info << "Using DSL macro template for " << (*t)->dsl_interpreter () << " with name " << (*t)->name (); tl::info << "Using DSL macro template for " << (*t)->dsl_interpreter () << " with name " << (*t)->name ();
} }
} }
@ -606,7 +606,7 @@ MacroEditorDialog::~MacroEditorDialog ()
s_macro_editor_instance = 0; s_macro_editor_instance = 0;
} }
for (std::vector<lay::Macro *>::iterator t = m_macro_templates.begin (); t != m_macro_templates.end (); ++t) { for (std::vector<lym::Macro *>::iterator t = m_macro_templates.begin (); t != m_macro_templates.end (); ++t) {
delete *t; delete *t;
} }
m_macro_templates.clear (); m_macro_templates.clear ();
@ -658,11 +658,11 @@ BEGIN_PROTECTED
} }
lay::MacroEditorTree *ct = current_macro_tree (); lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection (); lym::MacroCollection *collection = ct->current_macro_collection ();
// Select the first writeable collection if none is selected // Select the first writeable collection if none is selected
if (! collection || collection->is_readonly ()) { if (! collection || collection->is_readonly ()) {
for (lay::MacroCollection::const_child_iterator c = mp_root->begin_children (); c != mp_root->end_children (); ++c) { for (lym::MacroCollection::const_child_iterator c = mp_root->begin_children (); c != mp_root->end_children (); ++c) {
if (c->second->category () == ct->category () && ! c->second->is_readonly ()) { if (c->second->category () == ct->category () && ! c->second->is_readonly ()) {
ct->set_current (c->second); ct->set_current (c->second);
collection = c->second; collection = c->second;
@ -672,7 +672,7 @@ BEGIN_PROTECTED
} }
if (collection && (force_add || (collection->begin () == collection->end () && collection->begin_children () == collection->end_children ()))) { if (collection && (force_add || (collection->begin () == collection->end () && collection->begin_children () == collection->end_children ()))) {
lay::Macro *m = new_macro (); lym::Macro *m = new_macro ();
if (force_add && m) { if (force_add && m) {
set_run_macro (m); set_run_macro (m);
} }
@ -696,7 +696,7 @@ BEGIN_PROTECTED
select_category (cat); select_category (cat);
} }
lay::Macro *m = new_macro (); lym::Macro *m = new_macro ();
if (force_add && m) { if (force_add && m) {
set_run_macro (m); set_run_macro (m);
} }
@ -820,7 +820,7 @@ MacroEditorDialog::showEvent (QShowEvent *)
std::string am; std::string am;
MainWindow::instance ()->config_get (cfg_macro_editor_active_macro, am); MainWindow::instance ()->config_get (cfg_macro_editor_active_macro, am);
if (! am.empty ()) { if (! am.empty ()) {
lay::Macro *macro = mp_root->find_macro (am); lym::Macro *macro = mp_root->find_macro (am);
if (macro) { if (macro) {
set_run_macro (macro); set_run_macro (macro);
} }
@ -835,7 +835,7 @@ MacroEditorDialog::showEvent (QShowEvent *)
editor_for_file (cm); editor_for_file (cm);
} }
for (std::map <Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) {
page->second->set_debugging_on (m_debugging_on); page->second->set_debugging_on (m_debugging_on);
} }
@ -945,7 +945,7 @@ MacroEditorDialog::set_debugging_on (bool on)
m_debugging_on = on; m_debugging_on = on;
for (std::map <Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) {
page->second->set_debugging_on (m_debugging_on); page->second->set_debugging_on (m_debugging_on);
} }
@ -976,14 +976,14 @@ MacroEditorDialog::process_events (QEventLoop::ProcessEventsFlags flags)
} }
static bool static bool
any_modified(MacroCollection *parent) any_modified(lym::MacroCollection *parent)
{ {
for (MacroCollection::child_iterator c = parent->begin_children (); c != parent->end_children (); ++c) { for (lym::MacroCollection::child_iterator c = parent->begin_children (); c != parent->end_children (); ++c) {
if (any_modified (c->second)) { if (any_modified (c->second)) {
return true; return true;
} }
} }
for (MacroCollection::iterator c = parent->begin (); c != parent->end (); ++c) { for (lym::MacroCollection::iterator c = parent->begin (); c != parent->end (); ++c) {
if (c->second->is_modified ()) { if (c->second->is_modified ()) {
return true; return true;
} }
@ -1529,7 +1529,7 @@ MacroEditorDialog::update_console_text ()
void void
MacroEditorDialog::commit () MacroEditorDialog::commit ()
{ {
for (std::map <Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator page = m_tab_widgets.begin (); page != m_tab_widgets.end (); ++page) {
if (page->second->is_modified ()) { if (page->second->is_modified ()) {
page->second->commit (); page->second->commit ();
} }
@ -1537,20 +1537,20 @@ MacroEditorDialog::commit ()
} }
void void
MacroEditorDialog::macro_collection_deleted (lay::MacroCollection *collection) MacroEditorDialog::macro_collection_deleted (lym::MacroCollection *collection)
{ {
// close the tab pages related to the collection we want to delete // close the tab pages related to the collection we want to delete
std::set <lay::Macro *> used_macros; std::set <lym::Macro *> used_macros;
std::set <lay::MacroCollection *> used_collections; std::set <lym::MacroCollection *> used_collections;
collection->collect_used_nodes (used_macros, used_collections); collection->collect_used_nodes (used_macros, used_collections);
for (std::set <lay::Macro *>::iterator mc = used_macros.begin (); mc != used_macros.end (); ++mc) { for (std::set <lym::Macro *>::iterator mc = used_macros.begin (); mc != used_macros.end (); ++mc) {
if (mp_run_macro == *mc) { if (mp_run_macro == *mc) {
mp_run_macro = 0; mp_run_macro = 0;
} }
std::map <Macro *, MacroEditorPage *>::iterator p = m_tab_widgets.find (*mc); std::map <lym::Macro *, MacroEditorPage *>::iterator p = m_tab_widgets.find (*mc);
if (p != m_tab_widgets.end ()) { if (p != m_tab_widgets.end ()) {
// disable the macro on the page - we'll ask for updates when the file // disable the macro on the page - we'll ask for updates when the file
// watcher becomes active. So long, the macro is "zombie". // watcher becomes active. So long, the macro is "zombie".
@ -1565,13 +1565,13 @@ MacroEditorDialog::macro_collection_deleted (lay::MacroCollection *collection)
} }
void void
MacroEditorDialog::macro_deleted (lay::Macro *macro) MacroEditorDialog::macro_deleted (lym::Macro *macro)
{ {
if (mp_run_macro == macro) { if (mp_run_macro == macro) {
mp_run_macro = 0; mp_run_macro = 0;
} }
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro);
if (page != m_tab_widgets.end ()) { if (page != m_tab_widgets.end ()) {
// disable the macro on the page - we'll ask for updates when the file // disable the macro on the page - we'll ask for updates when the file
// watcher becomes active. So long, the macro is "zombie". // watcher becomes active. So long, the macro is "zombie".
@ -1584,15 +1584,15 @@ MacroEditorDialog::macro_deleted (lay::Macro *macro)
} }
void void
MacroEditorDialog::macro_collection_changed (lay::MacroCollection * /*collection*/) MacroEditorDialog::macro_collection_changed (lym::MacroCollection * /*collection*/)
{ {
refresh_file_watcher (); refresh_file_watcher ();
} }
void void
MacroEditorDialog::macro_changed (lay::Macro *macro) MacroEditorDialog::macro_changed (lym::Macro *macro)
{ {
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro);
if (page != m_tab_widgets.end ()) { if (page != m_tab_widgets.end ()) {
int index = tabWidget->indexOf (page->second); int index = tabWidget->indexOf (page->second);
QString tt = tl::to_qstring (macro->summary ()); QString tt = tl::to_qstring (macro->summary ());
@ -1629,12 +1629,12 @@ MacroEditorDialog::current_tab_changed (int index)
do_update_ui_to_run_mode (); do_update_ui_to_run_mode ();
} }
lay::Macro *MacroEditorDialog::create_macro_here (const char *prefix) lym::Macro *MacroEditorDialog::create_macro_here (const char *prefix)
{ {
lay::MacroEditorTree *mt = current_macro_tree (); lay::MacroEditorTree *mt = current_macro_tree ();
MacroCollection *collection = mt->current_macro_collection (); lym::MacroCollection *collection = mt->current_macro_collection ();
if (! collection) { if (! collection) {
Macro *m = mt->current_macro (); lym::Macro *m = mt->current_macro ();
if (m) { if (m) {
collection = m->parent (); collection = m->parent ();
} }
@ -1648,19 +1648,19 @@ lay::Macro *MacroEditorDialog::create_macro_here (const char *prefix)
} }
void void
MacroEditorDialog::macro_renamed (lay::Macro * /*macro*/) MacroEditorDialog::macro_renamed (lym::Macro * /*macro*/)
{ {
refresh_file_watcher (); refresh_file_watcher ();
} }
void void
MacroEditorDialog::folder_renamed (lay::MacroCollection * /*mc*/) MacroEditorDialog::folder_renamed (lym::MacroCollection * /*mc*/)
{ {
refresh_file_watcher (); refresh_file_watcher ();
} }
void void
MacroEditorDialog::move_macro (lay::Macro *source, lay::MacroCollection *target) MacroEditorDialog::move_macro (lym::Macro *source, lym::MacroCollection *target)
{ {
if (m_in_exec) { if (m_in_exec) {
return; return;
@ -1670,12 +1670,12 @@ BEGIN_PROTECTED
if (source->parent () != target) { if (source->parent () != target) {
lay::Macro *m = target->create (source->name ().c_str (), source->format ()); lym::Macro *m = target->create (source->name ().c_str (), source->format ());
m->assign (*source); m->assign (*source);
m->set_readonly (false); m->set_readonly (false);
m->save (); m->save ();
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (source); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (source);
if (page != m_tab_widgets.end ()) { if (page != m_tab_widgets.end ()) {
MacroEditorPage *w = page->second; MacroEditorPage *w = page->second;
w->connect_macro (m); w->connect_macro (m);
@ -1686,7 +1686,7 @@ BEGIN_PROTECTED
} }
if (! source->is_readonly ()) { if (! source->is_readonly ()) {
MacroCollection *collection = source->parent (); lym::MacroCollection *collection = source->parent ();
if (collection && ! collection->is_readonly ()) { if (collection && ! collection->is_readonly ()) {
if (source->del ()) { if (source->del ()) {
collection->erase (source); collection->erase (source);
@ -1706,18 +1706,18 @@ END_PROTECTED
} }
void void
MacroEditorDialog::move_subfolder (lay::MacroCollection *source, lay::MacroCollection *target) MacroEditorDialog::move_subfolder (lym::MacroCollection *source, lym::MacroCollection *target)
{ {
lay::MacroCollection *mt = target->create_folder (source->name ().c_str ()); lym::MacroCollection *mt = target->create_folder (source->name ().c_str ());
if (! mt) { if (! mt) {
return; return;
} }
std::vector <MacroCollection::iterator> m_del; std::vector <lym::MacroCollection::iterator> m_del;
for (MacroCollection::iterator mm = source->begin (); mm != source->end (); ++mm) { for (lym::MacroCollection::iterator mm = source->begin (); mm != source->end (); ++mm) {
lay::Macro *m = mt->create (mm->second->name ().c_str ()); lym::Macro *m = mt->create (mm->second->name ().c_str ());
if (!m) { if (!m) {
continue; continue;
} }
@ -1726,7 +1726,7 @@ MacroEditorDialog::move_subfolder (lay::MacroCollection *source, lay::MacroColle
m->set_readonly (false); m->set_readonly (false);
m->save (); m->save ();
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (mm->second); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (mm->second);
if (page != m_tab_widgets.end ()) { if (page != m_tab_widgets.end ()) {
MacroEditorPage *w = page->second; MacroEditorPage *w = page->second;
w->connect_macro (m); w->connect_macro (m);
@ -1743,13 +1743,13 @@ MacroEditorDialog::move_subfolder (lay::MacroCollection *source, lay::MacroColle
} }
} }
for (std::vector <MacroCollection::iterator>::const_iterator d = m_del.begin (); d != m_del.end (); ++d) { for (std::vector <lym::MacroCollection::iterator>::const_iterator d = m_del.begin (); d != m_del.end (); ++d) {
source->erase (*d); source->erase (*d);
} }
std::vector <MacroCollection::child_iterator> mc_del; std::vector <lym::MacroCollection::child_iterator> mc_del;
for (MacroCollection::child_iterator m = source->begin_children (); m != source->end_children (); ++m) { for (lym::MacroCollection::child_iterator m = source->begin_children (); m != source->end_children (); ++m) {
move_subfolder (m->second, mt); move_subfolder (m->second, mt);
if (! m->second->is_readonly ()) { if (! m->second->is_readonly ()) {
if (m->second->del ()) { if (m->second->del ()) {
@ -1758,13 +1758,13 @@ MacroEditorDialog::move_subfolder (lay::MacroCollection *source, lay::MacroColle
} }
} }
for (std::vector <MacroCollection::child_iterator>::const_iterator d = mc_del.begin (); d != mc_del.end (); ++d) { for (std::vector <lym::MacroCollection::child_iterator>::const_iterator d = mc_del.begin (); d != mc_del.end (); ++d) {
source->erase (*d); source->erase (*d);
} }
} }
void void
MacroEditorDialog::move_folder (lay::MacroCollection *source, lay::MacroCollection *target) MacroEditorDialog::move_folder (lym::MacroCollection *source, lym::MacroCollection *target)
{ {
if (m_in_exec) { if (m_in_exec) {
return; return;
@ -1893,7 +1893,7 @@ MacroEditorDialog::save_button_clicked ()
BEGIN_PROTECTED BEGIN_PROTECTED
Macro *m = current_macro_tree ()->current_macro (); lym::Macro *m = current_macro_tree ()->current_macro ();
if (m) { if (m) {
m->save (); m->save ();
} else if (tabWidget->currentWidget ()) { } else if (tabWidget->currentWidget ()) {
@ -2003,8 +2003,8 @@ BEGIN_PROTECTED
return; return;
} }
Macro *macro = page->macro (); lym::Macro *macro = page->macro ();
if (macro->format () == lay::Macro::PlainTextWithHashAnnotationsFormat) { if (macro->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
page->commit (); page->commit ();
} }
@ -2037,7 +2037,7 @@ BEGIN_PROTECTED
END_PROTECTED END_PROTECTED
} }
lay::Macro * lym::Macro *
MacroEditorDialog::new_macro() MacroEditorDialog::new_macro()
{ {
ensure_writeable_collection_selected (); ensure_writeable_collection_selected ();
@ -2059,7 +2059,7 @@ MacroEditorDialog::new_macro()
return 0; return 0;
} }
Macro *m = create_macro_here (m_macro_templates [template_index]->name ().c_str ()); lym::Macro *m = create_macro_here (m_macro_templates [template_index]->name ().c_str ());
m->assign (*m_macro_templates [template_index]); m->assign (*m_macro_templates [template_index]);
m->set_readonly (false); m->set_readonly (false);
// we don't want to keep the template's description // we don't want to keep the template's description
@ -2103,7 +2103,7 @@ BEGIN_PROTECTED
return; return;
} }
for (std::map <Macro *, MacroEditorPage *>::iterator p = m_tab_widgets.begin (); p != m_tab_widgets.end (); ++p) { for (std::map <lym::Macro *, MacroEditorPage *>::iterator p = m_tab_widgets.begin (); p != m_tab_widgets.end (); ++p) {
if (p->second == page) { if (p->second == page) {
m_tab_widgets.erase (p); m_tab_widgets.erase (p);
break; break;
@ -2135,8 +2135,8 @@ BEGIN_PROTECTED
lay::MacroEditorTree *ct = current_macro_tree (); lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection (); lym::MacroCollection *collection = ct->current_macro_collection ();
Macro *m = ct->current_macro (); lym::Macro *m = ct->current_macro ();
if (collection) { if (collection) {
@ -2150,7 +2150,7 @@ BEGIN_PROTECTED
throw tl::Exception ("Can't delete this folder - it is not empty"); throw tl::Exception ("Can't delete this folder - it is not empty");
} }
MacroCollection *p = collection->parent (); lym::MacroCollection *p = collection->parent ();
if (p) { if (p) {
@ -2171,7 +2171,7 @@ BEGIN_PROTECTED
} else if (m) { } else if (m) {
MacroCollection *collection = m->parent (); lym::MacroCollection *collection = m->parent ();
if (m->is_readonly ()) { if (m->is_readonly ()) {
throw tl::Exception ("Can't delete this macro - it is readonly"); throw tl::Exception ("Can't delete this macro - it is readonly");
} }
@ -2226,9 +2226,9 @@ void
MacroEditorDialog::ensure_writeable_collection_selected () MacroEditorDialog::ensure_writeable_collection_selected ()
{ {
lay::MacroEditorTree *ct = current_macro_tree (); lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection (); lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) { if (! collection) {
Macro *macro = ct->current_macro (); lym::Macro *macro = ct->current_macro ();
if (macro) { if (macro) {
collection = macro->parent (); collection = macro->parent ();
} }
@ -2236,7 +2236,7 @@ MacroEditorDialog::ensure_writeable_collection_selected ()
// Select the first writeable collection if none is selected // Select the first writeable collection if none is selected
if (! collection || collection->is_readonly ()) { if (! collection || collection->is_readonly ()) {
for (lay::MacroCollection::const_child_iterator c = mp_root->begin_children (); c != mp_root->end_children (); ++c) { for (lym::MacroCollection::const_child_iterator c = mp_root->begin_children (); c != mp_root->end_children (); ++c) {
if (c->second->category () == ct->category () && ! c->second->is_readonly ()) { if (c->second->category () == ct->category () && ! c->second->is_readonly ()) {
ct->set_current (c->second); ct->set_current (c->second);
collection = c->second; collection = c->second;
@ -2317,7 +2317,7 @@ BEGIN_PROTECTED
} }
std::set<std::string> modified_files; std::set<std::string> modified_files;
for (std::map <Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) {
if (m->first->is_modified ()) { if (m->first->is_modified ()) {
modified_files.insert (m->first->path ()); modified_files.insert (m->first->path ());
} }
@ -2400,7 +2400,7 @@ MacroEditorDialog::file_removed (const QString &path)
} }
void void
MacroEditorDialog::sync_file_watcher (lay::MacroCollection * /*collection*/) MacroEditorDialog::sync_file_watcher (lym::MacroCollection * /*collection*/)
{ {
#if 0 #if 0
// this would monitor the whole tree - but it's a little too deep. This // this would monitor the whole tree - but it's a little too deep. This
@ -2410,7 +2410,7 @@ MacroEditorDialog::sync_file_watcher (lay::MacroCollection * /*collection*/)
m_file_watcher->add_file (collection->path ()); m_file_watcher->add_file (collection->path ());
for (lay::MacroCollection::iterator m = collection->begin (); m != collection->end (); ++m) { for (lym::MacroCollection::iterator m = collection->begin (); m != collection->end (); ++m) {
if (m->second->is_file ()) { if (m->second->is_file ()) {
m_file_watcher->add_file (m->second->path()); m_file_watcher->add_file (m->second->path());
} }
@ -2418,12 +2418,12 @@ MacroEditorDialog::sync_file_watcher (lay::MacroCollection * /*collection*/)
} }
for (lay::MacroCollection::child_iterator m = collection->begin_children (); m != collection->end_children (); ++m) { for (lym::MacroCollection::child_iterator m = collection->begin_children (); m != collection->end_children (); ++m) {
sync_file_watcher (m->second); sync_file_watcher (m->second);
} }
#else #else
// This solution monitors the open files only // This solution monitors the open files only
for (std::map <Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) {
m_file_watcher->add_file (m->first->path ()); m_file_watcher->add_file (m->first->path ());
} }
#endif #endif
@ -2499,7 +2499,7 @@ BEGIN_PROTECTED
std::string new_path = tl::to_string (QFileInfo (new_dir).absoluteFilePath ()); std::string new_path = tl::to_string (QFileInfo (new_dir).absoluteFilePath ());
paths.push_back (std::make_pair (new_path, cat)); paths.push_back (std::make_pair (new_path, cat));
lay::MacroCollection *c = mp_root->add_folder (tl::to_string (QObject::tr ("Project")) + " - " + new_path, new_path, cat, false); lym::MacroCollection *c = mp_root->add_folder (tl::to_string (QObject::tr ("Project")) + " - " + new_path, new_path, cat, false);
if (!c) { if (!c) {
throw tl::Exception (tl::to_string (QObject::tr ("The selected directory is already installed as custom location"))); throw tl::Exception (tl::to_string (QObject::tr ("The selected directory is already installed as custom location")));
} }
@ -2527,9 +2527,9 @@ MacroEditorDialog::remove_location ()
BEGIN_PROTECTED BEGIN_PROTECTED
lay::MacroEditorTree *ct = current_macro_tree (); lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection (); lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) { if (! collection) {
Macro *m = ct->current_macro (); lym::Macro *m = ct->current_macro ();
if (m) { if (m) {
collection = m->parent (); collection = m->parent ();
} }
@ -2589,7 +2589,7 @@ BEGIN_PROTECTED
std::string filters = tl::to_string (QObject::tr ("All files (*);;KLayout macro files (*.lym);;Ruby files (*.rb);;Python files (*.py)")); std::string filters = tl::to_string (QObject::tr ("All files (*);;KLayout macro files (*.lym);;Ruby files (*.rb);;Python files (*.py)"));
// add the suffixes in the DSL interpreter declarations // add the suffixes in the DSL interpreter declarations
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (! cls->suffix ().empty ()) { if (! cls->suffix ().empty ()) {
filters += ";;"; filters += ";;";
if (! cls->description ().empty ()) { if (! cls->description ().empty ()) {
@ -2609,7 +2609,7 @@ BEGIN_PROTECTED
if (file_dialog->get_open (fn)) { if (file_dialog->get_open (fn)) {
// create a new macro and use the new name as the base name // create a new macro and use the new name as the base name
Macro *m = create_macro_here (tl::to_string (QFileInfo (tl::to_qstring (fn)).baseName ()).c_str ()); lym::Macro *m = create_macro_here (tl::to_string (QFileInfo (tl::to_qstring (fn)).baseName ()).c_str ());
try { try {
m->load_from (fn); m->load_from (fn);
@ -2642,9 +2642,9 @@ BEGIN_PROTECTED
ensure_writeable_collection_selected (); ensure_writeable_collection_selected ();
lay::MacroEditorTree *ct = current_macro_tree (); lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection (); lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) { if (! collection) {
Macro *m = ct->current_macro (); lym::Macro *m = ct->current_macro ();
if (m) { if (m) {
collection = m->parent (); collection = m->parent ();
} }
@ -2654,7 +2654,7 @@ BEGIN_PROTECTED
throw tl::Exception (tl::to_string (QObject::tr ("Cannot create a folder here"))); throw tl::Exception (tl::to_string (QObject::tr ("Cannot create a folder here")));
} }
MacroCollection *mm = collection->create_folder (); lym::MacroCollection *mm = collection->create_folder ();
if (! mm) { if (! mm) {
throw tl::Exception (tl::to_string (QObject::tr ("Failed to create the folder here"))); throw tl::Exception (tl::to_string (QObject::tr ("Failed to create the folder here")));
} }
@ -2687,11 +2687,11 @@ END_PROTECTED
} }
void void
MacroEditorDialog::item_double_clicked(lay::Macro *m) MacroEditorDialog::item_double_clicked(lym::Macro *m)
{ {
BEGIN_PROTECTED BEGIN_PROTECTED
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (m); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (m);
if (page == m_tab_widgets.end ()) { if (page == m_tab_widgets.end ()) {
MacroEditorPage *page = create_page (m); MacroEditorPage *page = create_page (m);
@ -2730,7 +2730,7 @@ MacroEditorDialog::start_exec (gsi::Interpreter *ec)
m_current_stack_depth = -1; m_current_stack_depth = -1;
m_process_events_interval = 0.05; m_process_events_interval = 0.05;
for (std::map<Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) { for (std::map<lym::Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) {
f->second->exec_model ()->set_current_line (-1); f->second->exec_model ()->set_current_line (-1);
f->second->exec_model ()->set_run_mode (true); f->second->exec_model ()->set_run_mode (true);
} }
@ -2756,7 +2756,7 @@ MacroEditorDialog::end_exec (gsi::Interpreter *ec)
m_continue = false; m_continue = false;
m_current_stack_depth = -1; m_current_stack_depth = -1;
for (std::map<Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) { for (std::map<lym::Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) {
f->second->exec_model ()->set_run_mode (false); f->second->exec_model ()->set_run_mode (false);
} }
@ -2767,14 +2767,14 @@ MacroEditorDialog::end_exec (gsi::Interpreter *ec)
size_t size_t
MacroEditorDialog::id_for_path (gsi::Interpreter *, const std::string &path) MacroEditorDialog::id_for_path (gsi::Interpreter *, const std::string &path)
{ {
for (std::map <Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) { for (std::map <lym::Macro *, MacroEditorPage *>::const_iterator m = m_tab_widgets.begin (); m != m_tab_widgets.end (); ++m) {
if (m->first->path () == path) { if (m->first->path () == path) {
m_file_to_widget.push_back (*m); m_file_to_widget.push_back (*m);
return m_file_to_widget.size (); return m_file_to_widget.size ();
} }
} }
lay::Macro *macro = mp_root->find_macro (path); lym::Macro *macro = mp_root->find_macro (path);
if (macro) { if (macro) {
m_file_to_widget.push_back (std::make_pair (macro, (MacroEditorPage *) 0)); m_file_to_widget.push_back (std::make_pair (macro, (MacroEditorPage *) 0));
return m_file_to_widget.size (); return m_file_to_widget.size ();
@ -3002,8 +3002,8 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
MacroEditorPage *page = dynamic_cast<MacroEditorPage *> (tabWidget->currentWidget ()); MacroEditorPage *page = dynamic_cast<MacroEditorPage *> (tabWidget->currentWidget ());
dbgOn->setEnabled (! m_in_exec); dbgOn->setEnabled (! m_in_exec);
runButton->setEnabled ((! m_in_exec && (mp_run_macro || (page && page->macro () && page->macro ()->interpreter () != lay::Macro::None))) || m_in_breakpoint); runButton->setEnabled ((! m_in_exec && (mp_run_macro || (page && page->macro () && page->macro ()->interpreter () != lym::Macro::None))) || m_in_breakpoint);
runThisButton->setEnabled ((! m_in_exec && page && page->macro () && page->macro ()->interpreter () != lay::Macro::None) || m_in_breakpoint); runThisButton->setEnabled ((! m_in_exec && page && page->macro () && page->macro ()->interpreter () != lym::Macro::None) || m_in_breakpoint);
singleStepButton->setEnabled (! m_in_exec || m_in_breakpoint); singleStepButton->setEnabled (! m_in_exec || m_in_breakpoint);
nextStepButton->setEnabled (! m_in_exec || m_in_breakpoint); nextStepButton->setEnabled (! m_in_exec || m_in_breakpoint);
stopButton->setEnabled (m_in_exec); stopButton->setEnabled (m_in_exec);
@ -3033,7 +3033,7 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
actionRefresh->setEnabled (! m_in_exec); actionRefresh->setEnabled (! m_in_exec);
actionAddLocation->setEnabled (! m_in_exec); actionAddLocation->setEnabled (! m_in_exec);
actionRemoveLocation->setEnabled (! m_in_exec); actionRemoveLocation->setEnabled (! m_in_exec);
propertiesButton->setEnabled (! m_in_exec && page && page->macro () && (page->macro ()->format () == Macro::MacroFormat || page->macro ()->format () == Macro::PlainTextWithHashAnnotationsFormat)); propertiesButton->setEnabled (! m_in_exec && page && page->macro () && (page->macro ()->format () == lym::Macro::MacroFormat || page->macro ()->format () == lym::Macro::PlainTextWithHashAnnotationsFormat));
setupButton->setEnabled (! m_in_exec); setupButton->setEnabled (! m_in_exec);
langSelFrame->setEnabled (! m_in_exec); langSelFrame->setEnabled (! m_in_exec);
@ -3085,7 +3085,7 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
variableList->setPalette (p); variableList->setPalette (p);
watchList->setPalette (p); watchList->setPalette (p);
std::map <Macro *, MacroEditorPage *>::const_iterator t = m_tab_widgets.find (mp_run_macro); std::map <lym::Macro *, MacroEditorPage *>::const_iterator t = m_tab_widgets.find (mp_run_macro);
if (t != m_tab_widgets.end ()) { if (t != m_tab_widgets.end ()) {
int index = tabWidget->indexOf (t->second); int index = tabWidget->indexOf (t->second);
if (index >= 0) { if (index >= 0) {
@ -3106,7 +3106,7 @@ MacroEditorDialog::stack_element_double_clicked (QListWidgetItem *item)
} }
MacroEditorPage * MacroEditorPage *
MacroEditorDialog::create_page (Macro *macro) MacroEditorDialog::create_page (lym::Macro *macro)
{ {
std::auto_ptr<MacroEditorPage> editor (new MacroEditorPage (this, &m_highlighters)); std::auto_ptr<MacroEditorPage> editor (new MacroEditorPage (this, &m_highlighters));
editor->set_ntab (m_ntab); editor->set_ntab (m_ntab);
@ -3120,7 +3120,7 @@ MacroEditorDialog::create_page (Macro *macro)
} }
MacroEditorPage * MacroEditorPage *
MacroEditorDialog::editor_for_macro (Macro *macro) MacroEditorDialog::editor_for_macro (lym::Macro *macro)
{ {
for (std::vector<lay::MacroEditorTree *>::const_iterator mt = m_macro_trees.begin (); mt != m_macro_trees.end (); ++mt) { for (std::vector<lay::MacroEditorTree *>::const_iterator mt = m_macro_trees.begin (); mt != m_macro_trees.end (); ++mt) {
(*mt)->set_current (macro); (*mt)->set_current (macro);
@ -3128,7 +3128,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
MacroEditorPage *editor = 0; MacroEditorPage *editor = 0;
std::map <Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro); std::map <lym::Macro *, MacroEditorPage *>::iterator page = m_tab_widgets.find (macro);
if (page == m_tab_widgets.end ()) { if (page == m_tab_widgets.end ()) {
editor = create_page (macro); editor = create_page (macro);
@ -3142,7 +3142,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
refresh_file_watcher (); refresh_file_watcher ();
for (std::vector <std::pair<Macro *, MacroEditorPage *> >::iterator f = m_file_to_widget.begin (); f != m_file_to_widget.end (); ++f) { for (std::vector <std::pair<lym::Macro *, MacroEditorPage *> >::iterator f = m_file_to_widget.begin (); f != m_file_to_widget.end (); ++f) {
if (f->first == macro) { if (f->first == macro) {
f->second = editor; f->second = editor;
break; break;
@ -3160,7 +3160,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
MacroEditorPage * MacroEditorPage *
MacroEditorDialog::editor_for_file (const std::string &path) MacroEditorDialog::editor_for_file (const std::string &path)
{ {
lay::Macro *macro = mp_root->find_macro (path); lym::Macro *macro = mp_root->find_macro (path);
if (macro) { if (macro) {
return editor_for_macro (macro); return editor_for_macro (macro);
} else { } else {
@ -3176,7 +3176,7 @@ MacroEditorDialog::set_exec_point (const std::string *file, int line, int eval_c
editor = editor_for_file (*file); editor = editor_for_file (*file);
} }
for (std::map<Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) { for (std::map<lym::Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) {
f->second->exec_model ()->set_current_line (f->second == editor ? line : -1, true); f->second->exec_model ()->set_current_line (f->second == editor ? line : -1, true);
} }
@ -3207,7 +3207,7 @@ MacroEditorDialog::breakpoint_button_clicked ()
void void
MacroEditorDialog::clear_breakpoints_button_clicked () MacroEditorDialog::clear_breakpoints_button_clicked ()
{ {
for (std::map<Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) { for (std::map<lym::Macro *, MacroEditorPage *>::const_iterator f = m_tab_widgets.begin (); f != m_tab_widgets.end (); ++f) {
f->second->exec_model ()->set_breakpoints (std::set <int> ()); f->second->exec_model ()->set_breakpoints (std::set <int> ());
} }
} }
@ -3262,14 +3262,14 @@ BEGIN_PROTECTED
END_PROTECTED END_PROTECTED
} }
lay::Macro * lym::Macro *
MacroEditorDialog::current_run_macro () MacroEditorDialog::current_run_macro ()
{ {
// validate the current run macro against the macros present in the collection and // validate the current run macro against the macros present in the collection and
// return 0 if invalid (that takes the current one) // return 0 if invalid (that takes the current one)
std::set<lay::Macro *> macros; std::set<lym::Macro *> macros;
std::set<lay::MacroCollection *> macro_collections; std::set<lym::MacroCollection *> macro_collections;
mp_root->collect_used_nodes (macros, macro_collections); mp_root->collect_used_nodes (macros, macro_collections);
if (macros.find (mp_run_macro) != macros.end ()) { if (macros.find (mp_run_macro) != macros.end ()) {
@ -3280,7 +3280,7 @@ MacroEditorDialog::current_run_macro ()
} }
void void
MacroEditorDialog::run (int stop_stack_depth, lay::Macro *macro) MacroEditorDialog::run (int stop_stack_depth, lym::Macro *macro)
{ {
m_stop_stack_depth = stop_stack_depth; m_stop_stack_depth = stop_stack_depth;
m_continue = true; m_continue = true;
@ -3364,11 +3364,11 @@ MacroEditorDialog::run (int stop_stack_depth, lay::Macro *macro)
} }
void void
MacroEditorDialog::set_run_macro (lay::Macro *m) MacroEditorDialog::set_run_macro (lym::Macro *m)
{ {
if (m != mp_run_macro) { if (m != mp_run_macro) {
std::map <Macro *, MacroEditorPage *>::const_iterator t = m_tab_widgets.find (mp_run_macro); std::map <lym::Macro *, MacroEditorPage *>::const_iterator t = m_tab_widgets.find (mp_run_macro);
if (t != m_tab_widgets.end ()) { if (t != m_tab_widgets.end ()) {
int index = tabWidget->indexOf (t->second); int index = tabWidget->indexOf (t->second);
if (index >= 0) { if (index >= 0) {

View File

@ -32,7 +32,7 @@
#include "tlTimer.h" #include "tlTimer.h"
#include "tlFileSystemWatcher.h" #include "tlFileSystemWatcher.h"
#include "tlDeferredExecution.h" #include "tlDeferredExecution.h"
#include "layMacro.h" #include "lymMacro.h"
#include "gsiInterpreter.h" #include "gsiInterpreter.h"
#include "tlScriptError.h" #include "tlScriptError.h"
@ -49,8 +49,6 @@ class QTreeWidgetItem;
namespace lay namespace lay
{ {
class Macro;
class MacroCollection;
class MacroEditorTree; class MacroEditorTree;
class BrowserPanel; class BrowserPanel;
@ -75,7 +73,7 @@ public:
/** /**
* @brief Constructor * @brief Constructor
*/ */
MacroEditorDialog (QWidget *parent, lay::MacroCollection *root); MacroEditorDialog (QWidget *parent, lym::MacroCollection *root);
/** /**
* @brief Destructor * @brief Destructor
@ -129,7 +127,7 @@ public:
/** /**
* @brief Gets the macro which is run * @brief Gets the macro which is run
*/ */
lay::Macro *run_macro () const lym::Macro *run_macro () const
{ {
return mp_run_macro; return mp_run_macro;
} }
@ -175,11 +173,11 @@ private slots:
void add_location (); void add_location ();
void remove_location (); void remove_location ();
void clear_breakpoints_button_clicked (); void clear_breakpoints_button_clicked ();
void item_double_clicked (lay::Macro *macro); void item_double_clicked (lym::Macro *macro);
void move_macro (lay::Macro *source, lay::MacroCollection *target); void move_macro (lym::Macro *source, lym::MacroCollection *target);
void move_folder (lay::MacroCollection *source, lay::MacroCollection *target); void move_folder (lym::MacroCollection *source, lym::MacroCollection *target);
void macro_renamed (lay::Macro *macro); void macro_renamed (lym::Macro *macro);
void folder_renamed (lay::MacroCollection *mc); void folder_renamed (lym::MacroCollection *mc);
void current_tab_changed (int index); void current_tab_changed (int index);
void commit (); void commit ();
void stack_element_double_clicked (QListWidgetItem *item); void stack_element_double_clicked (QListWidgetItem *item);
@ -190,10 +188,10 @@ private slots:
void replace_all_button_clicked (); void replace_all_button_clicked ();
void find_next_button_clicked (); void find_next_button_clicked ();
void help_requested (const QString &s); void help_requested (const QString &s);
void macro_changed (Macro *macro); void macro_changed (lym::Macro *macro);
void macro_deleted (Macro *macro); void macro_deleted (lym::Macro *macro);
void macro_collection_deleted (MacroCollection *collection); void macro_collection_deleted (lym::MacroCollection *collection);
void macro_collection_changed (MacroCollection *collection); void macro_collection_changed (lym::MacroCollection *collection);
void add_watch (); void add_watch ();
void edit_watch (); void edit_watch ();
void del_watches (); void del_watches ();
@ -229,9 +227,9 @@ protected:
private: private:
lay::MacroEditorTree *current_macro_tree (); lay::MacroEditorTree *current_macro_tree ();
lay::Macro *create_macro_here(const char *name = 0); lym::Macro *create_macro_here(const char *name = 0);
void move_subfolder (lay::MacroCollection *source, lay::MacroCollection *target); void move_subfolder (lym::MacroCollection *source, lym::MacroCollection *target);
lay::MacroEditorPage *create_page (lay::Macro *macro); lay::MacroEditorPage *create_page (lym::Macro *macro);
void ensure_writeable_collection_selected (); void ensure_writeable_collection_selected ();
void update_console_text (); void update_console_text ();
void start_exec (gsi::Interpreter *interpreter); void start_exec (gsi::Interpreter *interpreter);
@ -246,34 +244,34 @@ private:
void handle_error (tl::ScriptError &re); void handle_error (tl::ScriptError &re);
void set_exec_point (const std::string *file, int line, int eval_context); void set_exec_point (const std::string *file, int line, int eval_context);
MacroEditorPage *editor_for_file (const std::string &path); MacroEditorPage *editor_for_file (const std::string &path);
MacroEditorPage *editor_for_macro (lay::Macro *macro); MacroEditorPage *editor_for_macro (lym::Macro *macro);
void run (int stop_stack_depth, lay::Macro *macro); void run (int stop_stack_depth, lym::Macro *macro);
lay::Macro *current_run_macro (); lym::Macro *current_run_macro ();
void update_ui_to_run_mode (); void update_ui_to_run_mode ();
void do_update_ui_to_run_mode (); void do_update_ui_to_run_mode ();
void set_run_macro (lay::Macro *m); void set_run_macro (lym::Macro *m);
void apply_search (bool if_needed); void apply_search (bool if_needed);
void process_events (QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents); void process_events (QEventLoop::ProcessEventsFlags flags = QEventLoop::AllEvents);
void sync_file_watcher (lay::MacroCollection *current); void sync_file_watcher (lym::MacroCollection *current);
void do_refresh_file_watcher (); void do_refresh_file_watcher ();
void refresh_file_watcher (); void refresh_file_watcher ();
void reload_macros (); void reload_macros ();
void update_inspected (); void update_inspected ();
void update_watches (); void update_watches ();
lay::Macro *new_macro (); lym::Macro *new_macro ();
void do_search_edited (); void do_search_edited ();
void select_trace (size_t index); void select_trace (size_t index);
lay::MacroCollection *mp_root; lym::MacroCollection *mp_root;
bool m_first_show; bool m_first_show;
bool m_in_processing; bool m_in_processing;
bool m_debugging_on; bool m_debugging_on;
lay::Macro *mp_run_macro; lym::Macro *mp_run_macro;
std::vector<lay::Macro *> m_macro_templates; std::vector<lym::Macro *> m_macro_templates;
tl::DeferredMethod<MacroEditorDialog> md_update_console_text; tl::DeferredMethod<MacroEditorDialog> md_update_console_text;
tl::DeferredMethod<MacroEditorDialog> md_search_edited; tl::DeferredMethod<MacroEditorDialog> md_search_edited;
TextEditWidget *mp_console_text; TextEditWidget *mp_console_text;
std::map <Macro *, MacroEditorPage *> m_tab_widgets; std::map <lym::Macro *, MacroEditorPage *> m_tab_widgets;
int m_history_index; int m_history_index;
bool m_in_event_handler; bool m_in_event_handler;
QString m_edit_text; QString m_edit_text;
@ -283,7 +281,7 @@ private:
QTextCharFormat m_echo_format; QTextCharFormat m_echo_format;
QTextCharFormat m_stderr_format; QTextCharFormat m_stderr_format;
MacroEditorHighlighters m_highlighters; MacroEditorHighlighters m_highlighters;
std::vector<std::pair<Macro *, MacroEditorPage *> > m_file_to_widget; std::vector<std::pair<lym::Macro *, MacroEditorPage *> > m_file_to_widget;
std::vector<lay::MacroEditorTree *> m_macro_trees; std::vector<lay::MacroEditorTree *> m_macro_trees;
bool m_in_exec, m_in_breakpoint; bool m_in_exec, m_in_breakpoint;
gsi::Interpreter *mp_exec_controller, *mp_current_interpreter; gsi::Interpreter *mp_exec_controller, *mp_current_interpreter;

View File

@ -22,7 +22,7 @@
#include "layMacroEditorPage.h" #include "layMacroEditorPage.h"
#include "layMacroInterpreter.h" #include "lymMacroInterpreter.h"
#include "tlExceptions.h" #include "tlExceptions.h"
#include "tlString.h" #include "tlString.h"
@ -94,7 +94,7 @@ MacroEditorHighlighters::MacroEditorHighlighters (QObject *parent)
} }
QSyntaxHighlighter * QSyntaxHighlighter *
MacroEditorHighlighters::highlighter_for (QObject *parent, lay::Macro::Interpreter lang, const std::string &dsl_name) MacroEditorHighlighters::highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name)
{ {
std::string scheme = scheme_for (lang, dsl_name); std::string scheme = scheme_for (lang, dsl_name);
@ -127,7 +127,7 @@ MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::str
} }
GenericSyntaxHighlighterAttributes * GenericSyntaxHighlighterAttributes *
MacroEditorHighlighters::attributes_for (lay::Macro::Interpreter lang, const std::string &dsl_name) MacroEditorHighlighters::attributes_for (lym::Macro::Interpreter lang, const std::string &dsl_name)
{ {
std::string scheme = scheme_for (lang, dsl_name); std::string scheme = scheme_for (lang, dsl_name);
@ -195,14 +195,14 @@ MacroEditorHighlighters::load (const std::string &s)
} }
std::string std::string
MacroEditorHighlighters::scheme_for (lay::Macro::Interpreter lang, const std::string &dsl_name) MacroEditorHighlighters::scheme_for (lym::Macro::Interpreter lang, const std::string &dsl_name)
{ {
if (lang == Macro::Ruby) { if (lang == lym::Macro::Ruby) {
return "ruby"; return "ruby";
} else if (lang == Macro::Python) { } else if (lang == lym::Macro::Python) {
return "python"; return "python";
} else if (lang == Macro::DSLInterpreter) { } else if (lang == lym::Macro::DSLInterpreter) {
return MacroInterpreter::syntax_scheme (dsl_name); return lym::MacroInterpreter::syntax_scheme (dsl_name);
} else { } else {
return std::string (); return std::string ();
} }
@ -212,22 +212,22 @@ MacroEditorHighlighters::scheme_for (lay::Macro::Interpreter lang, const std::st
// MacroEditorExecutionModel implementation // MacroEditorExecutionModel implementation
MacroEditorExecutionModel::MacroEditorExecutionModel (QObject * /*parent*/) MacroEditorExecutionModel::MacroEditorExecutionModel (QObject * /*parent*/)
: m_current_line (-1), m_run_mode (false), m_interpreter (Macro::None) : m_current_line (-1), m_run_mode (false), m_interpreter (lym::Macro::None)
{ {
// .. nothing yet .. // .. nothing yet ..
} }
void MacroEditorExecutionModel::set_interpreter (Macro::Interpreter lang) void MacroEditorExecutionModel::set_interpreter (lym::Macro::Interpreter lang)
{ {
m_interpreter = lang; m_interpreter = lang;
if (lang == Macro::None) { if (lang == lym::Macro::None) {
set_breakpoints (std::set<int> ()); set_breakpoints (std::set<int> ());
} }
} }
void MacroEditorExecutionModel::set_breakpoints (const std::set<int> &b) void MacroEditorExecutionModel::set_breakpoints (const std::set<int> &b)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -239,7 +239,7 @@ void MacroEditorExecutionModel::set_breakpoints (const std::set<int> &b)
void MacroEditorExecutionModel::toggle_breakpoint (int line) void MacroEditorExecutionModel::toggle_breakpoint (int line)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -253,7 +253,7 @@ void MacroEditorExecutionModel::toggle_breakpoint (int line)
void MacroEditorExecutionModel::set_breakpoint (int line) void MacroEditorExecutionModel::set_breakpoint (int line)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -265,7 +265,7 @@ void MacroEditorExecutionModel::set_breakpoint (int line)
void MacroEditorExecutionModel::remove_breakpoint (int line) void MacroEditorExecutionModel::remove_breakpoint (int line)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -277,7 +277,7 @@ void MacroEditorExecutionModel::remove_breakpoint (int line)
void MacroEditorExecutionModel::set_current_line (int line, bool force_event) void MacroEditorExecutionModel::set_current_line (int line, bool force_event)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -289,7 +289,7 @@ void MacroEditorExecutionModel::set_current_line (int line, bool force_event)
void MacroEditorExecutionModel::set_run_mode (bool run_mode) void MacroEditorExecutionModel::set_run_mode (bool run_mode)
{ {
if (m_interpreter == Macro::None) { if (m_interpreter == lym::Macro::None) {
return; return;
} }
@ -803,7 +803,7 @@ void MacroEditorPage::apply_attributes ()
} }
} }
void MacroEditorPage::connect_macro (Macro *macro) void MacroEditorPage::connect_macro (lym::Macro *macro)
{ {
if (mp_macro != macro) { if (mp_macro != macro) {
@ -822,9 +822,9 @@ void MacroEditorPage::connect_macro (Macro *macro)
connect (mp_macro, SIGNAL (changed ()), this, SLOT (update ())); connect (mp_macro, SIGNAL (changed ()), this, SLOT (update ()));
Macro::Interpreter lang = macro->interpreter (); lym::Macro::Interpreter lang = macro->interpreter ();
if (lang == Macro::DSLInterpreter) { if (lang == lym::Macro::DSLInterpreter) {
lang = MacroInterpreter::debugger_scheme (macro->dsl_interpreter ()); lang = lym::MacroInterpreter::debugger_scheme (macro->dsl_interpreter ());
} }
mp_exec_model->set_interpreter (lang); mp_exec_model->set_interpreter (lang);
@ -842,7 +842,7 @@ void MacroEditorPage::connect_macro (Macro *macro)
m_is_modified = false; m_is_modified = false;
} else { } else {
mp_exec_model->set_interpreter (Macro::None); mp_exec_model->set_interpreter (lym::Macro::None);
} }
mp_side_panel->set_watermark (mp_macro ? tl::to_qstring (mp_macro->interpreter_name ()) : QString ()); mp_side_panel->set_watermark (mp_macro ? tl::to_qstring (mp_macro->interpreter_name ()) : QString ());

View File

@ -27,7 +27,7 @@
#include "layCommon.h" #include "layCommon.h"
#include "layMacro.h" #include "lymMacro.h"
#include "layGenericSyntaxHighlighter.h" #include "layGenericSyntaxHighlighter.h"
#include <QDialog> #include <QDialog>
@ -49,9 +49,6 @@ class QSyntaxHighlighter;
namespace lay namespace lay
{ {
class Macro;
class MacroCollection;
/** /**
* @brief A collection of highlighters * @brief A collection of highlighters
*/ */
@ -60,9 +57,9 @@ class MacroEditorHighlighters
public: public:
MacroEditorHighlighters (QObject *parent); MacroEditorHighlighters (QObject *parent);
QSyntaxHighlighter *highlighter_for (QObject *parent, lay::Macro::Interpreter lang, const std::string &dsl_name); QSyntaxHighlighter *highlighter_for (QObject *parent, lym::Macro::Interpreter lang, const std::string &dsl_name);
GenericSyntaxHighlighterAttributes *attributes_for (lay::Macro::Interpreter lang, const std::string &dsl_name); GenericSyntaxHighlighterAttributes *attributes_for (lym::Macro::Interpreter lang, const std::string &dsl_name);
GenericSyntaxHighlighterAttributes *basic_attributes (); GenericSyntaxHighlighterAttributes *basic_attributes ();
std::string to_string () const; std::string to_string () const;
@ -96,7 +93,7 @@ private:
GenericSyntaxHighlighterAttributes m_basic_attributes; GenericSyntaxHighlighterAttributes m_basic_attributes;
lay::GenericSyntaxHighlighter *highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes); lay::GenericSyntaxHighlighter *highlighter_for_scheme (QObject *parent, const std::string &scheme, GenericSyntaxHighlighterAttributes *attributes);
std::string scheme_for (lay::Macro::Interpreter lang, const std::string &dsl_name); std::string scheme_for (lym::Macro::Interpreter lang, const std::string &dsl_name);
}; };
/** /**
@ -123,7 +120,7 @@ public:
return m_breakpoints.find (line) != m_breakpoints.end (); return m_breakpoints.find (line) != m_breakpoints.end ();
} }
void set_interpreter (Macro::Interpreter lang); void set_interpreter (lym::Macro::Interpreter lang);
void set_breakpoints (const std::set<int> &b); void set_breakpoints (const std::set<int> &b);
@ -156,7 +153,7 @@ private:
std::set<int> m_breakpoints; std::set<int> m_breakpoints;
int m_current_line; int m_current_line;
bool m_run_mode; bool m_run_mode;
Macro::Interpreter m_interpreter; lym::Macro::Interpreter m_interpreter;
}; };
/** /**
@ -218,9 +215,9 @@ Q_OBJECT
public: public:
MacroEditorPage (QWidget *parent, MacroEditorHighlighters *highlighters); MacroEditorPage (QWidget *parent, MacroEditorHighlighters *highlighters);
void connect_macro (Macro *macro); void connect_macro (lym::Macro *macro);
Macro *macro () const lym::Macro *macro () const
{ {
return mp_macro; return mp_macro;
} }
@ -285,7 +282,7 @@ protected slots:
void run_mode_changed (); void run_mode_changed ();
private: private:
Macro *mp_macro; lym::Macro *mp_macro;
MacroEditorExecutionModel *mp_exec_model; MacroEditorExecutionModel *mp_exec_model;
MacroEditorTextWidget *mp_text; MacroEditorTextWidget *mp_text;
MacroEditorSidePanel *mp_side_panel; MacroEditorSidePanel *mp_side_panel;

View File

@ -24,8 +24,8 @@
#ifndef HDR_layMacroEditorSetupDialog #ifndef HDR_layMacroEditorSetupDialog
#define HDR_layMacroEditorSetupDialog #define HDR_layMacroEditorSetupDialog
#include "layMacro.h"
#include "layGenericSyntaxHighlighter.h" #include "layGenericSyntaxHighlighter.h"
#include "lymMacro.h"
#include "ui_MacroEditorSetupDialog.h" #include "ui_MacroEditorSetupDialog.h"
#include <QDialog> #include <QDialog>

View File

@ -23,7 +23,7 @@
#include "layMacroEditorTree.h" #include "layMacroEditorTree.h"
#include "layMacroEditorDialog.h" #include "layMacroEditorDialog.h"
#include "layMacro.h" #include "lymMacro.h"
#include "tlExceptions.h" #include "tlExceptions.h"
#include "tlInternational.h" #include "tlInternational.h"
#include "tlException.h" #include "tlException.h"
@ -40,13 +40,13 @@ namespace lay
// ----------------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------------
// A model for the macro tree // A model for the macro tree
static QIcon tree_icon_for_format (const lay::Macro *m, bool active) static QIcon tree_icon_for_format (const lym::Macro *m, bool active)
{ {
// TODO: create a nice icon for the DSL interpreted scripts // TODO: create a nice icon for the DSL interpreted scripts
if (m->interpreter () == Macro::Text) { if (m->interpreter () == lym::Macro::Text) {
return QIcon (QString::fromUtf8 (":/textdocumenticon.png")); return QIcon (QString::fromUtf8 (":/textdocumenticon.png"));
} else if (m->interpreter () == Macro::Ruby) { } else if (m->interpreter () == lym::Macro::Ruby) {
if (m->format () == Macro::PlainTextFormat || m->format () == Macro::PlainTextWithHashAnnotationsFormat) { if (m->format () == lym::Macro::PlainTextFormat || m->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
if (active) { if (active) {
return QIcon (QString::fromUtf8 (":/rubymacroiconactive.png")); return QIcon (QString::fromUtf8 (":/rubymacroiconactive.png"));
} else { } else {
@ -59,8 +59,8 @@ static QIcon tree_icon_for_format (const lay::Macro *m, bool active)
return QIcon (QString::fromUtf8 (":/generalmacroicon.png")); return QIcon (QString::fromUtf8 (":/generalmacroicon.png"));
} }
} }
} else if (m->interpreter () == Macro::Python) { } else if (m->interpreter () == lym::Macro::Python) {
if (m->format () == Macro::PlainTextFormat || m->format () == Macro::PlainTextWithHashAnnotationsFormat) { if (m->format () == lym::Macro::PlainTextFormat || m->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
if (active) { if (active) {
return QIcon (QString::fromUtf8 (":/pythonmacroiconactive.png")); return QIcon (QString::fromUtf8 (":/pythonmacroiconactive.png"));
} else { } else {
@ -80,7 +80,7 @@ static QIcon tree_icon_for_format (const lay::Macro *m, bool active)
struct FilteredMacroCollectionIter struct FilteredMacroCollectionIter
{ {
FilteredMacroCollectionIter (const lay::MacroCollection *mc, const std::string &cat) FilteredMacroCollectionIter (const lym::MacroCollection *mc, const std::string &cat)
: m_b (mc->begin_children ()), m_e (mc->end_children ()), m_category (cat) : m_b (mc->begin_children ()), m_e (mc->end_children ()), m_category (cat)
{ {
next (); next ();
@ -91,12 +91,12 @@ struct FilteredMacroCollectionIter
return m_b == m_e; return m_b == m_e;
} }
std::pair<const std::string, lay::MacroCollection *> operator* () const std::pair<const std::string, lym::MacroCollection *> operator* () const
{ {
return m_b.operator* (); return m_b.operator* ();
} }
const std::pair<const std::string, lay::MacroCollection *> *operator-> () const const std::pair<const std::string, lym::MacroCollection *> *operator-> () const
{ {
return m_b.operator-> (); return m_b.operator-> ();
} }
@ -108,7 +108,7 @@ struct FilteredMacroCollectionIter
} }
private: private:
lay::MacroCollection::const_child_iterator m_b, m_e; lym::MacroCollection::const_child_iterator m_b, m_e;
std::string m_category; std::string m_category;
void next () void next ()
@ -119,23 +119,23 @@ private:
} }
}; };
MacroTreeModel::MacroTreeModel (QObject *parent, lay::MacroEditorDialog *dialog, lay::MacroCollection *root, const std::string &cat) MacroTreeModel::MacroTreeModel (QObject *parent, lay::MacroEditorDialog *dialog, lym::MacroCollection *root, const std::string &cat)
: QAbstractItemModel (parent), mp_dialog (dialog), mp_parent (dialog), mp_root (root), m_category (cat) : QAbstractItemModel (parent), mp_dialog (dialog), mp_parent (dialog), mp_root (root), m_category (cat)
{ {
connect (root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed ())); connect (root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *))); connect (root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *))); connect (root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ())); connect (root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (root, SIGNAL (about_to_change ()), this, SLOT (about_to_change ())); connect (root, SIGNAL (about_to_change ()), this, SLOT (about_to_change ()));
} }
MacroTreeModel::MacroTreeModel (QWidget *parent, lay::MacroCollection *root, const std::string &cat) MacroTreeModel::MacroTreeModel (QWidget *parent, lym::MacroCollection *root, const std::string &cat)
: QAbstractItemModel (parent), mp_dialog (0), mp_parent (parent), mp_root (root), m_category (cat) : QAbstractItemModel (parent), mp_dialog (0), mp_parent (parent), mp_root (root), m_category (cat)
{ {
connect (root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed ())); connect (root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *))); connect (root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *))); connect (root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ())); connect (root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (root, SIGNAL (about_to_change ()), this, SLOT (about_to_change ())); connect (root, SIGNAL (about_to_change ()), this, SLOT (about_to_change ()));
} }
@ -144,12 +144,12 @@ Qt::DropActions MacroTreeModel::supportedDropActions() const
return Qt::MoveAction; return Qt::MoveAction;
} }
void MacroTreeModel::macro_deleted (lay::Macro *) void MacroTreeModel::macro_deleted (lym::Macro *)
{ {
// .. nothing yet .. // .. nothing yet ..
} }
void MacroTreeModel::macro_collection_deleted (lay::MacroCollection *) void MacroTreeModel::macro_collection_deleted (lym::MacroCollection *)
{ {
// .. nothing yet .. // .. nothing yet ..
} }
@ -177,8 +177,8 @@ void MacroTreeModel::macro_collection_changed ()
QModelIndexList pi = persistentIndexList (); QModelIndexList pi = persistentIndexList ();
for (QModelIndexList::const_iterator i = pi.begin (); i != pi.end (); ++i) { for (QModelIndexList::const_iterator i = pi.begin (); i != pi.end (); ++i) {
if (is_valid_pointer (i->internalPointer ())) { if (is_valid_pointer (i->internalPointer ())) {
lay::Macro *macro = dynamic_cast <lay::Macro *> ((QObject *) i->internalPointer ()); lym::Macro *macro = dynamic_cast <lym::Macro *> ((QObject *) i->internalPointer ());
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> ((QObject *) i->internalPointer ()); lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> ((QObject *) i->internalPointer ());
if (macro) { if (macro) {
changePersistentIndex (*i, index_for (macro)); changePersistentIndex (*i, index_for (macro));
} else if (mc) { } else if (mc) {
@ -203,13 +203,13 @@ bool MacroTreeModel::is_valid_pointer (void *ptr) const
{ {
if (m_valid_objects.empty ()) { if (m_valid_objects.empty ()) {
std::set<lay::Macro *> macros; std::set<lym::Macro *> macros;
std::set<lay::MacroCollection *> macro_collections; std::set<lym::MacroCollection *> macro_collections;
mp_root->collect_used_nodes (macros, macro_collections); mp_root->collect_used_nodes (macros, macro_collections);
for (std::set<lay::Macro *>::const_iterator m = macros.begin (); m != macros.end (); ++m) { for (std::set<lym::Macro *>::const_iterator m = macros.begin (); m != macros.end (); ++m) {
m_valid_objects.insert ((void *)(QObject *)*m); m_valid_objects.insert ((void *)(QObject *)*m);
} }
for (std::set<lay::MacroCollection *>::const_iterator m = macro_collections.begin (); m != macro_collections.end (); ++m) { for (std::set<lym::MacroCollection *>::const_iterator m = macro_collections.begin (); m != macro_collections.end (); ++m) {
m_valid_objects.insert ((void *)(QObject *)*m); m_valid_objects.insert ((void *)(QObject *)*m);
} }
@ -258,7 +258,7 @@ bool MacroTreeModel::dropMimeData (const QMimeData *data, Qt::DropAction /*actio
return false; return false;
} }
lay::MacroCollection *to_mc = dynamic_cast <lay::MacroCollection *> ((QObject *) parent.internalPointer ()); lym::MacroCollection *to_mc = dynamic_cast <lym::MacroCollection *> ((QObject *) parent.internalPointer ());
if (! to_mc) { if (! to_mc) {
return false; return false;
} }
@ -271,8 +271,8 @@ bool MacroTreeModel::dropMimeData (const QMimeData *data, Qt::DropAction /*actio
if (is_valid_pointer ((void *) p)) { if (is_valid_pointer ((void *) p)) {
QObject *from_object = (QObject *) (void *) p; QObject *from_object = (QObject *) (void *) p;
lay::Macro *from_macro = dynamic_cast <lay::Macro *> (from_object); lym::Macro *from_macro = dynamic_cast <lym::Macro *> (from_object);
lay::MacroCollection *from_mc = dynamic_cast <lay::MacroCollection *> (from_object); lym::MacroCollection *from_mc = dynamic_cast <lym::MacroCollection *> (from_object);
if (from_macro) { if (from_macro) {
emit move_macro (from_macro, to_mc); emit move_macro (from_macro, to_mc);
@ -299,8 +299,8 @@ bool MacroTreeModel::setData (const QModelIndex &index, const QVariant &v, int r
} }
QObject *object = (QObject *) index.internalPointer (); QObject *object = (QObject *) index.internalPointer ();
lay::Macro *macro = dynamic_cast <lay::Macro *> (object); lym::Macro *macro = dynamic_cast <lym::Macro *> (object);
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> (object); lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> (object);
// TODO: don't do this while executing // TODO: don't do this while executing
if (macro) { if (macro) {
@ -337,8 +337,8 @@ QVariant MacroTreeModel::data (const QModelIndex &index, int role) const
} }
const QObject *object = (QObject *) index.internalPointer (); const QObject *object = (QObject *) index.internalPointer ();
const lay::Macro *macro = dynamic_cast <const lay::Macro *> (object); const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object); const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
if (macro) { if (macro) {
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
return QVariant (tl::to_qstring (macro->display_string ())); return QVariant (tl::to_qstring (macro->display_string ()));
@ -384,8 +384,8 @@ Qt::ItemFlags MacroTreeModel::flags (const QModelIndex &index) const
} }
const QObject *object = (QObject *) index.internalPointer (); const QObject *object = (QObject *) index.internalPointer ();
const lay::Macro *macro = dynamic_cast <const lay::Macro *> (object); const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object); const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
if (macro) { if (macro) {
if (! macro->is_readonly ()) { if (! macro->is_readonly ()) {
return QAbstractItemModel::flags (index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled; return QAbstractItemModel::flags (index) | Qt::ItemIsEditable | Qt::ItemIsDragEnabled;
@ -406,14 +406,14 @@ Qt::ItemFlags MacroTreeModel::flags (const QModelIndex &index) const
bool MacroTreeModel::hasChildren (const QModelIndex &parent) const bool MacroTreeModel::hasChildren (const QModelIndex &parent) const
{ {
const lay::MacroCollection *mc = 0; const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) { if (! parent.isValid ()) {
mc = mp_root; mc = mp_root;
} else { } else {
if (! is_valid_pointer (parent.internalPointer ())) { if (! is_valid_pointer (parent.internalPointer ())) {
return false; return false;
} }
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ()); mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
} }
if (mc) { if (mc) {
return ! FilteredMacroCollectionIter (mc, m_category).at_end () || mc->begin () != mc->end (); return ! FilteredMacroCollectionIter (mc, m_category).at_end () || mc->begin () != mc->end ();
@ -429,10 +429,10 @@ QModelIndex MacroTreeModel::parent (const QModelIndex &index) const
} }
const QObject *object = (QObject *) index.internalPointer (); const QObject *object = (QObject *) index.internalPointer ();
const lay::Macro *macro = dynamic_cast <const lay::Macro *> (object); const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object); const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
const lay::MacroCollection *p = 0; const lym::MacroCollection *p = 0;
if (macro) { if (macro) {
p = macro->parent (); p = macro->parent ();
} else if (mc) { } else if (mc) {
@ -440,7 +440,7 @@ QModelIndex MacroTreeModel::parent (const QModelIndex &index) const
} }
if (p) { if (p) {
const lay::MacroCollection *pp = p->parent (); const lym::MacroCollection *pp = p->parent ();
if (pp) { if (pp) {
int row = 0; int row = 0;
for (FilteredMacroCollectionIter i (pp, m_category); ! i.at_end (); ++i, ++row) { for (FilteredMacroCollectionIter i (pp, m_category); ! i.at_end (); ++i, ++row) {
@ -456,14 +456,14 @@ QModelIndex MacroTreeModel::parent (const QModelIndex &index) const
QModelIndex MacroTreeModel::index (int row, int column, const QModelIndex &parent) const QModelIndex MacroTreeModel::index (int row, int column, const QModelIndex &parent) const
{ {
const lay::MacroCollection *mc = 0; const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) { if (! parent.isValid ()) {
mc = mp_root; mc = mp_root;
} else { } else {
if (! is_valid_pointer (parent.internalPointer ())) { if (! is_valid_pointer (parent.internalPointer ())) {
return QModelIndex (); return QModelIndex ();
} }
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ()); mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
} }
if (mc) { if (mc) {
@ -475,7 +475,7 @@ QModelIndex MacroTreeModel::index (int row, int column, const QModelIndex &paren
} }
++i; ++i;
} }
lay::MacroCollection::const_iterator j = mc->begin (); lym::MacroCollection::const_iterator j = mc->begin ();
while (j != mc->end ()) { while (j != mc->end ()) {
if (r-- <= 0) { if (r-- <= 0) {
return createIndex (row, column, (void *)(QObject *)j->second); return createIndex (row, column, (void *)(QObject *)j->second);
@ -489,14 +489,14 @@ QModelIndex MacroTreeModel::index (int row, int column, const QModelIndex &paren
int MacroTreeModel::rowCount (const QModelIndex &parent) const int MacroTreeModel::rowCount (const QModelIndex &parent) const
{ {
const lay::MacroCollection *mc = 0; const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) { if (! parent.isValid ()) {
mc = mp_root; mc = mp_root;
} else { } else {
if (! is_valid_pointer (parent.internalPointer ())) { if (! is_valid_pointer (parent.internalPointer ())) {
return 0; return 0;
} }
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ()); mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
} }
int n = 0; int n = 0;
@ -504,7 +504,7 @@ int MacroTreeModel::rowCount (const QModelIndex &parent) const
for (FilteredMacroCollectionIter i (mc, m_category); ! i.at_end (); ++i) { for (FilteredMacroCollectionIter i (mc, m_category); ! i.at_end (); ++i) {
++n; ++n;
} }
for (lay::MacroCollection::const_iterator i = mc->begin (); i != mc->end (); ++i) { for (lym::MacroCollection::const_iterator i = mc->begin (); i != mc->end (); ++i) {
++n; ++n;
} }
} }
@ -512,14 +512,14 @@ int MacroTreeModel::rowCount (const QModelIndex &parent) const
} }
QModelIndex QModelIndex
MacroTreeModel::index_for (lay::Macro *macro) const MacroTreeModel::index_for (lym::Macro *macro) const
{ {
if (! macro || ! macro->parent ()) { if (! macro || ! macro->parent ()) {
return QModelIndex (); return QModelIndex ();
} }
// check category // check category
const lay::MacroCollection *pp = macro->parent (); const lym::MacroCollection *pp = macro->parent ();
while (pp && (pp->category ().empty () || pp->category () == m_category)) { while (pp && (pp->category ().empty () || pp->category () == m_category)) {
pp = pp->parent (); pp = pp->parent ();
} }
@ -533,7 +533,7 @@ MacroTreeModel::index_for (lay::Macro *macro) const
for (FilteredMacroCollectionIter i (pp, m_category); ! i.at_end (); ++i, ++row) { for (FilteredMacroCollectionIter i (pp, m_category); ! i.at_end (); ++i, ++row) {
; ;
} }
for (lay::MacroCollection::const_iterator i = pp->begin (); i != pp->end (); ++i, ++row) { for (lym::MacroCollection::const_iterator i = pp->begin (); i != pp->end (); ++i, ++row) {
if (i->second == macro) { if (i->second == macro) {
return createIndex (row, 0, (void *)(QObject *)macro); return createIndex (row, 0, (void *)(QObject *)macro);
} }
@ -543,14 +543,14 @@ MacroTreeModel::index_for (lay::Macro *macro) const
} }
QModelIndex QModelIndex
MacroTreeModel::index_for (lay::MacroCollection *mc) const MacroTreeModel::index_for (lym::MacroCollection *mc) const
{ {
if (! mc || ! mc->parent ()) { if (! mc || ! mc->parent ()) {
return QModelIndex (); return QModelIndex ();
} }
// check category // check category
const lay::MacroCollection *pp = mc; const lym::MacroCollection *pp = mc;
while (pp && (pp->category ().empty () || pp->category () == m_category)) { while (pp && (pp->category ().empty () || pp->category () == m_category)) {
pp = pp->parent (); pp = pp->parent ();
} }
@ -585,49 +585,49 @@ MacroEditorTree::MacroEditorTree (QWidget *parent, const std::string &cat)
setDropIndicatorShown (true); setDropIndicatorShown (true);
} }
void MacroEditorTree::model_macro_renamed (lay::Macro *macro) void MacroEditorTree::model_macro_renamed (lym::Macro *macro)
{ {
set_current (macro); set_current (macro);
emit macro_renamed (macro); emit macro_renamed (macro);
} }
void MacroEditorTree::model_folder_renamed (lay::MacroCollection *mc) void MacroEditorTree::model_folder_renamed (lym::MacroCollection *mc)
{ {
set_current (mc); set_current (mc);
emit folder_renamed (mc); emit folder_renamed (mc);
} }
void MacroEditorTree::model_move_macro (lay::Macro *source, lay::MacroCollection *target) void MacroEditorTree::model_move_macro (lym::Macro *source, lym::MacroCollection *target)
{ {
emit move_macro (source, target); emit move_macro (source, target);
} }
void MacroEditorTree::model_move_folder (lay::MacroCollection *source, lay::MacroCollection *target) void MacroEditorTree::model_move_folder (lym::MacroCollection *source, lym::MacroCollection *target)
{ {
emit move_folder (source, target); emit move_folder (source, target);
} }
lay::Macro *MacroEditorTree::current_macro () const lym::Macro *MacroEditorTree::current_macro () const
{ {
QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ()); QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ());
if (ci.isValid () && mp_model->is_valid_pointer (ci.internalPointer ())) { if (ci.isValid () && mp_model->is_valid_pointer (ci.internalPointer ())) {
return dynamic_cast <lay::Macro *> ((QObject *) ci.internalPointer ()); return dynamic_cast <lym::Macro *> ((QObject *) ci.internalPointer ());
} else { } else {
return 0; return 0;
} }
} }
lay::MacroCollection *MacroEditorTree::current_macro_collection () const lym::MacroCollection *MacroEditorTree::current_macro_collection () const
{ {
QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ()); QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ());
if (ci.isValid () && mp_model->is_valid_pointer (ci.internalPointer ())) { if (ci.isValid () && mp_model->is_valid_pointer (ci.internalPointer ())) {
return dynamic_cast <lay::MacroCollection *> ((QObject *) ci.internalPointer ()); return dynamic_cast <lym::MacroCollection *> ((QObject *) ci.internalPointer ());
} else { } else {
return 0; return 0;
} }
} }
bool MacroEditorTree::set_current (lay::Macro *macro) bool MacroEditorTree::set_current (lym::Macro *macro)
{ {
QModelIndex index = mp_proxyModel->mapFromSource (mp_model->index_for (macro)); QModelIndex index = mp_proxyModel->mapFromSource (mp_model->index_for (macro));
setCurrentIndex (index); setCurrentIndex (index);
@ -639,7 +639,7 @@ bool MacroEditorTree::set_current (lay::Macro *macro)
} }
} }
bool MacroEditorTree::set_current (lay::MacroCollection *mc) bool MacroEditorTree::set_current (lym::MacroCollection *mc)
{ {
QModelIndex index = mp_proxyModel->mapFromSource (mp_model->index_for (mc)); QModelIndex index = mp_proxyModel->mapFromSource (mp_model->index_for (mc));
setCurrentIndex (index); setCurrentIndex (index);
@ -653,16 +653,16 @@ bool MacroEditorTree::set_current (lay::MacroCollection *mc)
void MacroEditorTree::setup (lay::MacroEditorDialog *dialog) void MacroEditorTree::setup (lay::MacroEditorDialog *dialog)
{ {
mp_model = new MacroTreeModel (this, dialog, &lay::MacroCollection::root (), m_category); mp_model = new MacroTreeModel (this, dialog, &lym::MacroCollection::root (), m_category);
mp_proxyModel = new QSortFilterProxyModel (this); mp_proxyModel = new QSortFilterProxyModel (this);
mp_proxyModel->setSourceModel (mp_model); mp_proxyModel->setSourceModel (mp_model);
setModel (mp_proxyModel); setModel (mp_proxyModel);
connect (this, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (double_clicked_slot (const QModelIndex &))); connect (this, SIGNAL (doubleClicked (const QModelIndex &)), this, SLOT (double_clicked_slot (const QModelIndex &)));
connect (mp_model, SIGNAL (macro_renamed (lay::Macro *)), this, SLOT (model_macro_renamed (lay::Macro *))); connect (mp_model, SIGNAL (macro_renamed (lym::Macro *)), this, SLOT (model_macro_renamed (lym::Macro *)));
connect (mp_model, SIGNAL (folder_renamed (lay::MacroCollection *)), this, SLOT (model_folder_renamed (lay::MacroCollection *))); connect (mp_model, SIGNAL (folder_renamed (lym::MacroCollection *)), this, SLOT (model_folder_renamed (lym::MacroCollection *)));
connect (mp_model, SIGNAL (move_macro (lay::Macro *, lay::MacroCollection *)), this, SLOT (model_move_macro (lay::Macro *, lay::MacroCollection *))); connect (mp_model, SIGNAL (move_macro (lym::Macro *, lym::MacroCollection *)), this, SLOT (model_move_macro (lym::Macro *, lym::MacroCollection *)));
connect (mp_model, SIGNAL (move_folder (lay::MacroCollection *, lay::MacroCollection *)), this, SLOT (model_move_folder (lay::MacroCollection *, lay::MacroCollection *))); connect (mp_model, SIGNAL (move_folder (lym::MacroCollection *, lym::MacroCollection *)), this, SLOT (model_move_folder (lym::MacroCollection *, lym::MacroCollection *)));
} }
void MacroEditorTree::double_clicked_slot (const QModelIndex &index) void MacroEditorTree::double_clicked_slot (const QModelIndex &index)
@ -672,8 +672,8 @@ void MacroEditorTree::double_clicked_slot (const QModelIndex &index)
if (mp_model->is_valid_pointer (i.internalPointer ())) { if (mp_model->is_valid_pointer (i.internalPointer ())) {
QObject *object = (QObject *) i.internalPointer (); QObject *object = (QObject *) i.internalPointer ();
lay::Macro *macro = dynamic_cast <lay::Macro *> (object); lym::Macro *macro = dynamic_cast <lym::Macro *> (object);
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> (object); lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> (object);
if (macro) { if (macro) {
emit macro_double_clicked (macro); emit macro_double_clicked (macro);

View File

@ -24,6 +24,8 @@
#ifndef HDR_layMacroEditorTree #ifndef HDR_layMacroEditorTree
#define HDR_layMacroEditorTree #define HDR_layMacroEditorTree
#include "lymMacro.h"
#include <QTreeView> #include <QTreeView>
#include <set> #include <set>
@ -33,8 +35,6 @@ class QSortFilterProxyModel;
namespace lay namespace lay
{ {
class Macro;
class MacroCollection;
class MacroEditorDialog; class MacroEditorDialog;
class MacroTreeModel class MacroTreeModel
@ -43,8 +43,8 @@ class MacroTreeModel
Q_OBJECT Q_OBJECT
public: public:
MacroTreeModel (QObject *parent, lay::MacroEditorDialog *dialog, lay::MacroCollection *root, const std::string &cat); MacroTreeModel (QObject *parent, lay::MacroEditorDialog *dialog, lym::MacroCollection *root, const std::string &cat);
MacroTreeModel (QWidget *parent, lay::MacroCollection *root, const std::string &cat); MacroTreeModel (QWidget *parent, lym::MacroCollection *root, const std::string &cat);
int columnCount (const QModelIndex &parent) const; int columnCount (const QModelIndex &parent) const;
QVariant data (const QModelIndex &index, int role) const; QVariant data (const QModelIndex &index, int role) const;
@ -55,22 +55,22 @@ public:
int rowCount (const QModelIndex &parent) const; int rowCount (const QModelIndex &parent) const;
bool setData (const QModelIndex &index, const QVariant &v, int role); bool setData (const QModelIndex &index, const QVariant &v, int role);
Qt::DropActions supportedDropActions() const; Qt::DropActions supportedDropActions() const;
QModelIndex index_for (lay::Macro *macro) const; QModelIndex index_for (lym::Macro *macro) const;
QModelIndex index_for (lay::MacroCollection *mc) const; QModelIndex index_for (lym::MacroCollection *mc) const;
void update_data (); void update_data ();
bool is_valid_pointer (void *) const; bool is_valid_pointer (void *) const;
signals: signals:
void macro_renamed (lay::Macro *macro); void macro_renamed (lym::Macro *macro);
void folder_renamed (lay::MacroCollection *folder); void folder_renamed (lym::MacroCollection *folder);
void move_macro (lay::Macro *source, lay::MacroCollection *target); void move_macro (lym::Macro *source, lym::MacroCollection *target);
void move_folder (lay::MacroCollection *source, lay::MacroCollection *target); void move_folder (lym::MacroCollection *source, lym::MacroCollection *target);
private slots: private slots:
void macro_changed (); void macro_changed ();
void macro_deleted (Macro *macro); void macro_deleted (lym::Macro *macro);
void macro_collection_deleted (MacroCollection *mc); void macro_collection_deleted (lym::MacroCollection *mc);
void macro_collection_changed (); void macro_collection_changed ();
void about_to_change (); void about_to_change ();
@ -82,7 +82,7 @@ private:
lay::MacroEditorDialog *mp_dialog; lay::MacroEditorDialog *mp_dialog;
QWidget *mp_parent; QWidget *mp_parent;
lay::MacroCollection *mp_root; lym::MacroCollection *mp_root;
std::string m_category; std::string m_category;
mutable std::set <void *> m_valid_objects; mutable std::set <void *> m_valid_objects;
}; };
@ -96,23 +96,23 @@ public:
MacroEditorTree (QWidget *parent, const std::string &cat); MacroEditorTree (QWidget *parent, const std::string &cat);
void setup (lay::MacroEditorDialog *dialog); void setup (lay::MacroEditorDialog *dialog);
lay::Macro *current_macro () const; lym::Macro *current_macro () const;
lay::MacroCollection *current_macro_collection () const; lym::MacroCollection *current_macro_collection () const;
bool set_current (lay::Macro *macro); bool set_current (lym::Macro *macro);
bool set_current (lay::MacroCollection *mc); bool set_current (lym::MacroCollection *mc);
void update_data () void update_data ()
{ {
mp_model->update_data (); mp_model->update_data ();
} }
QModelIndex index_for (lay::Macro *macro) const QModelIndex index_for (lym::Macro *macro) const
{ {
return mp_model->index_for (macro); return mp_model->index_for (macro);
} }
QModelIndex index_for (lay::MacroCollection *mc) const QModelIndex index_for (lym::MacroCollection *mc) const
{ {
return mp_model->index_for (mc); return mp_model->index_for (mc);
} }
@ -123,12 +123,12 @@ public:
} }
signals: signals:
void move_macro (lay::Macro *source, lay::MacroCollection *target); void move_macro (lym::Macro *source, lym::MacroCollection *target);
void move_folder (lay::MacroCollection *source, lay::MacroCollection *target); void move_folder (lym::MacroCollection *source, lym::MacroCollection *target);
void macro_double_clicked (lay::Macro *macro); void macro_double_clicked (lym::Macro *macro);
void macro_collection_double_clicked (lay::MacroCollection *mc); void macro_collection_double_clicked (lym::MacroCollection *mc);
void macro_renamed (lay::Macro *macro); void macro_renamed (lym::Macro *macro);
void folder_renamed (lay::MacroCollection *folder); void folder_renamed (lym::MacroCollection *folder);
private: private:
QSortFilterProxyModel *mp_proxyModel; QSortFilterProxyModel *mp_proxyModel;
@ -137,10 +137,10 @@ private:
private slots: private slots:
void double_clicked_slot (const QModelIndex &index); void double_clicked_slot (const QModelIndex &index);
void model_move_macro (lay::Macro *source, lay::MacroCollection *target); void model_move_macro (lym::Macro *source, lym::MacroCollection *target);
void model_move_folder (lay::MacroCollection *source, lay::MacroCollection *target); void model_move_folder (lym::MacroCollection *source, lym::MacroCollection *target);
void model_macro_renamed (lay::Macro *macro); void model_macro_renamed (lym::Macro *macro);
void model_folder_renamed (lay::MacroCollection *folder); void model_folder_renamed (lym::MacroCollection *folder);
}; };
} }

View File

@ -23,7 +23,7 @@
#include "layMacroPropertiesDialog.h" #include "layMacroPropertiesDialog.h"
#include "layMainWindow.h" #include "layMainWindow.h"
#include "layMacroInterpreter.h" #include "lymMacroInterpreter.h"
#include "tlString.h" #include "tlString.h"
#include <QKeySequence> #include <QKeySequence>
@ -41,7 +41,7 @@ MacroPropertiesDialog::MacroPropertiesDialog (QWidget *parent)
} }
int int
MacroPropertiesDialog::exec_dialog (lay::Macro *macro) MacroPropertiesDialog::exec_dialog (lym::Macro *macro)
{ {
update (macro); update (macro);
int ret = QDialog::exec (); int ret = QDialog::exec ();
@ -59,15 +59,15 @@ MacroPropertiesDialog::shortcut_edited ()
} }
void void
MacroPropertiesDialog::update (const lay::Macro *macro) MacroPropertiesDialog::update (const lym::Macro *macro)
{ {
std::string ip = "-"; std::string ip = "-";
if (macro->interpreter () == lay::Macro::Ruby) { if (macro->interpreter () == lym::Macro::Ruby) {
ip = "Ruby"; ip = "Ruby";
} else if (macro->interpreter () == lay::Macro::Python) { } else if (macro->interpreter () == lym::Macro::Python) {
ip = "Python"; ip = "Python";
} else if (macro->interpreter () == lay::Macro::DSLInterpreter) { } else if (macro->interpreter () == lym::Macro::DSLInterpreter) {
ip = lay::MacroInterpreter::description (macro->dsl_interpreter ()); ip = lym::MacroInterpreter::description (macro->dsl_interpreter ());
} }
interpreterLabel->setText (tl::to_qstring (ip)); interpreterLabel->setText (tl::to_qstring (ip));
@ -85,7 +85,7 @@ MacroPropertiesDialog::update (const lay::Macro *macro)
} }
void void
MacroPropertiesDialog::commit (lay::Macro *macro) MacroPropertiesDialog::commit (lym::Macro *macro)
{ {
macro->set_description (tl::to_string (description->text ())); macro->set_description (tl::to_string (description->text ()));
macro->set_version (tl::to_string (version->text ())); macro->set_version (tl::to_string (version->text ()));

View File

@ -27,7 +27,7 @@
#include "layCommon.h" #include "layCommon.h"
#include "ui_MacroPropertiesDialog.h" #include "ui_MacroPropertiesDialog.h"
#include "layMacro.h" #include "lymMacro.h"
namespace lay namespace lay
{ {
@ -43,14 +43,14 @@ Q_OBJECT
public: public:
MacroPropertiesDialog (QWidget *parent); MacroPropertiesDialog (QWidget *parent);
int exec_dialog (lay::Macro *macro); int exec_dialog (lym::Macro *macro);
public slots: public slots:
void shortcut_edited (); void shortcut_edited ();
private: private:
void update (const lay::Macro *macro); void update (const lym::Macro *macro);
void commit (lay::Macro *macro); void commit (lym::Macro *macro);
}; };
} }

View File

@ -40,7 +40,6 @@
#include "dbLoadLayoutOptions.h" #include "dbLoadLayoutOptions.h"
#include "layAbstractMenu.h" #include "layAbstractMenu.h"
#include "layAbstractMenuProvider.h" #include "layAbstractMenuProvider.h"
#include "layMacro.h"
#include "layLayoutView.h" #include "layLayoutView.h"
#include "layPlugin.h" #include "layPlugin.h"
#include "layProgress.h" #include "layProgress.h"

View File

@ -30,9 +30,9 @@
#include "layMainWindow.h" #include "layMainWindow.h"
#include "layApplication.h" #include "layApplication.h"
#include "layMacroEditorTree.h" #include "layMacroEditorTree.h"
#include "layMacro.h"
#include "layMacroController.h" #include "layMacroController.h"
#include "layTechnologyController.h" #include "layTechnologyController.h"
#include "lymMacro.h"
#include "tlAssert.h" #include "tlAssert.h"
#include "tlStream.h" #include "tlStream.h"
#include "dbStream.h" #include "dbStream.h"
@ -362,17 +362,17 @@ TechMacrosPage::setup ()
QString cp = macro_dir.canonicalPath (); QString cp = macro_dir.canonicalPath ();
// if a macro collection already exists, show a readonly copy of this one // if a macro collection already exists, show a readonly copy of this one
const lay::MacroCollection *original = 0; const lym::MacroCollection *original = 0;
const lay::MacroCollection *root = &lay::MacroCollection::root (); const lym::MacroCollection *root = &lym::MacroCollection::root ();
for (lay::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! original; ++m) { for (lym::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! original; ++m) {
if (m->second->virtual_mode () == lay::MacroCollection::TechFolder && m->second->category () == m_cat && QDir (tl::to_qstring (m->second->path ())).canonicalPath () == cp) { if (m->second->virtual_mode () == lym::MacroCollection::TechFolder && m->second->category () == m_cat && QDir (tl::to_qstring (m->second->path ())).canonicalPath () == cp) {
original = m->second; original = m->second;
} }
} }
const lay::MacroCollection *alt = 0; const lym::MacroCollection *alt = 0;
for (lay::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! alt; ++m) { for (lym::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! alt; ++m) {
if (m->second->virtual_mode () != lay::MacroCollection::TechFolder && QDir (tl::to_qstring (m->second->path ())).canonicalPath () == cp) { if (m->second->virtual_mode () != lym::MacroCollection::TechFolder && QDir (tl::to_qstring (m->second->path ())).canonicalPath () == cp) {
alt = m->second; alt = m->second;
} }
} }
@ -435,7 +435,7 @@ TechMacrosPage::setup ()
desc = tl::to_string (QObject::tr ("Technology")) + " - " + tech ()->name (); desc = tl::to_string (QObject::tr ("Technology")) + " - " + tech ()->name ();
} }
lay::MacroCollection *mc = new lay::MacroCollection (); lym::MacroCollection *mc = new lym::MacroCollection ();
mp_collection.reset (mc); mp_collection.reset (mc);
mc->add_folder (desc, mp, m_cat, true); mc->add_folder (desc, mp, m_cat, true);
m_current_path = mp; m_current_path = mp;
@ -469,10 +469,10 @@ END_PROTECTED
void void
TechMacrosPage::macro_selected (const QModelIndex &index) TechMacrosPage::macro_selected (const QModelIndex &index)
{ {
const lay::Macro *m = 0; const lym::Macro *m = 0;
lay::MacroTreeModel *model = dynamic_cast<lay::MacroTreeModel *> (folder_tree->model ()); lay::MacroTreeModel *model = dynamic_cast<lay::MacroTreeModel *> (folder_tree->model ());
if (model && model->is_valid_pointer (index.internalPointer ())) { if (model && model->is_valid_pointer (index.internalPointer ())) {
m = dynamic_cast <lay::Macro *> ((QObject *) index.internalPointer ()); m = dynamic_cast <lym::Macro *> ((QObject *) index.internalPointer ());
} }
if (! m) { if (! m) {

View File

@ -38,12 +38,17 @@
#include <memory> #include <memory>
namespace lym
{
class Macro;
class MacroCollection;
}
namespace lay namespace lay
{ {
class TechnologyComponentEditor; class TechnologyComponentEditor;
class Technology; class Technology;
class MacroCollection;
class TechBaseEditorPage class TechBaseEditorPage
: public TechnologyComponentEditor, : public TechnologyComponentEditor,
@ -78,7 +83,7 @@ public:
private: private:
std::string m_cat, m_cat_desc; std::string m_cat, m_cat_desc;
std::vector<std::pair<QLabel *, QString> > m_original_labels; std::vector<std::pair<QLabel *, QString> > m_original_labels;
std::auto_ptr<lay::MacroCollection> mp_collection; std::auto_ptr<lym::MacroCollection> mp_collection;
std::string m_current_path; std::string m_current_path;
private slots: private slots:

View File

@ -36,7 +36,6 @@ namespace lay
class TechSetupDialog; class TechSetupDialog;
class MainWindow; class MainWindow;
class MacroCollection;
/** /**
* @brief A "controller" for the technologies * @brief A "controller" for the technologies

View File

@ -24,9 +24,9 @@
#include "gsiDecl.h" #include "gsiDecl.h"
#include "gsiDeclBasic.h" #include "gsiDeclBasic.h"
#include "gsiInterpreter.h" #include "gsiInterpreter.h"
#include "layMacroInterpreter.h" #include "lymMacroInterpreter.h"
#include "layMacro.h" #include "lymMacro.h"
#include "layApplication.h" #include "rba.h"
#include "tlClassRegistry.h" #include "tlClassRegistry.h"
@ -37,7 +37,7 @@ namespace tl
// type traits for BrowserDialog_Stub // type traits for BrowserDialog_Stub
template <> template <>
struct type_traits<lay::Macro> : public type_traits<void> { struct type_traits<lym::Macro> : public type_traits<void> {
typedef tl::false_tag has_copy_constructor; typedef tl::false_tag has_copy_constructor;
}; };
@ -51,17 +51,23 @@ class MacroExecutionContext
public: public:
static void set_debugger_scope (const std::string &filename) static void set_debugger_scope (const std::string &filename)
{ {
lay::Application::instance ()->ruby_interpreter ().set_debugger_scope (filename); if (rba::RubyInterpreter::instance ()) {
rba::RubyInterpreter::instance ()->set_debugger_scope (filename);
}
} }
static void remove_debugger_scope () static void remove_debugger_scope ()
{ {
lay::Application::instance ()->ruby_interpreter ().remove_debugger_scope (); if (rba::RubyInterpreter::instance ()) {
rba::RubyInterpreter::instance ()->remove_debugger_scope ();
}
} }
static void ignore_next_exception () static void ignore_next_exception ()
{ {
lay::Application::instance ()->ruby_interpreter ().ignore_next_exception (); if (rba::RubyInterpreter::instance ()) {
rba::RubyInterpreter::instance ()->ignore_next_exception ();
}
} }
}; };
@ -90,25 +96,25 @@ Class<gsi::MacroExecutionContext> decl_MacroExecutionContext ("MacroExecutionCon
); );
class MacroInterpreter class MacroInterpreter
: public lay::MacroInterpreter : public lym::MacroInterpreter
{ {
public: public:
MacroInterpreter () MacroInterpreter ()
: lay::MacroInterpreter (), : lym::MacroInterpreter (),
mp_registration (0) mp_registration (0)
{ {
m_suffix = lay::MacroInterpreter::suffix (); m_suffix = lym::MacroInterpreter::suffix ();
m_description = lay::MacroInterpreter::description (); m_description = lym::MacroInterpreter::description ();
m_storage_scheme = lay::MacroInterpreter::storage_scheme (); m_storage_scheme = lym::MacroInterpreter::storage_scheme ();
m_syntax_scheme = lay::MacroInterpreter::syntax_scheme (); m_syntax_scheme = lym::MacroInterpreter::syntax_scheme ();
m_debugger_scheme = lay::MacroInterpreter::debugger_scheme (); m_debugger_scheme = lym::MacroInterpreter::debugger_scheme ();
} }
~MacroInterpreter () ~MacroInterpreter ()
{ {
delete mp_registration; delete mp_registration;
mp_registration = 0; mp_registration = 0;
for (std::vector<lay::Macro *>::const_iterator t = m_templates.begin (); t != m_templates.end (); ++t) { for (std::vector<lym::Macro *>::const_iterator t = m_templates.begin (); t != m_templates.end (); ++t) {
delete *t; delete *t;
} }
m_templates.clear (); m_templates.clear ();
@ -121,34 +127,34 @@ public:
// cancel any previous registration and register (again) // cancel any previous registration and register (again)
delete mp_registration; delete mp_registration;
mp_registration = new tl::RegisteredClass<lay::MacroInterpreter> (this, 0 /*position*/, name, false /*does not own object*/); mp_registration = new tl::RegisteredClass<lym::MacroInterpreter> (this, 0 /*position*/, name, false /*does not own object*/);
m_name = name; m_name = name;
} }
virtual void execute (const lay::Macro *macro) const virtual void execute (const lym::Macro *macro) const
{ {
if (f_execute.can_issue ()) { if (f_execute.can_issue ()) {
f_execute.issue<MacroInterpreter, const lay::Macro *> (&MacroInterpreter::execute, macro); f_execute.issue<MacroInterpreter, const lym::Macro *> (&MacroInterpreter::execute, macro);
} }
} }
void set_storage_scheme (int scheme) void set_storage_scheme (int scheme)
{ {
m_storage_scheme = lay::Macro::Format (scheme); m_storage_scheme = lym::Macro::Format (scheme);
} }
virtual lay::Macro::Format storage_scheme () const virtual lym::Macro::Format storage_scheme () const
{ {
return m_storage_scheme; return m_storage_scheme;
} }
void set_debugger_scheme (int scheme) void set_debugger_scheme (int scheme)
{ {
m_debugger_scheme = lay::Macro::Interpreter (scheme); m_debugger_scheme = lym::Macro::Interpreter (scheme);
} }
virtual lay::Macro::Interpreter debugger_scheme () const virtual lym::Macro::Interpreter debugger_scheme () const
{ {
return m_debugger_scheme; return m_debugger_scheme;
} }
@ -183,28 +189,28 @@ public:
return m_suffix; return m_suffix;
} }
lay::Macro *create_template (const std::string &name) lym::Macro *create_template (const std::string &name)
{ {
if (! mp_registration) { if (! mp_registration) {
throw std::runtime_error (tl::to_string (QObject::tr ("MacroInterpreter::create_template must be called after register"))); throw std::runtime_error (tl::to_string (QObject::tr ("MacroInterpreter::create_template must be called after register")));
} }
lay::Macro *m = new lay::Macro (); lym::Macro *m = new lym::Macro ();
m->rename (name); m->rename (name);
m->set_readonly (true); m->set_readonly (true);
m->set_dsl_interpreter (m_name); m->set_dsl_interpreter (m_name);
m->set_interpreter (lay::Macro::DSLInterpreter); m->set_interpreter (lym::Macro::DSLInterpreter);
m->set_format (storage_scheme ()); m->set_format (storage_scheme ());
m_templates.push_back (m); m_templates.push_back (m);
return m; return m;
} }
virtual void get_templates (std::vector<lay::Macro *> &tt) const virtual void get_templates (std::vector<lym::Macro *> &tt) const
{ {
for (std::vector<lay::Macro *>::const_iterator t = m_templates.begin (); t != m_templates.end (); ++t) { for (std::vector<lym::Macro *>::const_iterator t = m_templates.begin (); t != m_templates.end (); ++t) {
tt.push_back (new lay::Macro ()); tt.push_back (new lym::Macro ());
tt.back ()->rename ((*t)->name ()); tt.back ()->rename ((*t)->name ());
tt.back ()->assign (**t); tt.back ()->assign (**t);
} }
@ -213,39 +219,39 @@ public:
gsi::Callback f_execute; gsi::Callback f_execute;
private: private:
tl::RegisteredClass <lay::MacroInterpreter> *mp_registration; tl::RegisteredClass <lym::MacroInterpreter> *mp_registration;
std::string m_name; std::string m_name;
std::vector<lay::Macro *> m_templates; std::vector<lym::Macro *> m_templates;
std::string m_syntax_scheme; std::string m_syntax_scheme;
lay::Macro::Format m_storage_scheme; lym::Macro::Format m_storage_scheme;
lay::Macro::Interpreter m_debugger_scheme; lym::Macro::Interpreter m_debugger_scheme;
std::string m_suffix; std::string m_suffix;
std::string m_description; std::string m_description;
}; };
int const_PlainTextFormat () int const_PlainTextFormat ()
{ {
return int (lay::Macro::PlainTextFormat); return int (lym::Macro::PlainTextFormat);
} }
int const_PlainTextWithHashAnnotationsFormat () int const_PlainTextWithHashAnnotationsFormat ()
{ {
return int (lay::Macro::PlainTextWithHashAnnotationsFormat); return int (lym::Macro::PlainTextWithHashAnnotationsFormat);
} }
int const_MacroFormat () int const_MacroFormat ()
{ {
return int (lay::Macro::MacroFormat); return int (lym::Macro::MacroFormat);
} }
int const_RubyDebugger () int const_RubyDebugger ()
{ {
return int (lay::Macro::Ruby); return int (lym::Macro::Ruby);
} }
int const_NoDebugger () int const_NoDebugger ()
{ {
return int (lay::Macro::None); return int (lym::Macro::None);
} }
Class<gsi::MacroInterpreter> decl_MacroInterpreter ("MacroInterpreter", Class<gsi::MacroInterpreter> decl_MacroInterpreter ("MacroInterpreter",
@ -414,95 +420,95 @@ Class<gsi::MacroInterpreter> decl_MacroInterpreter ("MacroInterpreter",
"This class has been introduced in version 0.23.\n" "This class has been introduced in version 0.23.\n"
); );
Class<lay::Macro> decl_Macro ("Macro", Class<lym::Macro> decl_Macro ("Macro",
gsi::method ("path", &lay::Macro::path, gsi::method ("path", &lym::Macro::path,
"@brief Gets the path of the macro\n" "@brief Gets the path of the macro\n"
"\n" "\n"
"The path is the path where the macro is stored, starting with an abstract group identifier. " "The path is the path where the macro is stored, starting with an abstract group identifier. "
"The path is used to identify the macro in the debugger for example." "The path is used to identify the macro in the debugger for example."
) + ) +
gsi::method ("description", &lay::Macro::description, gsi::method ("description", &lym::Macro::description,
"@brief Gets the description text\n" "@brief Gets the description text\n"
"\n" "\n"
"The description text of a macro will appear in the macro list. If used as a macro template, " "The description text of a macro will appear in the macro list. If used as a macro template, "
"the description text can have the format \"Group;;Description\". In that case, the macro " "the description text can have the format \"Group;;Description\". In that case, the macro "
"will appear in a group with title \"Group\"." "will appear in a group with title \"Group\"."
) + ) +
gsi::method ("description=", &lay::Macro::set_description, gsi::method ("description=", &lym::Macro::set_description,
"@brief Sets the description text\n" "@brief Sets the description text\n"
"@args description\n" "@args description\n"
"@param description The description text.\n" "@param description The description text.\n"
"See \\description for details.\n" "See \\description for details.\n"
) + ) +
gsi::method ("prolog", &lay::Macro::prolog, gsi::method ("prolog", &lym::Macro::prolog,
"@brief Gets the prolog code\n" "@brief Gets the prolog code\n"
"\n" "\n"
"The prolog is executed before the actual code is executed. Interpretation depends on the " "The prolog is executed before the actual code is executed. Interpretation depends on the "
"implementation of the DSL interpreter for DSL macros." "implementation of the DSL interpreter for DSL macros."
) + ) +
gsi::method ("prolog=", &lay::Macro::set_prolog, gsi::method ("prolog=", &lym::Macro::set_prolog,
"@brief Sets the prolog\n" "@brief Sets the prolog\n"
"@args string\n" "@args string\n"
"See \\prolog for details.\n" "See \\prolog for details.\n"
) + ) +
gsi::method ("epilog", &lay::Macro::epilog, gsi::method ("epilog", &lym::Macro::epilog,
"@brief Gets the epilog code\n" "@brief Gets the epilog code\n"
"\n" "\n"
"The epilog is executed after the actual code is executed. Interpretation depends on the " "The epilog is executed after the actual code is executed. Interpretation depends on the "
"implementation of the DSL interpreter for DSL macros." "implementation of the DSL interpreter for DSL macros."
) + ) +
gsi::method ("epilog=", &lay::Macro::set_epilog, gsi::method ("epilog=", &lym::Macro::set_epilog,
"@brief Sets the epilog\n" "@brief Sets the epilog\n"
"@args string\n" "@args string\n"
"See \\epilog for details.\n" "See \\epilog for details.\n"
) + ) +
gsi::method ("category", &lay::Macro::category, gsi::method ("category", &lym::Macro::category,
"@brief Gets the category tags\n" "@brief Gets the category tags\n"
"\n" "\n"
"The category tags string indicates to which categories a macro will belong to. This string " "The category tags string indicates to which categories a macro will belong to. This string "
"is only used for templates currently and is a comma-separated list of category names." "is only used for templates currently and is a comma-separated list of category names."
) + ) +
gsi::method ("category=", &lay::Macro::set_category, gsi::method ("category=", &lym::Macro::set_category,
"@brief Sets the category tags string\n" "@brief Sets the category tags string\n"
"@args string\n" "@args string\n"
"See \\category for details.\n" "See \\category for details.\n"
) + ) +
gsi::method ("text", &lay::Macro::text, gsi::method ("text", &lym::Macro::text,
"@brief Gets the macro text\n" "@brief Gets the macro text\n"
"\n" "\n"
"The text is the code executed by the macro interpreter. " "The text is the code executed by the macro interpreter. "
"Depending on the DSL interpreter, the text can be any kind of code." "Depending on the DSL interpreter, the text can be any kind of code."
) + ) +
gsi::method ("text=", &lay::Macro::set_text, gsi::method ("text=", &lym::Macro::set_text,
"@brief Sets the macro text\n" "@brief Sets the macro text\n"
"@args string\n" "@args string\n"
"See \\text for details.\n" "See \\text for details.\n"
) + ) +
gsi::method ("show_in_menu?", &lay::Macro::show_in_menu, gsi::method ("show_in_menu?", &lym::Macro::show_in_menu,
"@brief Gets a value indicating whether the macro shall be shown in the menu\n" "@brief Gets a value indicating whether the macro shall be shown in the menu\n"
) + ) +
gsi::method ("show_in_menu=", &lay::Macro::set_show_in_menu, gsi::method ("show_in_menu=", &lym::Macro::set_show_in_menu,
"@brief Sets a value indicating whether the macro shall be shown in the menu\n" "@brief Sets a value indicating whether the macro shall be shown in the menu\n"
"@args flag\n" "@args flag\n"
) + ) +
gsi::method ("group_name", &lay::Macro::group_name, gsi::method ("group_name", &lym::Macro::group_name,
"@brief Gets the menu group name\n" "@brief Gets the menu group name\n"
"\n" "\n"
"If a group name is specified and \\show_in_menu? is true, the macro will appear in " "If a group name is specified and \\show_in_menu? is true, the macro will appear in "
"a separate group (separated by a separator) together with other macros sharing the same group." "a separate group (separated by a separator) together with other macros sharing the same group."
) + ) +
gsi::method ("group_name=", &lay::Macro::set_group_name, gsi::method ("group_name=", &lym::Macro::set_group_name,
"@brief Sets the menu group name\n" "@brief Sets the menu group name\n"
"@args string\n" "@args string\n"
"See \\group_name for details.\n" "See \\group_name for details.\n"
) + ) +
gsi::method ("menu_path", &lay::Macro::menu_path, gsi::method ("menu_path", &lym::Macro::menu_path,
"@brief Gets the menu path\n" "@brief Gets the menu path\n"
"\n" "\n"
"If a menu path is specified and \\show_in_menu? is true, the macro will appear in " "If a menu path is specified and \\show_in_menu? is true, the macro will appear in "
"the menu at the specified position." "the menu at the specified position."
) + ) +
gsi::method ("menu_path=", &lay::Macro::set_menu_path, gsi::method ("menu_path=", &lym::Macro::set_menu_path,
"@brief Sets the menu path\n" "@brief Sets the menu path\n"
"@args string\n" "@args string\n"
"See \\menu_path for details.\n" "See \\menu_path for details.\n"

23
src/lym/lym.pro Normal file
View File

@ -0,0 +1,23 @@
DESTDIR = $$OUT_PWD/..
TARGET = klayout_lym
include($$PWD/../klayout.pri)
include($$PWD/../lib.pri)
DEFINES += MAKE_LYM_LIBRARY
SOURCES = \
gsiDeclLymMacro.cc \
lymMacroInterpreter.cc \
lymMacro.cc \
HEADERS = \
lymCommon.h \
lymMacroInterpreter.h \
lymMacro.h \
INCLUDEPATH += ../tl ../gsi ../rba ../pya
DEPENDPATH += ../tl ../gsi ../rba ../pya
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_rba -lklayout_pya

48
src/lym/lymCommon.h Normal file
View File

@ -0,0 +1,48 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2017 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(HDR_lymCommon_h)
# define HDR_lymCommon_h
# if defined _WIN32 || defined __CYGWIN__
# ifdef MAKE_LYM_LIBRARY
# define LYM_PUBLIC __declspec(dllexport)
# else
# define LYM_PUBLIC __declspec(dllimport)
# endif
# define LYM_LOCAL
# else
# if __GNUC__ >= 4
# define LYM_PUBLIC __attribute__ ((visibility ("default")))
# define LYM_LOCAL __attribute__ ((visibility ("hidden")))
# else
# define LYM_PUBLIC
# define LYM_LOCAL
# endif
# endif
#endif

View File

@ -21,20 +21,21 @@
*/ */
#include "layMacro.h" #include "lymMacro.h"
#include "layMacroInterpreter.h" #include "lymMacroInterpreter.h"
#include "layMainWindow.h"
#include "layAbstractMenu.h"
#include "layApplication.h"
#include "tlExceptions.h" #include "tlExceptions.h"
#include "gsiDecl.h" #include "gsiDecl.h"
#include "gsiInterpreter.h" #include "gsiInterpreter.h"
#include "tlString.h" #include "tlString.h"
#include "tlStableVector.h"
#include "tlClassRegistry.h" #include "tlClassRegistry.h"
#include "tlLog.h" #include "tlLog.h"
#include "tlXMLParser.h" #include "tlXMLParser.h"
#include "rba.h"
#include "pya.h"
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
#include <QUrl> #include <QUrl>
@ -43,7 +44,7 @@
#include <fstream> #include <fstream>
#include <memory> #include <memory>
namespace lay namespace lym
{ {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -68,7 +69,7 @@ void Macro::on_changed ()
} }
} }
void Macro::assign (const lay::Macro &other) void Macro::assign (const lym::Macro &other)
{ {
m_description = other.m_description; m_description = other.m_description;
m_version = other.m_version; m_version = other.m_version;
@ -169,7 +170,7 @@ struct Interpreter2s
/** /**
* @brief Declaration of the XML structure of a macro * @brief Declaration of the XML structure of a macro
*/ */
static tl::XMLStruct<lay::Macro> xml_struct ("klayout-macro", static tl::XMLStruct<lym::Macro> xml_struct ("klayout-macro",
tl::make_member (&Macro::description, &Macro::set_description, "description") + tl::make_member (&Macro::description, &Macro::set_description, "description") +
tl::make_member (&Macro::version, &Macro::set_version, "version") + tl::make_member (&Macro::version, &Macro::set_version, "version") +
tl::make_member (&Macro::category, &Macro::set_category, "category") + tl::make_member (&Macro::category, &Macro::set_category, "category") +
@ -330,7 +331,7 @@ Macro::format_from_suffix (const std::string &fn, Macro::Interpreter &interprete
} else if (!suffix.empty ()) { } else if (!suffix.empty ()) {
// locate the suffix in the DSL interpreter declarations // locate the suffix in the DSL interpreter declarations
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls->suffix () == suffix) { if (cls->suffix () == suffix) {
@ -523,23 +524,23 @@ const std::string &Macro::text () const
struct PropertyField struct PropertyField
{ {
const char *name; const char *name;
const std::string &(lay::Macro::*string_getter) () const; const std::string &(lym::Macro::*string_getter) () const;
void (lay::Macro::*string_setter) (const std::string &); void (lym::Macro::*string_setter) (const std::string &);
bool (lay::Macro::*bool_getter) () const; bool (lym::Macro::*bool_getter) () const;
void (lay::Macro::*bool_setter) (bool); void (lym::Macro::*bool_setter) (bool);
}; };
static PropertyField property_fields[] = { static PropertyField property_fields[] = {
{ "description", &lay::Macro::description, &lay::Macro::set_description, 0, 0 }, { "description", &lym::Macro::description, &lym::Macro::set_description, 0, 0 },
{ "prolog", &lay::Macro::prolog, &lay::Macro::set_prolog, 0, 0 }, { "prolog", &lym::Macro::prolog, &lym::Macro::set_prolog, 0, 0 },
{ "epilog", &lay::Macro::epilog, &lay::Macro::set_epilog, 0, 0 }, { "epilog", &lym::Macro::epilog, &lym::Macro::set_epilog, 0, 0 },
{ "version", &lay::Macro::version, &lay::Macro::set_version, 0, 0 }, { "version", &lym::Macro::version, &lym::Macro::set_version, 0, 0 },
{ "autorun", 0, 0, &lay::Macro::is_autorun, &lay::Macro::set_autorun }, { "autorun", 0, 0, &lym::Macro::is_autorun, &lym::Macro::set_autorun },
{ "autorun-early", 0, 0, &lay::Macro::is_autorun_early, &lay::Macro::set_autorun_early}, { "autorun-early", 0, 0, &lym::Macro::is_autorun_early, &lym::Macro::set_autorun_early},
{ "show-in-menu", 0, 0, &lay::Macro::show_in_menu, &lay::Macro::set_show_in_menu }, { "show-in-menu", 0, 0, &lym::Macro::show_in_menu, &lym::Macro::set_show_in_menu },
{ "group-name", &lay::Macro::group_name, &lay::Macro::set_group_name, 0, 0 }, { "group-name", &lym::Macro::group_name, &lym::Macro::set_group_name, 0, 0 },
{ "menu-path", &lay::Macro::menu_path, &lay::Macro::set_menu_path, 0, 0 }, { "menu-path", &lym::Macro::menu_path, &lym::Macro::set_menu_path, 0, 0 },
{ "shortcut", &lay::Macro::shortcut, &lay::Macro::set_shortcut, 0, 0 } { "shortcut", &lym::Macro::shortcut, &lym::Macro::set_shortcut, 0, 0 }
}; };
static std::string escape_pta_string (const char *cp) static std::string escape_pta_string (const char *cp)
@ -942,14 +943,27 @@ void Macro::install_doc () const
} }
} }
static gsi::Interpreter *script_interpreter (lym::Macro::Interpreter lang)
{
gsi::Interpreter *ip = 0;
// This
if (lang == lym::Macro::Ruby) {
ip = rba::RubyInterpreter::instance ();
} else if (lang == lym::Macro::Python) {
ip = pya::PythonInterpreter::instance ();
}
return (ip && ip->available() ? ip : 0);
}
bool Macro::can_run () const bool Macro::can_run () const
{ {
if (interpreter () == lay::Macro::Ruby) { gsi::Interpreter *ip = script_interpreter (interpreter ());
return (lay::Application::instance ()->ruby_interpreter ().available ()); if (ip) {
} else if (interpreter () == lay::Macro::Python) { return true;
return (lay::Application::instance ()->python_interpreter ().available ()); } else if (interpreter () == lym::Macro::DSLInterpreter) {
} else if (interpreter () == lay::Macro::DSLInterpreter) { return lym::MacroInterpreter::can_run (this);
return lay::MacroInterpreter::can_run (this);
} else { } else {
return false; return false;
} }
@ -962,24 +976,17 @@ int Macro::run () const
} }
try { try {
if (interpreter () == lay::Macro::Ruby) { gsi::Interpreter *ip = script_interpreter (interpreter ());
if (ip) {
if (! prolog ().empty ()) { if (! prolog ().empty ()) {
lay::Application::instance ()->ruby_interpreter ().eval_string (prolog ().c_str ()); ip->eval_string (prolog ().c_str ());
} }
lay::Application::instance ()->ruby_interpreter ().eval_string (text ().c_str (), path ().c_str (), 1); ip->eval_string (text ().c_str (), path ().c_str (), 1);
if (! epilog ().empty ()) { if (! epilog ().empty ()) {
lay::Application::instance ()->ruby_interpreter ().eval_string (epilog ().c_str ()); ip->eval_string (epilog ().c_str ());
} }
} else if (interpreter () == lay::Macro::Python) { } else if (interpreter () == lym::Macro::DSLInterpreter) {
if (! prolog ().empty ()) { lym::MacroInterpreter::execute_macro (this);
lay::Application::instance ()->python_interpreter ().eval_string (prolog ().c_str ());
}
lay::Application::instance ()->python_interpreter ().eval_string (text ().c_str (), path ().c_str (), 1);
if (! epilog ().empty ()) {
lay::Application::instance ()->python_interpreter ().eval_string (epilog ().c_str ());
}
} else if (interpreter () == lay::Macro::DSLInterpreter) {
lay::MacroInterpreter::execute_macro (this);
} }
} catch (tl::ExitException &ex) { } catch (tl::ExitException &ex) {
return ex.status (); return ex.status ();
@ -1356,7 +1363,7 @@ void MacroCollection::scan (const std::string &path)
filters << QString::fromUtf8 ("*.py"); filters << QString::fromUtf8 ("*.py");
// add the suffixes in the DSL interpreter declarations // add the suffixes in the DSL interpreter declarations
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (! cls->suffix ().empty ()) { if (! cls->suffix ().empty ()) {
filters << tl::to_qstring ("*." + cls->suffix ()); filters << tl::to_qstring ("*." + cls->suffix ());
} }
@ -1365,7 +1372,7 @@ void MacroCollection::scan (const std::string &path)
QStringList files = dir.entryList (filters, QDir::Files); QStringList files = dir.entryList (filters, QDir::Files);
for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) {
std::auto_ptr<lay::Macro> new_macro; std::auto_ptr<lym::Macro> new_macro;
try { try {
@ -1440,7 +1447,7 @@ void MacroCollection::scan (const std::string &path)
} }
} }
void MacroCollection::erase (lay::Macro *mp) void MacroCollection::erase (lym::Macro *mp)
{ {
for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) {
if (m->second == mp) { if (m->second == mp) {
@ -1454,7 +1461,7 @@ void MacroCollection::erase (lay::Macro *mp)
} }
} }
void MacroCollection::erase (lay::MacroCollection *mp) void MacroCollection::erase (lym::MacroCollection *mp)
{ {
for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) {
if (f->second == mp) { if (f->second == mp) {
@ -1520,7 +1527,7 @@ bool MacroCollection::rename (const std::string &n)
} }
} }
lay::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir) lym::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir)
{ {
std::string name; std::string name;
int n = 0; int n = 0;
@ -1541,7 +1548,7 @@ lay::MacroCollection *MacroCollection::create_folder (const char *prefix, bool m
begin_changes (); begin_changes ();
lay::MacroCollection *m = m_folders.insert (std::make_pair (name, new lay::MacroCollection ())).first->second; lym::MacroCollection *m = m_folders.insert (std::make_pair (name, new lym::MacroCollection ())).first->second;
m->set_virtual_mode (NotVirtual); m->set_virtual_mode (NotVirtual);
m->set_name (name); m->set_name (name);
m->set_parent (this); m->set_parent (this);
@ -1551,7 +1558,7 @@ lay::MacroCollection *MacroCollection::create_folder (const char *prefix, bool m
return m; return m;
} }
lay::Macro *MacroCollection::create (const char *prefix, Macro::Format format) lym::Macro *MacroCollection::create (const char *prefix, Macro::Format format)
{ {
std::string name; std::string name;
int n = 0; int n = 0;
@ -1568,7 +1575,7 @@ lay::Macro *MacroCollection::create (const char *prefix, Macro::Format format)
begin_changes (); begin_changes ();
lay::Macro *m = m_macros.insert (std::make_pair (name, new lay::Macro ()))->second; lym::Macro *m = m_macros.insert (std::make_pair (name, new lym::Macro ()))->second;
m->set_name (name); m->set_name (name);
m->set_parent (this); m->set_parent (this);
@ -1577,7 +1584,7 @@ lay::Macro *MacroCollection::create (const char *prefix, Macro::Format format)
return m; return m;
} }
void MacroCollection::add_unspecific (lay::Macro *m) void MacroCollection::add_unspecific (lym::Macro *m)
{ {
begin_changes (); begin_changes ();
m_macros.insert (std::make_pair (m->name (), m)); m_macros.insert (std::make_pair (m->name (), m));
@ -1585,7 +1592,7 @@ void MacroCollection::add_unspecific (lay::Macro *m)
on_changed (); on_changed ();
} }
bool MacroCollection::add (lay::Macro *m) bool MacroCollection::add (lym::Macro *m)
{ {
QDir d (tl::to_qstring (path ())); QDir d (tl::to_qstring (path ()));
QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir (); QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir ();
@ -1618,7 +1625,7 @@ bool MacroCollection::add (lay::Macro *m)
if (dm == d) { if (dm == d) {
begin_changes (); begin_changes ();
lay::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second; lym::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second;
mc->set_virtual_mode (NotVirtual); mc->set_virtual_mode (NotVirtual);
mc->set_parent (this); mc->set_parent (this);
on_changed (); on_changed ();
@ -1653,7 +1660,7 @@ void MacroCollection::rename_macro (Macro *macro, const std::string &new_name)
} }
} }
lay::Macro *MacroCollection::find_macro (const std::string &path) lym::Macro *MacroCollection::find_macro (const std::string &path)
{ {
for (iterator m = begin (); m != end (); ++m) { for (iterator m = begin (); m != end (); ++m) {
if (m->second->path () == path) { if (m->second->path () == path) {
@ -1662,7 +1669,7 @@ lay::Macro *MacroCollection::find_macro (const std::string &path)
} }
for (child_iterator mc = begin_children (); mc != end_children (); ++mc) { for (child_iterator mc = begin_children (); mc != end_children (); ++mc) {
lay::Macro *macro = mc->second->find_macro (path); lym::Macro *macro = mc->second->find_macro (path);
if (macro) { if (macro) {
return macro; return macro;
} }
@ -1676,7 +1683,7 @@ MacroCollection &MacroCollection::root ()
return ms_root; return ms_root;
} }
static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *actual) static bool sync_macros (lym::MacroCollection *current, lym::MacroCollection *actual)
{ {
bool ret = false; bool ret = false;
@ -1684,18 +1691,18 @@ static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *ac
current->make_readonly (actual->is_readonly ()); current->make_readonly (actual->is_readonly ());
} }
std::vector<lay::MacroCollection *> folders_to_delete; std::vector<lym::MacroCollection *> folders_to_delete;
for (lay::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) { for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) {
lay::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0; lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0;
if (! cm) { if (! cm) {
folders_to_delete.push_back (m->second); folders_to_delete.push_back (m->second);
} }
} }
if (actual) { if (actual) {
for (lay::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) { for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) {
lay::MacroCollection *cm = current->folder_by_name (m->first); lym::MacroCollection *cm = current->folder_by_name (m->first);
if (! cm) { if (! cm) {
cm = current->create_folder (m->first.c_str (), false); cm = current->create_folder (m->first.c_str (), false);
ret = true; ret = true;
@ -1707,24 +1714,24 @@ static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *ac
} }
// delete folders which do no longer exist // delete folders which do no longer exist
for (std::vector<lay::MacroCollection *>::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { for (std::vector<lym::MacroCollection *>::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) {
ret = true; ret = true;
sync_macros (*m, 0); sync_macros (*m, 0);
current->erase (*m); current->erase (*m);
} }
std::vector<lay::Macro *> macros_to_delete; std::vector<lym::Macro *> macros_to_delete;
for (lay::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) { for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) {
lay::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0; lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0;
if (! cm) { if (! cm) {
macros_to_delete.push_back (m->second); macros_to_delete.push_back (m->second);
} }
} }
if (actual) { if (actual) {
for (lay::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) { for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) {
lay::Macro *cm = current->macro_by_name (m->first, m->second->format ()); lym::Macro *cm = current->macro_by_name (m->first, m->second->format ());
if (cm) { if (cm) {
if (*cm != *m->second) { if (*cm != *m->second) {
cm->assign (*m->second); cm->assign (*m->second);
@ -1740,7 +1747,7 @@ static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *ac
} }
// erase macros from collection which are no longer used // erase macros from collection which are no longer used
for (std::vector<lay::Macro *>::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) { for (std::vector<lym::Macro *>::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) {
current->erase (*m); current->erase (*m);
ret = true; ret = true;
} }
@ -1752,8 +1759,8 @@ void MacroCollection::reload ()
{ {
// create a new collection and synchronize // create a new collection and synchronize
lay::MacroCollection new_collection; lym::MacroCollection new_collection;
for (lay::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { for (lym::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) {
new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */); new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */);
} }
@ -1761,15 +1768,15 @@ void MacroCollection::reload ()
sync_macros (this, &new_collection); sync_macros (this, &new_collection);
} }
static bool has_autorun_for (const lay::MacroCollection &collection, bool early) static bool has_autorun_for (const lym::MacroCollection &collection, bool early)
{ {
for (lay::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) {
if (has_autorun_for (*c->second, early)) { if (has_autorun_for (*c->second, early)) {
return true; return true;
} }
} }
for (lay::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) { for (lym::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) {
if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) { if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) {
return true; return true;
} }
@ -1783,13 +1790,13 @@ bool MacroCollection::has_autorun () const
return has_autorun_for (*this, false); return has_autorun_for (*this, false);
} }
static void autorun_for (lay::MacroCollection &collection, bool early) static void autorun_for (lym::MacroCollection &collection, bool early)
{ {
for (lay::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) {
autorun_for (*c->second, early); autorun_for (*c->second, early);
} }
for (lay::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) {
if (((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) && c->second->can_run ()) { if (((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) && c->second->can_run ()) {
BEGIN_PROTECTED_SILENT BEGIN_PROTECTED_SILENT
c->second->install_doc (); c->second->install_doc ();

View File

@ -21,10 +21,10 @@
*/ */
#ifndef HDR_layMacro #ifndef HDR_lymMacro
#define HDR_layMacro #define HDR_lymMacro
#include "layCommon.h" #include "lymCommon.h"
#include <string> #include <string>
#include <map> #include <map>
@ -32,7 +32,7 @@
#include <QObject> #include <QObject>
namespace lay namespace lym
{ {
class MacroCollection; class MacroCollection;
@ -54,7 +54,7 @@ class MacroCollection;
* a macro can be bound to an arbitrary interpreter and decides * a macro can be bound to an arbitrary interpreter and decides
* by itself which interpreter to use. * by itself which interpreter to use.
*/ */
class LAY_PUBLIC Macro class LYM_PUBLIC Macro
: public QObject : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -132,14 +132,14 @@ public:
* This will assign the definition of the macro but keep the name. * This will assign the definition of the macro but keep the name.
* It will also not modify the parent nor the readonly flag. * It will also not modify the parent nor the readonly flag.
*/ */
void assign (const lay::Macro &other); void assign (const lym::Macro &other);
/** /**
* @brief Returns the parent of the macro collection * @brief Returns the parent of the macro collection
* *
* Returns 0, if there is no parent of this collection (this is the root) * Returns 0, if there is no parent of this collection (this is the root)
*/ */
lay::MacroCollection *parent () lym::MacroCollection *parent ()
{ {
return mp_parent; return mp_parent;
} }
@ -149,7 +149,7 @@ public:
* *
* Returns 0, if there is no parent of this collection (this is the root) * Returns 0, if there is no parent of this collection (this is the root)
*/ */
const lay::MacroCollection *parent () const const lym::MacroCollection *parent () const
{ {
return mp_parent; return mp_parent;
} }
@ -594,7 +594,7 @@ private:
std::string m_menu_path; std::string m_menu_path;
std::string m_shortcut; std::string m_shortcut;
bool m_is_file; bool m_is_file;
lay::MacroCollection *mp_parent; lym::MacroCollection *mp_parent;
Interpreter m_interpreter; Interpreter m_interpreter;
std::string m_dsl_interpreter; std::string m_dsl_interpreter;
Format m_format; Format m_format;
@ -613,7 +613,7 @@ private:
m_name = name; m_name = name;
} }
void set_parent (lay::MacroCollection *parent) void set_parent (lym::MacroCollection *parent)
{ {
mp_parent = parent; mp_parent = parent;
} }
@ -629,7 +629,7 @@ private:
* A collection is representing a set of macros, usually associated with * A collection is representing a set of macros, usually associated with
* a folder containing *.lym, *.rb or other script files. * a folder containing *.lym, *.rb or other script files.
*/ */
class LAY_PUBLIC MacroCollection class LYM_PUBLIC MacroCollection
: public QObject : public QObject
{ {
Q_OBJECT Q_OBJECT
@ -732,7 +732,7 @@ public:
* *
* Returns 0, if there is no parent of this collection (this is the root) * Returns 0, if there is no parent of this collection (this is the root)
*/ */
lay::MacroCollection *parent () lym::MacroCollection *parent ()
{ {
return mp_parent; return mp_parent;
} }
@ -742,7 +742,7 @@ public:
* *
* Returns 0, if there is no parent of this collection (this is the root) * Returns 0, if there is no parent of this collection (this is the root)
*/ */
const lay::MacroCollection *parent () const const lym::MacroCollection *parent () const
{ {
return mp_parent; return mp_parent;
} }
@ -825,7 +825,7 @@ public:
* *
* @return true, if the macro could be added sucessfully. * @return true, if the macro could be added sucessfully.
*/ */
bool add (lay::Macro *m); bool add (lym::Macro *m);
/** /**
* @brief Adds a macro in an unspecific way * @brief Adds a macro in an unspecific way
@ -835,7 +835,7 @@ public:
* This is a way to build macro collections without connection * This is a way to build macro collections without connection
* to some file system point. * to some file system point.
*/ */
void add_unspecific (lay::Macro *m); void add_unspecific (lym::Macro *m);
/** /**
* @brief Erases the given macro from the list * @brief Erases the given macro from the list
@ -843,7 +843,7 @@ public:
* This does not remove the file but just remove the macro object. * This does not remove the file but just remove the macro object.
* This will also delete the macro object. * This will also delete the macro object.
*/ */
void erase (lay::Macro *m); void erase (lym::Macro *m);
/** /**
* @brief Erases the entry with the given iterator * @brief Erases the entry with the given iterator
@ -856,7 +856,7 @@ public:
* This does not remove the directory but just removes the macro collection object. * This does not remove the directory but just removes the macro collection object.
* This will also delete the macro collection object. * This will also delete the macro collection object.
*/ */
void erase (lay::MacroCollection *m); void erase (lym::MacroCollection *m);
/** /**
* @brief Erases the folder with the given iterator * @brief Erases the folder with the given iterator
@ -868,7 +868,7 @@ public:
* *
* If a name is given, it is used as a prefix to create a unique name for a macro with that format. * If a name is given, it is used as a prefix to create a unique name for a macro with that format.
*/ */
lay::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat); lym::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat);
/** /**
* @brief Creates a new macro collection in that collection (with a new name) * @brief Creates a new macro collection in that collection (with a new name)
@ -877,7 +877,7 @@ public:
* This method will also create the directory for this folder. * This method will also create the directory for this folder.
* If not sucessful, it will return 0. * If not sucessful, it will return 0.
*/ */
lay::MacroCollection *create_folder (const char *name = 0, bool mkdir = true); lym::MacroCollection *create_folder (const char *name = 0, bool mkdir = true);
/** /**
* @brief Gets the begin iterator of the macros * @brief Gets the begin iterator of the macros
@ -977,7 +977,7 @@ public:
* This method is called from the root collection and delivers the macro which * This method is called from the root collection and delivers the macro which
* matches the given path or 0. * matches the given path or 0.
*/ */
lay::Macro *find_macro (const std::string &path); lym::Macro *find_macro (const std::string &path);
/** /**
* @brief Returns true, if the collection has an autorun macro * @brief Returns true, if the collection has an autorun macro
@ -1027,22 +1027,22 @@ signals:
/** /**
* @brief This signal is sent by collection when a child collection is deleted in this collection * @brief This signal is sent by collection when a child collection is deleted in this collection
*/ */
void child_deleted (MacroCollection *); void child_deleted (lym::MacroCollection *);
/** /**
* @brief This signal is sent by the root object when a macro collection is deleted * @brief This signal is sent by the root object when a macro collection is deleted
*/ */
void macro_collection_deleted (MacroCollection *); void macro_collection_deleted (lym::MacroCollection *);
/** /**
* @brief This signal is sent by collection when a macro is deleted in this collection * @brief This signal is sent by collection when a macro is deleted in this collection
*/ */
void macro_deleted_here (Macro *); void macro_deleted_here (lym::Macro *);
/** /**
* @brief This signal is sent by the root object when a macro is deleted * @brief This signal is sent by the root object when a macro is deleted
*/ */
void macro_deleted (Macro *); void macro_deleted (lym::Macro *);
/** /**
* @brief This signal is sent by the root object when a macro changes * @brief This signal is sent by the root object when a macro changes
@ -1050,7 +1050,7 @@ signals:
* This signal is only emitted by the root, but it may originate from a * This signal is only emitted by the root, but it may originate from a
* macro inside the tree. * macro inside the tree.
*/ */
void macro_changed (Macro *); void macro_changed (lym::Macro *);
/** /**
* @brief This signal is sent by the root object when a macro collection changes * @brief This signal is sent by the root object when a macro collection changes
@ -1058,7 +1058,7 @@ signals:
* This signal is only emitted by the root, but it may originate from a * This signal is only emitted by the root, but it may originate from a
* macro collection inside the tree. * macro collection inside the tree.
*/ */
void macro_collection_changed (MacroCollection *); void macro_collection_changed (lym::MacroCollection *);
/** /**
* @brief This signal is sent by the root object befor the macro collection changes * @brief This signal is sent by the root object befor the macro collection changes
@ -1078,7 +1078,7 @@ private:
std::string m_category; std::string m_category;
std::multimap <std::string, Macro *> m_macros; std::multimap <std::string, Macro *> m_macros;
std::map <std::string, MacroCollection *> m_folders; std::map <std::string, MacroCollection *> m_folders;
lay::MacroCollection *mp_parent; lym::MacroCollection *mp_parent;
int m_virtual_mode; int m_virtual_mode;
bool m_readonly; bool m_readonly;
@ -1105,7 +1105,7 @@ private:
m_path = n; m_path = n;
} }
void set_parent (lay::MacroCollection *parent) void set_parent (lym::MacroCollection *parent)
{ {
mp_parent = parent; mp_parent = parent;
} }
@ -1125,7 +1125,7 @@ private:
* *
* This class allows to call a macro from a signal * This class allows to call a macro from a signal
*/ */
class MacroSignalAdaptor class LYM_PUBLIC MacroSignalAdaptor
: public QObject : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -21,26 +21,26 @@
*/ */
#include "layMacroInterpreter.h" #include "lymMacroInterpreter.h"
#include "layMacro.h" #include "lymMacro.h"
#include "tlInternational.h" #include "tlInternational.h"
#include "tlException.h" #include "tlException.h"
#include "tlClassRegistry.h" #include "tlClassRegistry.h"
namespace lay namespace lym
{ {
void void
MacroInterpreter::execute (const lay::Macro *) const MacroInterpreter::execute (const lym::Macro *) const
{ {
throw tl::Exception (tl::to_string (QObject::tr ("execute() implementation missing for DSL interpreter"))); throw tl::Exception (tl::to_string (QObject::tr ("execute() implementation missing for DSL interpreter")));
} }
bool bool
MacroInterpreter::can_run (const lay::Macro *macro) MacroInterpreter::can_run (const lym::Macro *macro)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == macro->dsl_interpreter ()) { if (cls.current_name () == macro->dsl_interpreter ()) {
return true; return true;
} }
@ -49,9 +49,9 @@ MacroInterpreter::can_run (const lay::Macro *macro)
} }
void void
MacroInterpreter::execute_macro (const lay::Macro *macro) MacroInterpreter::execute_macro (const lym::Macro *macro)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == macro->dsl_interpreter ()) { if (cls.current_name () == macro->dsl_interpreter ()) {
cls->execute (macro); cls->execute (macro);
return; return;
@ -64,7 +64,7 @@ MacroInterpreter::execute_macro (const lay::Macro *macro)
std::string std::string
MacroInterpreter::syntax_scheme (const std::string &dsl_name) MacroInterpreter::syntax_scheme (const std::string &dsl_name)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == dsl_name) { if (cls.current_name () == dsl_name) {
return cls->syntax_scheme (); return cls->syntax_scheme ();
} }
@ -76,7 +76,7 @@ MacroInterpreter::syntax_scheme (const std::string &dsl_name)
Macro::Format Macro::Format
MacroInterpreter::storage_scheme (const std::string &dsl_name) MacroInterpreter::storage_scheme (const std::string &dsl_name)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == dsl_name) { if (cls.current_name () == dsl_name) {
return cls->storage_scheme (); return cls->storage_scheme ();
} }
@ -88,7 +88,7 @@ MacroInterpreter::storage_scheme (const std::string &dsl_name)
Macro::Interpreter Macro::Interpreter
MacroInterpreter::debugger_scheme (const std::string &dsl_name) MacroInterpreter::debugger_scheme (const std::string &dsl_name)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == dsl_name) { if (cls.current_name () == dsl_name) {
return cls->debugger_scheme (); return cls->debugger_scheme ();
} }
@ -100,7 +100,7 @@ MacroInterpreter::debugger_scheme (const std::string &dsl_name)
std::string std::string
MacroInterpreter::description (const std::string &dsl_name) MacroInterpreter::description (const std::string &dsl_name)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == dsl_name) { if (cls.current_name () == dsl_name) {
return cls->description (); return cls->description ();
} }
@ -112,7 +112,7 @@ MacroInterpreter::description (const std::string &dsl_name)
std::string std::string
MacroInterpreter::suffix (const std::string &dsl_name) MacroInterpreter::suffix (const std::string &dsl_name)
{ {
for (tl::Registrar<lay::MacroInterpreter>::iterator cls = tl::Registrar<lay::MacroInterpreter>::begin (); cls != tl::Registrar<lay::MacroInterpreter>::end (); ++cls) { for (tl::Registrar<lym::MacroInterpreter>::iterator cls = tl::Registrar<lym::MacroInterpreter>::begin (); cls != tl::Registrar<lym::MacroInterpreter>::end (); ++cls) {
if (cls.current_name () == dsl_name) { if (cls.current_name () == dsl_name) {
return cls->suffix (); return cls->suffix ();
} }
@ -125,6 +125,6 @@ MacroInterpreter::suffix (const std::string &dsl_name)
namespace tl namespace tl
{ {
template<> tl::Registrar<lay::MacroInterpreter> *Registrar<lay::MacroInterpreter>::instance = 0; template<> LYM_PUBLIC tl::Registrar<lym::MacroInterpreter> *Registrar<lym::MacroInterpreter>::instance = 0;
template class LAY_PUBLIC tl::RegisteredClass<lay::MacroInterpreter>; template class LYM_PUBLIC tl::RegisteredClass<lym::MacroInterpreter>;
} }

View File

@ -21,20 +21,20 @@
*/ */
#ifndef HDR_layMacroInterpreter #ifndef HDR_lymMacroInterpreter
#define HDR_layMacroInterpreter #define HDR_lymMacroInterpreter
#include "layCommon.h" #include "lymCommon.h"
#include "gsiObject.h" #include "gsiObject.h"
#include "tlClassRegistry.h" #include "tlClassRegistry.h"
#include "layMacro.h" #include "lymMacro.h"
#include <string> #include <string>
#include <vector> #include <vector>
namespace lay namespace lym
{ {
/** /**
@ -50,7 +50,7 @@ namespace lay
* tl::RegisteredClass. * tl::RegisteredClass.
*/ */
class LAY_PUBLIC MacroInterpreter class LYM_PUBLIC MacroInterpreter
: public gsi::ObjectBase : public gsi::ObjectBase
{ {
public: public:
@ -67,7 +67,7 @@ public:
* *
* This method must be reimplemented to provide the actual execution of the macro. * This method must be reimplemented to provide the actual execution of the macro.
*/ */
virtual void execute (const lay::Macro *macro) const; virtual void execute (const lym::Macro *macro) const;
/** /**
* @brief Returns the storage scheme * @brief Returns the storage scheme
@ -75,7 +75,7 @@ public:
* The storage scheme is used to determine how the macro's text shall be stored. * The storage scheme is used to determine how the macro's text shall be stored.
* The scheme can be MacroFormat for the macro XML format or PlainTextFormat for plain text. * The scheme can be MacroFormat for the macro XML format or PlainTextFormat for plain text.
*/ */
virtual lay::Macro::Format storage_scheme () const virtual lym::Macro::Format storage_scheme () const
{ {
return Macro::PlainTextFormat; return Macro::PlainTextFormat;
} }
@ -133,7 +133,7 @@ public:
* new macros. The template objects must be new'd and added to the templates vector by the * new macros. The template objects must be new'd and added to the templates vector by the
* implementation of this method. These objects then will be deleted by the caller. * implementation of this method. These objects then will be deleted by the caller.
*/ */
virtual void get_templates (std::vector<lay::Macro *> & /*templates*/) const virtual void get_templates (std::vector<lym::Macro *> & /*templates*/) const
{ {
// .. nothing yet .. // .. nothing yet ..
} }
@ -144,12 +144,12 @@ public:
* This method locates the DSL interpreter with the given name and * This method locates the DSL interpreter with the given name and
* runs the script on it. * runs the script on it.
*/ */
static void execute_macro (const lay::Macro *macro); static void execute_macro (const lym::Macro *macro);
/** /**
* @brief Returns true, if a DSL interpreter is registered for the given macro * @brief Returns true, if a DSL interpreter is registered for the given macro
*/ */
static bool can_run (const lay::Macro *macro); static bool can_run (const lym::Macro *macro);
/** /**
* @brief Gets the syntax scheme for the given DSL name * @brief Gets the syntax scheme for the given DSL name

View File

@ -2,7 +2,7 @@
DESTDIR=$$OUT_PWD/.. DESTDIR=$$OUT_PWD/..
include($$PWD/../klayout.pri) include($$PWD/../klayout.pri)
include($$PWD/../unit_tests.pri) include($$PWD/../with_all_libs.pri)
TEMPLATE = app TEMPLATE = app

View File

@ -1,8 +1,8 @@
INCLUDEPATH += $$PYTHONINCLUDE $$PWD/tl $$PWD/gsi $$PWD/db $$PWD/rdb $$PWD/laybasic $$PWD/lay $$PWD/ant $$PWD/img $$PWD/edt $$PWD/ext $$PWD/lib $$PWD/common $$PWD/ut INCLUDEPATH += $$PYTHONINCLUDE $$PWD/tl $$PWD/gsi $$PWD/db $$PWD/rdb $$PWD/lym $$PWD/laybasic $$PWD/lay $$PWD/ant $$PWD/img $$PWD/edt $$PWD/ext $$PWD/lib $$PWD/common $$PWD/ut $$PWD/version
DEPENDPATH += $$PYTHONINCLUDE $$PWD/tl $$PWD/gsi $$PWD/db $$PWD/rdb $$PWD/laybasic $$PWD/lay $$PWD/ant $$PWD/img $$PWD/edt $$PWD/ext $$PWD/lib $$PWD/commo $$PWD/ut DEPENDPATH += $$PYTHONINCLUDE $$PWD/tl $$PWD/gsi $$PWD/db $$PWD/rdb $$PWD/lym $$PWD/laybasic $$PWD/lay $$PWD/ant $$PWD/img $$PWD/edt $$PWD/ext $$PWD/lib $$PWD/commo $$PWD/ut $$PWD/version
LIBS += $$PYTHONLIBFILE $$RUBYLIBFILE -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_laybasic -lklayout_lay -lklayout_ant -lklayout_img -lklayout_edt -lklayout_ext -lklayout_lib -lklayout_ut LIBS += $$PYTHONLIBFILE $$RUBYLIBFILE -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_lay -lklayout_ant -lklayout_img -lklayout_edt -lklayout_ext -lklayout_lib -lklayout_ut
# Note: this accounts for UI-generated headers placed into the output folders in # Note: this accounts for UI-generated headers placed into the output folders in
# shadow builds: # shadow builds: