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

View File

@ -6,6 +6,7 @@ include($$PWD/../klayout.pri)
TARGET = klayout
include($$PWD/../app.pri)
include($$PWD/../with_all_libs.pri)
HEADERS = \
@ -16,10 +17,6 @@ SOURCES = \
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 {
windres.target = klayout_rc.o
@ -32,34 +29,3 @@ win32 {
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 \
layLayoutStatisticsForm.h \
layLogViewerDialog.h \
layMacro.h \
layMacroEditorDialog.h \
layMacroEditorPage.h \
layMacroEditorSetupDialog.h \
layMacroEditorTree.h \
layMacroInterpreter.h \
layMacroPropertiesDialog.h \
layMacroVariableView.h \
layMainConfigPages.h \
@ -113,7 +111,6 @@ FORMS = \
SOURCES = \
gsiDeclLayApplication.cc \
gsiDeclLayHelpDialog.cc \
gsiDeclLayMacro.cc \
gsiDeclLayMainWindow.cc \
layApplication.cc \
layClipDialog.cc \
@ -126,12 +123,10 @@ SOURCES = \
layHelpSource.cc \
layLayoutStatisticsForm.cc \
layLogViewerDialog.cc \
layMacro.cc \
layMacroEditorDialog.cc \
layMacroEditorPage.cc \
layMacroEditorSetupDialog.cc \
layMacroEditorTree.cc \
layMacroInterpreter.cc \
layMacroPropertiesDialog.cc \
layMacroVariableView.cc \
layMainConfigPages.cc \
@ -174,9 +169,9 @@ RESOURCES = layBuildInMacros.qrc \
layResources.qrc \
laySaltTemplates.qrc
INCLUDEPATH += ../tl ../gsi ../db ../rdb ../laybasic ../ant ../img ../edt
DEPENDPATH += ../tl ../gsi ../db ../rdb ../laybasic ../ant ../img ../edt
LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt
INCLUDEPATH += ../tl ../gsi ../db ../rdb ../lym ../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_lym -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt
win32 {
# for stack trace support:

View File

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

View File

@ -50,6 +50,11 @@ namespace tl
class DeferredMethodScheduler;
}
namespace lym
{
class MacroCollection;
}
namespace lay
{
@ -57,7 +62,6 @@ class MainWindow;
class PluginRoot;
class ProgressReporter;
class ProgressBar;
class MacroCollection;
/**
* @brief A tiny struct describing a native plugin
@ -285,7 +289,7 @@ public:
*
* 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

View File

@ -24,11 +24,12 @@
#include "layTechnologyController.h"
#include "laySaltController.h"
#include "layMacroEditorDialog.h"
#include "layMacroInterpreter.h"
#include "layMainWindow.h"
#include "layMainConfigPages.h"
#include "layConfig.h"
#include "layApplication.h"
#include "lymMacroInterpreter.h"
#include "lymMacro.h"
#include <QDir>
#include <QUrl>
@ -45,7 +46,7 @@ MacroController::MacroController ()
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 (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
@ -54,8 +55,8 @@ MacroController::load ()
// Scan built-in macros
// These macros are always taken, even if there are no macros requested (they are required to
// fully form the API).
lay::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-macros", "macros", 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
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) {
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)));
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);
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);
}
@ -94,8 +95,8 @@ MacroController::initialized (lay::PluginRoot *root)
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 (&lay::MacroCollection::root (), SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (&lym::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
connect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
if (lay::TechnologyController::instance ()) {
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 ()));
@ -115,8 +116,8 @@ MacroController::initialized (lay::PluginRoot *root)
void
MacroController::uninitialize (lay::PluginRoot * /*root*/)
{
disconnect (&lay::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 (menu_needs_update ()), this, SLOT (macro_collection_changed ()));
disconnect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
if (lay::TechnologyController::instance ()) {
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 ()));
@ -188,7 +189,7 @@ MacroController::accepts_drop (const std::string &path_or_url) const
}
// 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 ())) {
return true;
}
@ -211,7 +212,7 @@ MacroController::drop_url (const std::string &path_or_url)
}
// 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->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 ()) {
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
std::vector<lay::MacroCollection *> folders_to_delete;
std::vector<lym::MacroCollection *> folders_to_delete;
// determine the paths that will be in use
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-> ()));
}
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) {
if (m->second->virtual_mode () == lay::MacroCollection::TechFolder ||
m->second->virtual_mode () == lay::MacroCollection::SaltFolder) {
for (lym::MacroCollection::child_iterator m = root->begin_children (); m != root->end_children (); ++m) {
if (m->second->virtual_mode () == lym::MacroCollection::TechFolder ||
m->second->virtual_mode () == lym::MacroCollection::SaltFolder) {
std::map<std::string, const ExternalPathDescriptor *>::const_iterator u = new_folders_by_path.find (m->second->path ());
if (u == new_folders_by_path.end ()) {
// 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) {
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
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) {
@ -463,7 +464,7 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
// In that case, the add_folder method will return 0.
// 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) {
mc->set_virtual_mode (p->type);
new_folders.push_back (mc);
@ -477,13 +478,13 @@ MacroController::sync_implicit_macros (bool ask_before_autorun)
tl::NoDeferredMethods silent;
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 ();
}
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) {
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 ();
}
}
@ -499,19 +500,19 @@ MacroController::add_path (const std::string &path, const std::string &descripti
}
void
MacroController::add_temp_macro (lay::Macro *m)
MacroController::add_temp_macro (lym::Macro *m)
{
m_temp_macros.add_unspecific (m);
}
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)
bool consider = false;
if (! tech || c->second->virtual_mode () != lay::MacroCollection::TechFolder) {
if (! tech || c->second->virtual_mode () != lym::MacroCollection::TechFolder) {
consider = true;
} else {
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 ());
@ -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));
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 ()));
// 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);
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 ()));
}
@ -649,7 +650,7 @@ MacroController::do_update_menu_with_macros ()
int n = 1;
std::set<std::string> groups;
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
std::sort (new_key_bindings.begin (), new_key_bindings.end ());
@ -665,9 +666,9 @@ MacroController::file_watcher_triggered ()
}
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] != ':') {
watcher->add_file (c->second->path ());
add_collections_to_file_watcher (*c->second, watcher);
@ -680,7 +681,7 @@ MacroController::sync_file_watcher ()
{
m_file_watcher->clear ();
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);
}
@ -688,7 +689,7 @@ void
MacroController::sync_files ()
{
tl::log << tl::to_string (tr ("Detected file system change in macro folders - updating"));
lay::MacroCollection::root ().reload ();
lym::MacroCollection::root ().reload ();
}
MacroController *

View File

@ -26,7 +26,7 @@
#include "layCommon.h"
#include "layPlugin.h"
#include "layMacro.h"
#include "lymMacro.h"
#include "tlObject.h"
#include "tlDeferredExecution.h"
#include "tlFileSystemWatcher.h"
@ -142,7 +142,7 @@ public:
* menu building. Hence they are stored temporarily.
* 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
@ -180,7 +180,7 @@ private:
*/
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)
{
// .. nothing yet ..
@ -189,7 +189,7 @@ private:
std::string path;
std::string description;
std::string cat;
lay::MacroCollection::FolderType type;
lym::MacroCollection::FolderType type;
bool readonly;
};
@ -214,8 +214,8 @@ private:
lay::MainWindow *mp_mw;
bool m_no_implicit_macros;
std::vector<lay::Action> m_macro_actions;
std::map<QAction *, lay::Macro *> m_action_to_macro;
lay::MacroCollection m_temp_macros;
std::map<QAction *, lym::Macro *> m_action_to_macro;
lym::MacroCollection m_temp_macros;
std::vector< std::pair<std::string, std::string> > m_macro_categories;
std::vector<InternalPathDescriptor> m_internal_paths;
std::vector<ExternalPathDescriptor> m_external_paths;
@ -227,7 +227,7 @@ private:
tl::DeferredMethod<MacroController> dm_sync_files;
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_sync_with_external_sources ();
void sync_file_watcher ();

View File

@ -27,7 +27,6 @@
#include "layMacroEditorDialog.h"
#include "layMacroEditorSetupDialog.h"
#include "layMacroPropertiesDialog.h"
#include "layMacroInterpreter.h"
#include "layFileDialog.h"
#include "layMainWindow.h"
#include "layHelpDialog.h"
@ -39,6 +38,7 @@
#include "layConfig.h"
#include "layWidgets.h"
#include "layProgress.h"
#include "lymMacroInterpreter.h"
#include "tlString.h"
#include "tlClassRegistry.h"
#include "tlExceptions.h"
@ -85,7 +85,7 @@ class MacroTemplateSelectionDialog
: public QDialog, private Ui::MacroTemplateSelectionDialog
{
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)
{
setupUi (this);
@ -101,7 +101,7 @@ public:
// Build a tree from the templates. Groups are formed by prepending a group title in the description
// separated from the actual description by ";;"
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 ();
@ -225,7 +225,7 @@ public:
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),
mp_root (root),
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);
connect (mp_root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed (Macro *)));
connect (mp_root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *)));
connect (mp_root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *)));
connect (mp_root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed (MacroCollection *)));
connect (mp_root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed (lym::Macro *)));
connect (mp_root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (mp_root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (mp_root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed (lym::MacroCollection *)));
m_categories = lay::MacroController::instance ()->macro_categories ();
@ -313,11 +313,11 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
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 (move_macro (lay::Macro *, lay::MacroCollection *)), this, SLOT (move_macro (lay::Macro *, lay::MacroCollection *)));
connect (macro_tree, SIGNAL (move_folder (lay::MacroCollection *, lay::MacroCollection *)), this, SLOT (move_folder (lay::MacroCollection *, lay::MacroCollection *)));
connect (macro_tree, SIGNAL (folder_renamed (lay::MacroCollection *)), this, SLOT (folder_renamed (lay::MacroCollection *)));
connect (macro_tree, SIGNAL (macro_renamed (lay::Macro *)), this, SLOT (macro_renamed (lay::Macro *)));
connect (macro_tree, SIGNAL (macro_double_clicked (lym::Macro *)), this, SLOT (item_double_clicked (lym::Macro *)));
connect (macro_tree, SIGNAL (move_macro (lym::Macro *, lym::MacroCollection *)), this, SLOT (move_macro (lym::Macro *, lym::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 (lym::MacroCollection *)), this, SLOT (folder_renamed (lym::MacroCollection *)));
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 ());
}
Macro *m = new Macro ();
lym::Macro *m = new lym::Macro ();
try {
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");
// 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 ()) {
filters << tl::to_qstring ("*." + cls->suffix ());
}
@ -547,7 +547,7 @@ MacroEditorDialog::MacroEditorDialog (QWidget * /*parent*/, lay::MacroCollection
QStringList files = dir.entryList (filters, QDir::Files);
for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) {
Macro *m = new Macro ();
lym::Macro *m = new lym::Macro ();
try {
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
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 ();
cls->get_templates (m_macro_templates);
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 ();
}
}
@ -606,7 +606,7 @@ MacroEditorDialog::~MacroEditorDialog ()
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;
}
m_macro_templates.clear ();
@ -658,11 +658,11 @@ BEGIN_PROTECTED
}
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
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 ()) {
ct->set_current (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 ()))) {
lay::Macro *m = new_macro ();
lym::Macro *m = new_macro ();
if (force_add && m) {
set_run_macro (m);
}
@ -696,7 +696,7 @@ BEGIN_PROTECTED
select_category (cat);
}
lay::Macro *m = new_macro ();
lym::Macro *m = new_macro ();
if (force_add && m) {
set_run_macro (m);
}
@ -820,7 +820,7 @@ MacroEditorDialog::showEvent (QShowEvent *)
std::string am;
MainWindow::instance ()->config_get (cfg_macro_editor_active_macro, am);
if (! am.empty ()) {
lay::Macro *macro = mp_root->find_macro (am);
lym::Macro *macro = mp_root->find_macro (am);
if (macro) {
set_run_macro (macro);
}
@ -835,7 +835,7 @@ MacroEditorDialog::showEvent (QShowEvent *)
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);
}
@ -945,7 +945,7 @@ MacroEditorDialog::set_debugging_on (bool 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);
}
@ -976,14 +976,14 @@ MacroEditorDialog::process_events (QEventLoop::ProcessEventsFlags flags)
}
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)) {
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 ()) {
return true;
}
@ -1529,7 +1529,7 @@ MacroEditorDialog::update_console_text ()
void
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 ()) {
page->second->commit ();
}
@ -1537,20 +1537,20 @@ MacroEditorDialog::commit ()
}
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
std::set <lay::Macro *> used_macros;
std::set <lay::MacroCollection *> used_collections;
std::set <lym::Macro *> used_macros;
std::set <lym::MacroCollection *> 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) {
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 ()) {
// disable the macro on the page - we'll ask for updates when the file
// watcher becomes active. So long, the macro is "zombie".
@ -1565,13 +1565,13 @@ MacroEditorDialog::macro_collection_deleted (lay::MacroCollection *collection)
}
void
MacroEditorDialog::macro_deleted (lay::Macro *macro)
MacroEditorDialog::macro_deleted (lym::Macro *macro)
{
if (mp_run_macro == macro) {
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 ()) {
// disable the macro on the page - we'll ask for updates when the file
// watcher becomes active. So long, the macro is "zombie".
@ -1584,15 +1584,15 @@ MacroEditorDialog::macro_deleted (lay::Macro *macro)
}
void
MacroEditorDialog::macro_collection_changed (lay::MacroCollection * /*collection*/)
MacroEditorDialog::macro_collection_changed (lym::MacroCollection * /*collection*/)
{
refresh_file_watcher ();
}
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 ()) {
int index = tabWidget->indexOf (page->second);
QString tt = tl::to_qstring (macro->summary ());
@ -1629,12 +1629,12 @@ MacroEditorDialog::current_tab_changed (int index)
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 ();
MacroCollection *collection = mt->current_macro_collection ();
lym::MacroCollection *collection = mt->current_macro_collection ();
if (! collection) {
Macro *m = mt->current_macro ();
lym::Macro *m = mt->current_macro ();
if (m) {
collection = m->parent ();
}
@ -1648,19 +1648,19 @@ lay::Macro *MacroEditorDialog::create_macro_here (const char *prefix)
}
void
MacroEditorDialog::macro_renamed (lay::Macro * /*macro*/)
MacroEditorDialog::macro_renamed (lym::Macro * /*macro*/)
{
refresh_file_watcher ();
}
void
MacroEditorDialog::folder_renamed (lay::MacroCollection * /*mc*/)
MacroEditorDialog::folder_renamed (lym::MacroCollection * /*mc*/)
{
refresh_file_watcher ();
}
void
MacroEditorDialog::move_macro (lay::Macro *source, lay::MacroCollection *target)
MacroEditorDialog::move_macro (lym::Macro *source, lym::MacroCollection *target)
{
if (m_in_exec) {
return;
@ -1670,12 +1670,12 @@ BEGIN_PROTECTED
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->set_readonly (false);
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 ()) {
MacroEditorPage *w = page->second;
w->connect_macro (m);
@ -1686,7 +1686,7 @@ BEGIN_PROTECTED
}
if (! source->is_readonly ()) {
MacroCollection *collection = source->parent ();
lym::MacroCollection *collection = source->parent ();
if (collection && ! collection->is_readonly ()) {
if (source->del ()) {
collection->erase (source);
@ -1706,18 +1706,18 @@ END_PROTECTED
}
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) {
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) {
continue;
}
@ -1726,7 +1726,7 @@ MacroEditorDialog::move_subfolder (lay::MacroCollection *source, lay::MacroColle
m->set_readonly (false);
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 ()) {
MacroEditorPage *w = page->second;
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);
}
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);
if (! m->second->is_readonly ()) {
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);
}
}
void
MacroEditorDialog::move_folder (lay::MacroCollection *source, lay::MacroCollection *target)
MacroEditorDialog::move_folder (lym::MacroCollection *source, lym::MacroCollection *target)
{
if (m_in_exec) {
return;
@ -1893,7 +1893,7 @@ MacroEditorDialog::save_button_clicked ()
BEGIN_PROTECTED
Macro *m = current_macro_tree ()->current_macro ();
lym::Macro *m = current_macro_tree ()->current_macro ();
if (m) {
m->save ();
} else if (tabWidget->currentWidget ()) {
@ -2003,8 +2003,8 @@ BEGIN_PROTECTED
return;
}
Macro *macro = page->macro ();
if (macro->format () == lay::Macro::PlainTextWithHashAnnotationsFormat) {
lym::Macro *macro = page->macro ();
if (macro->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
page->commit ();
}
@ -2037,7 +2037,7 @@ BEGIN_PROTECTED
END_PROTECTED
}
lay::Macro *
lym::Macro *
MacroEditorDialog::new_macro()
{
ensure_writeable_collection_selected ();
@ -2059,7 +2059,7 @@ MacroEditorDialog::new_macro()
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->set_readonly (false);
// we don't want to keep the template's description
@ -2103,7 +2103,7 @@ BEGIN_PROTECTED
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) {
m_tab_widgets.erase (p);
break;
@ -2135,8 +2135,8 @@ BEGIN_PROTECTED
lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection ();
Macro *m = ct->current_macro ();
lym::MacroCollection *collection = ct->current_macro_collection ();
lym::Macro *m = ct->current_macro ();
if (collection) {
@ -2150,7 +2150,7 @@ BEGIN_PROTECTED
throw tl::Exception ("Can't delete this folder - it is not empty");
}
MacroCollection *p = collection->parent ();
lym::MacroCollection *p = collection->parent ();
if (p) {
@ -2171,7 +2171,7 @@ BEGIN_PROTECTED
} else if (m) {
MacroCollection *collection = m->parent ();
lym::MacroCollection *collection = m->parent ();
if (m->is_readonly ()) {
throw tl::Exception ("Can't delete this macro - it is readonly");
}
@ -2226,9 +2226,9 @@ void
MacroEditorDialog::ensure_writeable_collection_selected ()
{
lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection ();
lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) {
Macro *macro = ct->current_macro ();
lym::Macro *macro = ct->current_macro ();
if (macro) {
collection = macro->parent ();
}
@ -2236,7 +2236,7 @@ MacroEditorDialog::ensure_writeable_collection_selected ()
// Select the first writeable collection if none is selected
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 ()) {
ct->set_current (c->second);
collection = c->second;
@ -2317,7 +2317,7 @@ BEGIN_PROTECTED
}
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 ()) {
modified_files.insert (m->first->path ());
}
@ -2400,7 +2400,7 @@ MacroEditorDialog::file_removed (const QString &path)
}
void
MacroEditorDialog::sync_file_watcher (lay::MacroCollection * /*collection*/)
MacroEditorDialog::sync_file_watcher (lym::MacroCollection * /*collection*/)
{
#if 0
// 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 ());
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 ()) {
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);
}
#else
// 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 ());
}
#endif
@ -2499,7 +2499,7 @@ BEGIN_PROTECTED
std::string new_path = tl::to_string (QFileInfo (new_dir).absoluteFilePath ());
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) {
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
lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection ();
lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) {
Macro *m = ct->current_macro ();
lym::Macro *m = ct->current_macro ();
if (m) {
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)"));
// 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 ()) {
filters += ";;";
if (! cls->description ().empty ()) {
@ -2609,7 +2609,7 @@ BEGIN_PROTECTED
if (file_dialog->get_open (fn)) {
// 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 {
m->load_from (fn);
@ -2642,9 +2642,9 @@ BEGIN_PROTECTED
ensure_writeable_collection_selected ();
lay::MacroEditorTree *ct = current_macro_tree ();
MacroCollection *collection = ct->current_macro_collection ();
lym::MacroCollection *collection = ct->current_macro_collection ();
if (! collection) {
Macro *m = ct->current_macro ();
lym::Macro *m = ct->current_macro ();
if (m) {
collection = m->parent ();
}
@ -2654,7 +2654,7 @@ BEGIN_PROTECTED
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) {
throw tl::Exception (tl::to_string (QObject::tr ("Failed to create the folder here")));
}
@ -2687,11 +2687,11 @@ END_PROTECTED
}
void
MacroEditorDialog::item_double_clicked(lay::Macro *m)
MacroEditorDialog::item_double_clicked(lym::Macro *m)
{
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 ()) {
MacroEditorPage *page = create_page (m);
@ -2730,7 +2730,7 @@ MacroEditorDialog::start_exec (gsi::Interpreter *ec)
m_current_stack_depth = -1;
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_run_mode (true);
}
@ -2756,7 +2756,7 @@ MacroEditorDialog::end_exec (gsi::Interpreter *ec)
m_continue = false;
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);
}
@ -2767,14 +2767,14 @@ MacroEditorDialog::end_exec (gsi::Interpreter *ec)
size_t
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) {
m_file_to_widget.push_back (*m);
return m_file_to_widget.size ();
}
}
lay::Macro *macro = mp_root->find_macro (path);
lym::Macro *macro = mp_root->find_macro (path);
if (macro) {
m_file_to_widget.push_back (std::make_pair (macro, (MacroEditorPage *) 0));
return m_file_to_widget.size ();
@ -3002,8 +3002,8 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
MacroEditorPage *page = dynamic_cast<MacroEditorPage *> (tabWidget->currentWidget ());
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);
runThisButton->setEnabled ((! m_in_exec && 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 () != lym::Macro::None) || m_in_breakpoint);
singleStepButton->setEnabled (! m_in_exec || m_in_breakpoint);
nextStepButton->setEnabled (! m_in_exec || m_in_breakpoint);
stopButton->setEnabled (m_in_exec);
@ -3033,7 +3033,7 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
actionRefresh->setEnabled (! m_in_exec);
actionAddLocation->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);
langSelFrame->setEnabled (! m_in_exec);
@ -3085,7 +3085,7 @@ MacroEditorDialog::do_update_ui_to_run_mode ()
variableList->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 ()) {
int index = tabWidget->indexOf (t->second);
if (index >= 0) {
@ -3106,7 +3106,7 @@ MacroEditorDialog::stack_element_double_clicked (QListWidgetItem *item)
}
MacroEditorPage *
MacroEditorDialog::create_page (Macro *macro)
MacroEditorDialog::create_page (lym::Macro *macro)
{
std::auto_ptr<MacroEditorPage> editor (new MacroEditorPage (this, &m_highlighters));
editor->set_ntab (m_ntab);
@ -3120,7 +3120,7 @@ MacroEditorDialog::create_page (Macro *macro)
}
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) {
(*mt)->set_current (macro);
@ -3128,7 +3128,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
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 ()) {
editor = create_page (macro);
@ -3142,7 +3142,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
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) {
f->second = editor;
break;
@ -3160,7 +3160,7 @@ MacroEditorDialog::editor_for_macro (Macro *macro)
MacroEditorPage *
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) {
return editor_for_macro (macro);
} else {
@ -3176,7 +3176,7 @@ MacroEditorDialog::set_exec_point (const std::string *file, int line, int eval_c
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);
}
@ -3207,7 +3207,7 @@ MacroEditorDialog::breakpoint_button_clicked ()
void
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> ());
}
}
@ -3262,14 +3262,14 @@ BEGIN_PROTECTED
END_PROTECTED
}
lay::Macro *
lym::Macro *
MacroEditorDialog::current_run_macro ()
{
// validate the current run macro against the macros present in the collection and
// return 0 if invalid (that takes the current one)
std::set<lay::Macro *> macros;
std::set<lay::MacroCollection *> macro_collections;
std::set<lym::Macro *> macros;
std::set<lym::MacroCollection *> macro_collections;
mp_root->collect_used_nodes (macros, macro_collections);
if (macros.find (mp_run_macro) != macros.end ()) {
@ -3280,7 +3280,7 @@ MacroEditorDialog::current_run_macro ()
}
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_continue = true;
@ -3364,11 +3364,11 @@ MacroEditorDialog::run (int stop_stack_depth, lay::Macro *macro)
}
void
MacroEditorDialog::set_run_macro (lay::Macro *m)
MacroEditorDialog::set_run_macro (lym::Macro *m)
{
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 ()) {
int index = tabWidget->indexOf (t->second);
if (index >= 0) {

View File

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

View File

@ -22,7 +22,7 @@
#include "layMacroEditorPage.h"
#include "layMacroInterpreter.h"
#include "lymMacroInterpreter.h"
#include "tlExceptions.h"
#include "tlString.h"
@ -94,7 +94,7 @@ MacroEditorHighlighters::MacroEditorHighlighters (QObject *parent)
}
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);
@ -127,7 +127,7 @@ MacroEditorHighlighters::highlighter_for_scheme (QObject *parent, const std::str
}
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);
@ -195,14 +195,14 @@ MacroEditorHighlighters::load (const std::string &s)
}
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";
} else if (lang == Macro::Python) {
} else if (lang == lym::Macro::Python) {
return "python";
} else if (lang == Macro::DSLInterpreter) {
return MacroInterpreter::syntax_scheme (dsl_name);
} else if (lang == lym::Macro::DSLInterpreter) {
return lym::MacroInterpreter::syntax_scheme (dsl_name);
} else {
return std::string ();
}
@ -212,22 +212,22 @@ MacroEditorHighlighters::scheme_for (lay::Macro::Interpreter lang, const std::st
// MacroEditorExecutionModel implementation
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 ..
}
void MacroEditorExecutionModel::set_interpreter (Macro::Interpreter lang)
void MacroEditorExecutionModel::set_interpreter (lym::Macro::Interpreter lang)
{
m_interpreter = lang;
if (lang == Macro::None) {
if (lang == lym::Macro::None) {
set_breakpoints (std::set<int> ());
}
}
void MacroEditorExecutionModel::set_breakpoints (const std::set<int> &b)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
return;
}
@ -239,7 +239,7 @@ void MacroEditorExecutionModel::set_breakpoints (const std::set<int> &b)
void MacroEditorExecutionModel::toggle_breakpoint (int line)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
return;
}
@ -253,7 +253,7 @@ void MacroEditorExecutionModel::toggle_breakpoint (int line)
void MacroEditorExecutionModel::set_breakpoint (int line)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
return;
}
@ -265,7 +265,7 @@ void MacroEditorExecutionModel::set_breakpoint (int line)
void MacroEditorExecutionModel::remove_breakpoint (int line)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
return;
}
@ -277,7 +277,7 @@ void MacroEditorExecutionModel::remove_breakpoint (int line)
void MacroEditorExecutionModel::set_current_line (int line, bool force_event)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
return;
}
@ -289,7 +289,7 @@ void MacroEditorExecutionModel::set_current_line (int line, bool force_event)
void MacroEditorExecutionModel::set_run_mode (bool run_mode)
{
if (m_interpreter == Macro::None) {
if (m_interpreter == lym::Macro::None) {
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) {
@ -822,9 +822,9 @@ void MacroEditorPage::connect_macro (Macro *macro)
connect (mp_macro, SIGNAL (changed ()), this, SLOT (update ()));
Macro::Interpreter lang = macro->interpreter ();
if (lang == Macro::DSLInterpreter) {
lang = MacroInterpreter::debugger_scheme (macro->dsl_interpreter ());
lym::Macro::Interpreter lang = macro->interpreter ();
if (lang == lym::Macro::DSLInterpreter) {
lang = lym::MacroInterpreter::debugger_scheme (macro->dsl_interpreter ());
}
mp_exec_model->set_interpreter (lang);
@ -842,7 +842,7 @@ void MacroEditorPage::connect_macro (Macro *macro)
m_is_modified = false;
} 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 ());

View File

@ -27,7 +27,7 @@
#include "layCommon.h"
#include "layMacro.h"
#include "lymMacro.h"
#include "layGenericSyntaxHighlighter.h"
#include <QDialog>
@ -49,9 +49,6 @@ class QSyntaxHighlighter;
namespace lay
{
class Macro;
class MacroCollection;
/**
* @brief A collection of highlighters
*/
@ -60,9 +57,9 @@ class MacroEditorHighlighters
public:
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 ();
std::string to_string () const;
@ -96,7 +93,7 @@ private:
GenericSyntaxHighlighterAttributes m_basic_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 ();
}
void set_interpreter (Macro::Interpreter lang);
void set_interpreter (lym::Macro::Interpreter lang);
void set_breakpoints (const std::set<int> &b);
@ -156,7 +153,7 @@ private:
std::set<int> m_breakpoints;
int m_current_line;
bool m_run_mode;
Macro::Interpreter m_interpreter;
lym::Macro::Interpreter m_interpreter;
};
/**
@ -218,9 +215,9 @@ Q_OBJECT
public:
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;
}
@ -285,7 +282,7 @@ protected slots:
void run_mode_changed ();
private:
Macro *mp_macro;
lym::Macro *mp_macro;
MacroEditorExecutionModel *mp_exec_model;
MacroEditorTextWidget *mp_text;
MacroEditorSidePanel *mp_side_panel;

View File

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

View File

@ -23,7 +23,7 @@
#include "layMacroEditorTree.h"
#include "layMacroEditorDialog.h"
#include "layMacro.h"
#include "lymMacro.h"
#include "tlExceptions.h"
#include "tlInternational.h"
#include "tlException.h"
@ -40,13 +40,13 @@ namespace lay
// -----------------------------------------------------------------------------------------
// 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
if (m->interpreter () == Macro::Text) {
if (m->interpreter () == lym::Macro::Text) {
return QIcon (QString::fromUtf8 (":/textdocumenticon.png"));
} else if (m->interpreter () == Macro::Ruby) {
if (m->format () == Macro::PlainTextFormat || m->format () == Macro::PlainTextWithHashAnnotationsFormat) {
} else if (m->interpreter () == lym::Macro::Ruby) {
if (m->format () == lym::Macro::PlainTextFormat || m->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
if (active) {
return QIcon (QString::fromUtf8 (":/rubymacroiconactive.png"));
} else {
@ -59,8 +59,8 @@ static QIcon tree_icon_for_format (const lay::Macro *m, bool active)
return QIcon (QString::fromUtf8 (":/generalmacroicon.png"));
}
}
} else if (m->interpreter () == Macro::Python) {
if (m->format () == Macro::PlainTextFormat || m->format () == Macro::PlainTextWithHashAnnotationsFormat) {
} else if (m->interpreter () == lym::Macro::Python) {
if (m->format () == lym::Macro::PlainTextFormat || m->format () == lym::Macro::PlainTextWithHashAnnotationsFormat) {
if (active) {
return QIcon (QString::fromUtf8 (":/pythonmacroiconactive.png"));
} else {
@ -80,7 +80,7 @@ static QIcon tree_icon_for_format (const lay::Macro *m, bool active)
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)
{
next ();
@ -91,12 +91,12 @@ struct FilteredMacroCollectionIter
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* ();
}
const std::pair<const std::string, lay::MacroCollection *> *operator-> () const
const std::pair<const std::string, lym::MacroCollection *> *operator-> () const
{
return m_b.operator-> ();
}
@ -108,7 +108,7 @@ struct FilteredMacroCollectionIter
}
private:
lay::MacroCollection::const_child_iterator m_b, m_e;
lym::MacroCollection::const_child_iterator m_b, m_e;
std::string m_category;
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)
{
connect (root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *)));
connect (root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
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)
{
connect (root, SIGNAL (macro_changed (Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (Macro *)), this, SLOT (macro_deleted (Macro *)));
connect (root, SIGNAL (macro_collection_deleted (MacroCollection *)), this, SLOT (macro_collection_deleted (MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (root, SIGNAL (macro_changed (lym::Macro *)), this, SLOT (macro_changed ()));
connect (root, SIGNAL (macro_deleted (lym::Macro *)), this, SLOT (macro_deleted (lym::Macro *)));
connect (root, SIGNAL (macro_collection_deleted (lym::MacroCollection *)), this, SLOT (macro_collection_deleted (lym::MacroCollection *)));
connect (root, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ()));
connect (root, SIGNAL (about_to_change ()), this, SLOT (about_to_change ()));
}
@ -144,12 +144,12 @@ Qt::DropActions MacroTreeModel::supportedDropActions() const
return Qt::MoveAction;
}
void MacroTreeModel::macro_deleted (lay::Macro *)
void MacroTreeModel::macro_deleted (lym::Macro *)
{
// .. nothing yet ..
}
void MacroTreeModel::macro_collection_deleted (lay::MacroCollection *)
void MacroTreeModel::macro_collection_deleted (lym::MacroCollection *)
{
// .. nothing yet ..
}
@ -177,8 +177,8 @@ void MacroTreeModel::macro_collection_changed ()
QModelIndexList pi = persistentIndexList ();
for (QModelIndexList::const_iterator i = pi.begin (); i != pi.end (); ++i) {
if (is_valid_pointer (i->internalPointer ())) {
lay::Macro *macro = dynamic_cast <lay::Macro *> ((QObject *) i->internalPointer ());
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> ((QObject *) i->internalPointer ());
lym::Macro *macro = dynamic_cast <lym::Macro *> ((QObject *) i->internalPointer ());
lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> ((QObject *) i->internalPointer ());
if (macro) {
changePersistentIndex (*i, index_for (macro));
} else if (mc) {
@ -203,13 +203,13 @@ bool MacroTreeModel::is_valid_pointer (void *ptr) const
{
if (m_valid_objects.empty ()) {
std::set<lay::Macro *> macros;
std::set<lay::MacroCollection *> macro_collections;
std::set<lym::Macro *> macros;
std::set<lym::MacroCollection *> 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);
}
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);
}
@ -258,7 +258,7 @@ bool MacroTreeModel::dropMimeData (const QMimeData *data, Qt::DropAction /*actio
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) {
return false;
}
@ -271,8 +271,8 @@ bool MacroTreeModel::dropMimeData (const QMimeData *data, Qt::DropAction /*actio
if (is_valid_pointer ((void *) p)) {
QObject *from_object = (QObject *) (void *) p;
lay::Macro *from_macro = dynamic_cast <lay::Macro *> (from_object);
lay::MacroCollection *from_mc = dynamic_cast <lay::MacroCollection *> (from_object);
lym::Macro *from_macro = dynamic_cast <lym::Macro *> (from_object);
lym::MacroCollection *from_mc = dynamic_cast <lym::MacroCollection *> (from_object);
if (from_macro) {
emit move_macro (from_macro, to_mc);
@ -287,7 +287,7 @@ bool MacroTreeModel::dropMimeData (const QMimeData *data, Qt::DropAction /*actio
return true;
}
int MacroTreeModel::columnCount (const QModelIndex & /*parent*/) const
int MacroTreeModel::columnCount (const QModelIndex & /*parent*/) const
{
return 1;
}
@ -299,8 +299,8 @@ bool MacroTreeModel::setData (const QModelIndex &index, const QVariant &v, int r
}
QObject *object = (QObject *) index.internalPointer ();
lay::Macro *macro = dynamic_cast <lay::Macro *> (object);
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> (object);
lym::Macro *macro = dynamic_cast <lym::Macro *> (object);
lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> (object);
// TODO: don't do this while executing
if (macro) {
@ -337,8 +337,8 @@ QVariant MacroTreeModel::data (const QModelIndex &index, int role) const
}
const QObject *object = (QObject *) index.internalPointer ();
const lay::Macro *macro = dynamic_cast <const lay::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object);
const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
if (macro) {
if (role == Qt::DisplayRole) {
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 lay::Macro *macro = dynamic_cast <const lay::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object);
const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
if (macro) {
if (! macro->is_readonly ()) {
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
{
const lay::MacroCollection *mc = 0;
const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) {
mc = mp_root;
} else {
if (! is_valid_pointer (parent.internalPointer ())) {
return false;
}
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ());
mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
}
if (mc) {
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 lay::Macro *macro = dynamic_cast <const lay::Macro *> (object);
const lay::MacroCollection *mc = dynamic_cast <const lay::MacroCollection *> (object);
const lym::Macro *macro = dynamic_cast <const lym::Macro *> (object);
const lym::MacroCollection *mc = dynamic_cast <const lym::MacroCollection *> (object);
const lay::MacroCollection *p = 0;
const lym::MacroCollection *p = 0;
if (macro) {
p = macro->parent ();
} else if (mc) {
@ -440,7 +440,7 @@ QModelIndex MacroTreeModel::parent (const QModelIndex &index) const
}
if (p) {
const lay::MacroCollection *pp = p->parent ();
const lym::MacroCollection *pp = p->parent ();
if (pp) {
int row = 0;
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
{
const lay::MacroCollection *mc = 0;
const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) {
mc = mp_root;
} else {
if (! is_valid_pointer (parent.internalPointer ())) {
return QModelIndex ();
}
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ());
mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
}
if (mc) {
@ -475,7 +475,7 @@ QModelIndex MacroTreeModel::index (int row, int column, const QModelIndex &paren
}
++i;
}
lay::MacroCollection::const_iterator j = mc->begin ();
lym::MacroCollection::const_iterator j = mc->begin ();
while (j != mc->end ()) {
if (r-- <= 0) {
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
{
const lay::MacroCollection *mc = 0;
const lym::MacroCollection *mc = 0;
if (! parent.isValid ()) {
mc = mp_root;
} else {
if (! is_valid_pointer (parent.internalPointer ())) {
return 0;
}
mc = dynamic_cast <const lay::MacroCollection *> ((QObject *) parent.internalPointer ());
mc = dynamic_cast <const lym::MacroCollection *> ((QObject *) parent.internalPointer ());
}
int n = 0;
@ -504,7 +504,7 @@ int MacroTreeModel::rowCount (const QModelIndex &parent) const
for (FilteredMacroCollectionIter i (mc, m_category); ! i.at_end (); ++i) {
++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;
}
}
@ -512,14 +512,14 @@ int MacroTreeModel::rowCount (const QModelIndex &parent) const
}
QModelIndex
MacroTreeModel::index_for (lay::Macro *macro) const
MacroTreeModel::index_for (lym::Macro *macro) const
{
if (! macro || ! macro->parent ()) {
return QModelIndex ();
}
// check category
const lay::MacroCollection *pp = macro->parent ();
const lym::MacroCollection *pp = macro->parent ();
while (pp && (pp->category ().empty () || pp->category () == m_category)) {
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 (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) {
return createIndex (row, 0, (void *)(QObject *)macro);
}
@ -543,14 +543,14 @@ MacroTreeModel::index_for (lay::Macro *macro) const
}
QModelIndex
MacroTreeModel::index_for (lay::MacroCollection *mc) const
MacroTreeModel::index_for (lym::MacroCollection *mc) const
{
if (! mc || ! mc->parent ()) {
return QModelIndex ();
}
// check category
const lay::MacroCollection *pp = mc;
const lym::MacroCollection *pp = mc;
while (pp && (pp->category ().empty () || pp->category () == m_category)) {
pp = pp->parent ();
}
@ -585,49 +585,49 @@ MacroEditorTree::MacroEditorTree (QWidget *parent, const std::string &cat)
setDropIndicatorShown (true);
}
void MacroEditorTree::model_macro_renamed (lay::Macro *macro)
void MacroEditorTree::model_macro_renamed (lym::Macro *macro)
{
set_current (macro);
emit macro_renamed (macro);
}
void MacroEditorTree::model_folder_renamed (lay::MacroCollection *mc)
void MacroEditorTree::model_folder_renamed (lym::MacroCollection *mc)
{
set_current (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);
}
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);
}
lay::Macro *MacroEditorTree::current_macro () const
lym::Macro *MacroEditorTree::current_macro () const
{
QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ());
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 {
return 0;
}
}
lay::MacroCollection *MacroEditorTree::current_macro_collection () const
lym::MacroCollection *MacroEditorTree::current_macro_collection () const
{
QModelIndex ci = mp_proxyModel->mapToSource (currentIndex ());
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 {
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));
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));
setCurrentIndex (index);
@ -653,16 +653,16 @@ bool MacroEditorTree::set_current (lay::MacroCollection *mc)
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->setSourceModel (mp_model);
setModel (mp_proxyModel);
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 (folder_renamed (lay::MacroCollection *)), this, SLOT (model_folder_renamed (lay::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_folder (lay::MacroCollection *, lay::MacroCollection *)), this, SLOT (model_move_folder (lay::MacroCollection *, lay::MacroCollection *)));
connect (mp_model, SIGNAL (macro_renamed (lym::Macro *)), this, SLOT (model_macro_renamed (lym::Macro *)));
connect (mp_model, SIGNAL (folder_renamed (lym::MacroCollection *)), this, SLOT (model_folder_renamed (lym::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 (lym::MacroCollection *, lym::MacroCollection *)), this, SLOT (model_move_folder (lym::MacroCollection *, lym::MacroCollection *)));
}
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 ())) {
QObject *object = (QObject *) i.internalPointer ();
lay::Macro *macro = dynamic_cast <lay::Macro *> (object);
lay::MacroCollection *mc = dynamic_cast <lay::MacroCollection *> (object);
lym::Macro *macro = dynamic_cast <lym::Macro *> (object);
lym::MacroCollection *mc = dynamic_cast <lym::MacroCollection *> (object);
if (macro) {
emit macro_double_clicked (macro);

View File

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

View File

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

View File

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

View File

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

View File

@ -30,9 +30,9 @@
#include "layMainWindow.h"
#include "layApplication.h"
#include "layMacroEditorTree.h"
#include "layMacro.h"
#include "layMacroController.h"
#include "layTechnologyController.h"
#include "lymMacro.h"
#include "tlAssert.h"
#include "tlStream.h"
#include "dbStream.h"
@ -362,17 +362,17 @@ TechMacrosPage::setup ()
QString cp = macro_dir.canonicalPath ();
// if a macro collection already exists, show a readonly copy of this one
const lay::MacroCollection *original = 0;
const lay::MacroCollection *root = &lay::MacroCollection::root ();
for (lay::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) {
const lym::MacroCollection *original = 0;
const lym::MacroCollection *root = &lym::MacroCollection::root ();
for (lym::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! original; ++m) {
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;
}
}
const lay::MacroCollection *alt = 0;
for (lay::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) {
const lym::MacroCollection *alt = 0;
for (lym::MacroCollection::const_child_iterator m = root->begin_children (); m != root->end_children () && ! alt; ++m) {
if (m->second->virtual_mode () != lym::MacroCollection::TechFolder && QDir (tl::to_qstring (m->second->path ())).canonicalPath () == cp) {
alt = m->second;
}
}
@ -435,7 +435,7 @@ TechMacrosPage::setup ()
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);
mc->add_folder (desc, mp, m_cat, true);
m_current_path = mp;
@ -469,10 +469,10 @@ END_PROTECTED
void
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 ());
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) {

View File

@ -38,12 +38,17 @@
#include <memory>
namespace lym
{
class Macro;
class MacroCollection;
}
namespace lay
{
class TechnologyComponentEditor;
class Technology;
class MacroCollection;
class TechBaseEditorPage
: public TechnologyComponentEditor,
@ -78,7 +83,7 @@ public:
private:
std::string m_cat, m_cat_desc;
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;
private slots:

View File

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

View File

@ -24,9 +24,9 @@
#include "gsiDecl.h"
#include "gsiDeclBasic.h"
#include "gsiInterpreter.h"
#include "layMacroInterpreter.h"
#include "layMacro.h"
#include "layApplication.h"
#include "lymMacroInterpreter.h"
#include "lymMacro.h"
#include "rba.h"
#include "tlClassRegistry.h"
@ -37,7 +37,7 @@ namespace tl
// type traits for BrowserDialog_Stub
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;
};
@ -51,17 +51,23 @@ class MacroExecutionContext
public:
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 ()
{
lay::Application::instance ()->ruby_interpreter ().remove_debugger_scope ();
if (rba::RubyInterpreter::instance ()) {
rba::RubyInterpreter::instance ()->remove_debugger_scope ();
}
}
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
: public lay::MacroInterpreter
: public lym::MacroInterpreter
{
public:
MacroInterpreter ()
: lay::MacroInterpreter (),
: lym::MacroInterpreter (),
mp_registration (0)
{
m_suffix = lay::MacroInterpreter::suffix ();
m_description = lay::MacroInterpreter::description ();
m_storage_scheme = lay::MacroInterpreter::storage_scheme ();
m_syntax_scheme = lay::MacroInterpreter::syntax_scheme ();
m_debugger_scheme = lay::MacroInterpreter::debugger_scheme ();
m_suffix = lym::MacroInterpreter::suffix ();
m_description = lym::MacroInterpreter::description ();
m_storage_scheme = lym::MacroInterpreter::storage_scheme ();
m_syntax_scheme = lym::MacroInterpreter::syntax_scheme ();
m_debugger_scheme = lym::MacroInterpreter::debugger_scheme ();
}
~MacroInterpreter ()
{
delete mp_registration;
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;
}
m_templates.clear ();
@ -121,34 +127,34 @@ public:
// cancel any previous registration and register (again)
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;
}
virtual void execute (const lay::Macro *macro) const
virtual void execute (const lym::Macro *macro) const
{
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)
{
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;
}
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;
}
@ -183,28 +189,28 @@ public:
return m_suffix;
}
lay::Macro *create_template (const std::string &name)
lym::Macro *create_template (const std::string &name)
{
if (! mp_registration) {
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->set_readonly (true);
m->set_dsl_interpreter (m_name);
m->set_interpreter (lay::Macro::DSLInterpreter);
m->set_interpreter (lym::Macro::DSLInterpreter);
m->set_format (storage_scheme ());
m_templates.push_back (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) {
tt.push_back (new lay::Macro ());
for (std::vector<lym::Macro *>::const_iterator t = m_templates.begin (); t != m_templates.end (); ++t) {
tt.push_back (new lym::Macro ());
tt.back ()->rename ((*t)->name ());
tt.back ()->assign (**t);
}
@ -213,39 +219,39 @@ public:
gsi::Callback f_execute;
private:
tl::RegisteredClass <lay::MacroInterpreter> *mp_registration;
tl::RegisteredClass <lym::MacroInterpreter> *mp_registration;
std::string m_name;
std::vector<lay::Macro *> m_templates;
std::vector<lym::Macro *> m_templates;
std::string m_syntax_scheme;
lay::Macro::Format m_storage_scheme;
lay::Macro::Interpreter m_debugger_scheme;
lym::Macro::Format m_storage_scheme;
lym::Macro::Interpreter m_debugger_scheme;
std::string m_suffix;
std::string m_description;
};
int const_PlainTextFormat ()
{
return int (lay::Macro::PlainTextFormat);
return int (lym::Macro::PlainTextFormat);
}
int const_PlainTextWithHashAnnotationsFormat ()
{
return int (lay::Macro::PlainTextWithHashAnnotationsFormat);
return int (lym::Macro::PlainTextWithHashAnnotationsFormat);
}
int const_MacroFormat ()
{
return int (lay::Macro::MacroFormat);
return int (lym::Macro::MacroFormat);
}
int const_RubyDebugger ()
{
return int (lay::Macro::Ruby);
return int (lym::Macro::Ruby);
}
int const_NoDebugger ()
{
return int (lay::Macro::None);
return int (lym::Macro::None);
}
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"
);
Class<lay::Macro> decl_Macro ("Macro",
gsi::method ("path", &lay::Macro::path,
Class<lym::Macro> decl_Macro ("Macro",
gsi::method ("path", &lym::Macro::path,
"@brief Gets the path of the macro\n"
"\n"
"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."
) +
gsi::method ("description", &lay::Macro::description,
gsi::method ("description", &lym::Macro::description,
"@brief Gets the description text\n"
"\n"
"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 "
"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"
"@args description\n"
"@param description The description text.\n"
"See \\description for details.\n"
) +
gsi::method ("prolog", &lay::Macro::prolog,
gsi::method ("prolog", &lym::Macro::prolog,
"@brief Gets the prolog code\n"
"\n"
"The prolog is executed before the actual code is executed. Interpretation depends on the "
"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"
"@args string\n"
"See \\prolog for details.\n"
) +
gsi::method ("epilog", &lay::Macro::epilog,
gsi::method ("epilog", &lym::Macro::epilog,
"@brief Gets the epilog code\n"
"\n"
"The epilog is executed after the actual code is executed. Interpretation depends on the "
"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"
"@args string\n"
"See \\epilog for details.\n"
) +
gsi::method ("category", &lay::Macro::category,
gsi::method ("category", &lym::Macro::category,
"@brief Gets the category tags\n"
"\n"
"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."
) +
gsi::method ("category=", &lay::Macro::set_category,
gsi::method ("category=", &lym::Macro::set_category,
"@brief Sets the category tags string\n"
"@args string\n"
"See \\category for details.\n"
) +
gsi::method ("text", &lay::Macro::text,
gsi::method ("text", &lym::Macro::text,
"@brief Gets the macro text\n"
"\n"
"The text is the code executed by the macro interpreter. "
"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"
"@args string\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"
) +
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"
"@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"
"\n"
"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."
) +
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"
"@args string\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"
"\n"
"If a menu path is specified and \\show_in_menu? is true, the macro will appear in "
"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"
"@args string\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 "layMacroInterpreter.h"
#include "layMainWindow.h"
#include "layAbstractMenu.h"
#include "layApplication.h"
#include "lymMacro.h"
#include "lymMacroInterpreter.h"
#include "tlExceptions.h"
#include "gsiDecl.h"
#include "gsiInterpreter.h"
#include "tlString.h"
#include "tlStableVector.h"
#include "tlClassRegistry.h"
#include "tlLog.h"
#include "tlXMLParser.h"
#include "rba.h"
#include "pya.h"
#include <QFile>
#include <QDir>
#include <QUrl>
@ -43,7 +44,7 @@
#include <fstream>
#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_version = other.m_version;
@ -169,7 +170,7 @@ struct Interpreter2s
/**
* @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::version, &Macro::set_version, "version") +
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 ()) {
// 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) {
@ -523,23 +524,23 @@ const std::string &Macro::text () const
struct PropertyField
{
const char *name;
const std::string &(lay::Macro::*string_getter) () const;
void (lay::Macro::*string_setter) (const std::string &);
bool (lay::Macro::*bool_getter) () const;
void (lay::Macro::*bool_setter) (bool);
const std::string &(lym::Macro::*string_getter) () const;
void (lym::Macro::*string_setter) (const std::string &);
bool (lym::Macro::*bool_getter) () const;
void (lym::Macro::*bool_setter) (bool);
};
static PropertyField property_fields[] = {
{ "description", &lay::Macro::description, &lay::Macro::set_description, 0, 0 },
{ "prolog", &lay::Macro::prolog, &lay::Macro::set_prolog, 0, 0 },
{ "epilog", &lay::Macro::epilog, &lay::Macro::set_epilog, 0, 0 },
{ "version", &lay::Macro::version, &lay::Macro::set_version, 0, 0 },
{ "autorun", 0, 0, &lay::Macro::is_autorun, &lay::Macro::set_autorun },
{ "autorun-early", 0, 0, &lay::Macro::is_autorun_early, &lay::Macro::set_autorun_early},
{ "show-in-menu", 0, 0, &lay::Macro::show_in_menu, &lay::Macro::set_show_in_menu },
{ "group-name", &lay::Macro::group_name, &lay::Macro::set_group_name, 0, 0 },
{ "menu-path", &lay::Macro::menu_path, &lay::Macro::set_menu_path, 0, 0 },
{ "shortcut", &lay::Macro::shortcut, &lay::Macro::set_shortcut, 0, 0 }
{ "description", &lym::Macro::description, &lym::Macro::set_description, 0, 0 },
{ "prolog", &lym::Macro::prolog, &lym::Macro::set_prolog, 0, 0 },
{ "epilog", &lym::Macro::epilog, &lym::Macro::set_epilog, 0, 0 },
{ "version", &lym::Macro::version, &lym::Macro::set_version, 0, 0 },
{ "autorun", 0, 0, &lym::Macro::is_autorun, &lym::Macro::set_autorun },
{ "autorun-early", 0, 0, &lym::Macro::is_autorun_early, &lym::Macro::set_autorun_early},
{ "show-in-menu", 0, 0, &lym::Macro::show_in_menu, &lym::Macro::set_show_in_menu },
{ "group-name", &lym::Macro::group_name, &lym::Macro::set_group_name, 0, 0 },
{ "menu-path", &lym::Macro::menu_path, &lym::Macro::set_menu_path, 0, 0 },
{ "shortcut", &lym::Macro::shortcut, &lym::Macro::set_shortcut, 0, 0 }
};
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
{
if (interpreter () == lay::Macro::Ruby) {
return (lay::Application::instance ()->ruby_interpreter ().available ());
} else if (interpreter () == lay::Macro::Python) {
return (lay::Application::instance ()->python_interpreter ().available ());
} else if (interpreter () == lay::Macro::DSLInterpreter) {
return lay::MacroInterpreter::can_run (this);
gsi::Interpreter *ip = script_interpreter (interpreter ());
if (ip) {
return true;
} else if (interpreter () == lym::Macro::DSLInterpreter) {
return lym::MacroInterpreter::can_run (this);
} else {
return false;
}
@ -962,24 +976,17 @@ int Macro::run () const
}
try {
if (interpreter () == lay::Macro::Ruby) {
gsi::Interpreter *ip = script_interpreter (interpreter ());
if (ip) {
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 ()) {
lay::Application::instance ()->ruby_interpreter ().eval_string (epilog ().c_str ());
ip->eval_string (epilog ().c_str ());
}
} else if (interpreter () == lay::Macro::Python) {
if (! prolog ().empty ()) {
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);
} else if (interpreter () == lym::Macro::DSLInterpreter) {
lym::MacroInterpreter::execute_macro (this);
}
} catch (tl::ExitException &ex) {
return ex.status ();
@ -1356,7 +1363,7 @@ void MacroCollection::scan (const std::string &path)
filters << QString::fromUtf8 ("*.py");
// 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 ()) {
filters << tl::to_qstring ("*." + cls->suffix ());
}
@ -1365,7 +1372,7 @@ void MacroCollection::scan (const std::string &path)
QStringList files = dir.entryList (filters, QDir::Files);
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 {
@ -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) {
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) {
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;
int n = 0;
@ -1541,7 +1548,7 @@ lay::MacroCollection *MacroCollection::create_folder (const char *prefix, bool m
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_name (name);
m->set_parent (this);
@ -1551,7 +1558,7 @@ lay::MacroCollection *MacroCollection::create_folder (const char *prefix, bool 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;
int n = 0;
@ -1568,7 +1575,7 @@ lay::Macro *MacroCollection::create (const char *prefix, Macro::Format format)
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_parent (this);
@ -1577,7 +1584,7 @@ lay::Macro *MacroCollection::create (const char *prefix, Macro::Format format)
return m;
}
void MacroCollection::add_unspecific (lay::Macro *m)
void MacroCollection::add_unspecific (lym::Macro *m)
{
begin_changes ();
m_macros.insert (std::make_pair (m->name (), m));
@ -1585,7 +1592,7 @@ void MacroCollection::add_unspecific (lay::Macro *m)
on_changed ();
}
bool MacroCollection::add (lay::Macro *m)
bool MacroCollection::add (lym::Macro *m)
{
QDir d (tl::to_qstring (path ()));
QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir ();
@ -1618,7 +1625,7 @@ bool MacroCollection::add (lay::Macro *m)
if (dm == d) {
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_parent (this);
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) {
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) {
lay::Macro *macro = mc->second->find_macro (path);
lym::Macro *macro = mc->second->find_macro (path);
if (macro) {
return macro;
}
@ -1676,7 +1683,7 @@ MacroCollection &MacroCollection::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;
@ -1684,18 +1691,18 @@ static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *ac
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) {
lay::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0;
for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) {
lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0;
if (! cm) {
folders_to_delete.push_back (m->second);
}
}
if (actual) {
for (lay::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) {
lay::MacroCollection *cm = current->folder_by_name (m->first);
for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) {
lym::MacroCollection *cm = current->folder_by_name (m->first);
if (! cm) {
cm = current->create_folder (m->first.c_str (), false);
ret = true;
@ -1707,24 +1714,24 @@ static bool sync_macros (lay::MacroCollection *current, lay::MacroCollection *ac
}
// 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;
sync_macros (*m, 0);
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) {
lay::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0;
for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) {
lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0;
if (! cm) {
macros_to_delete.push_back (m->second);
}
}
if (actual) {
for (lay::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) {
lay::Macro *cm = current->macro_by_name (m->first, m->second->format ());
for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) {
lym::Macro *cm = current->macro_by_name (m->first, m->second->format ());
if (cm) {
if (*cm != *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
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);
ret = true;
}
@ -1752,8 +1759,8 @@ void MacroCollection::reload ()
{
// create a new collection and synchronize
lay::MacroCollection new_collection;
for (lay::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) {
lym::MacroCollection new_collection;
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 */);
}
@ -1761,15 +1768,15 @@ void MacroCollection::reload ()
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)) {
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 ())) {
return true;
}
@ -1783,13 +1790,13 @@ bool MacroCollection::has_autorun () const
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);
}
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 ()) {
BEGIN_PROTECTED_SILENT
c->second->install_doc ();

View File

@ -21,10 +21,10 @@
*/
#ifndef HDR_layMacro
#define HDR_layMacro
#ifndef HDR_lymMacro
#define HDR_lymMacro
#include "layCommon.h"
#include "lymCommon.h"
#include <string>
#include <map>
@ -32,7 +32,7 @@
#include <QObject>
namespace lay
namespace lym
{
class MacroCollection;
@ -54,7 +54,7 @@ class MacroCollection;
* a macro can be bound to an arbitrary interpreter and decides
* by itself which interpreter to use.
*/
class LAY_PUBLIC Macro
class LYM_PUBLIC Macro
: public QObject
{
Q_OBJECT
@ -132,14 +132,14 @@ public:
* This will assign the definition of the macro but keep the name.
* 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
*
* Returns 0, if there is no parent of this collection (this is the root)
*/
lay::MacroCollection *parent ()
lym::MacroCollection *parent ()
{
return mp_parent;
}
@ -149,7 +149,7 @@ public:
*
* 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;
}
@ -594,7 +594,7 @@ private:
std::string m_menu_path;
std::string m_shortcut;
bool m_is_file;
lay::MacroCollection *mp_parent;
lym::MacroCollection *mp_parent;
Interpreter m_interpreter;
std::string m_dsl_interpreter;
Format m_format;
@ -613,7 +613,7 @@ private:
m_name = name;
}
void set_parent (lay::MacroCollection *parent)
void set_parent (lym::MacroCollection *parent)
{
mp_parent = parent;
}
@ -629,7 +629,7 @@ private:
* A collection is representing a set of macros, usually associated with
* a folder containing *.lym, *.rb or other script files.
*/
class LAY_PUBLIC MacroCollection
class LYM_PUBLIC MacroCollection
: public QObject
{
Q_OBJECT
@ -732,7 +732,7 @@ public:
*
* Returns 0, if there is no parent of this collection (this is the root)
*/
lay::MacroCollection *parent ()
lym::MacroCollection *parent ()
{
return mp_parent;
}
@ -742,7 +742,7 @@ public:
*
* 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;
}
@ -825,7 +825,7 @@ public:
*
* @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
@ -835,7 +835,7 @@ public:
* This is a way to build macro collections without connection
* 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
@ -843,7 +843,7 @@ public:
* This does not remove the file but just remove 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
@ -856,7 +856,7 @@ public:
* This does not remove the directory but just removes 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
@ -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.
*/
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)
@ -877,7 +877,7 @@ public:
* This method will also create the directory for this folder.
* 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
@ -977,7 +977,7 @@ public:
* This method is called from the root collection and delivers the macro which
* 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
@ -1027,22 +1027,22 @@ signals:
/**
* @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
*/
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
*/
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
*/
void macro_deleted (Macro *);
void macro_deleted (lym::Macro *);
/**
* @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
* 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
@ -1058,7 +1058,7 @@ signals:
* This signal is only emitted by the root, but it may originate from a
* 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
@ -1078,7 +1078,7 @@ private:
std::string m_category;
std::multimap <std::string, Macro *> m_macros;
std::map <std::string, MacroCollection *> m_folders;
lay::MacroCollection *mp_parent;
lym::MacroCollection *mp_parent;
int m_virtual_mode;
bool m_readonly;
@ -1105,7 +1105,7 @@ private:
m_path = n;
}
void set_parent (lay::MacroCollection *parent)
void set_parent (lym::MacroCollection *parent)
{
mp_parent = parent;
}
@ -1125,7 +1125,7 @@ private:
*
* This class allows to call a macro from a signal
*/
class MacroSignalAdaptor
class LYM_PUBLIC MacroSignalAdaptor
: public QObject
{
Q_OBJECT

View File

@ -21,26 +21,26 @@
*/
#include "layMacroInterpreter.h"
#include "layMacro.h"
#include "lymMacroInterpreter.h"
#include "lymMacro.h"
#include "tlInternational.h"
#include "tlException.h"
#include "tlClassRegistry.h"
namespace lay
namespace lym
{
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")));
}
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 ()) {
return true;
}
@ -49,9 +49,9 @@ MacroInterpreter::can_run (const lay::Macro *macro)
}
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 ()) {
cls->execute (macro);
return;
@ -64,7 +64,7 @@ MacroInterpreter::execute_macro (const lay::Macro *macro)
std::string
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) {
return cls->syntax_scheme ();
}
@ -76,7 +76,7 @@ MacroInterpreter::syntax_scheme (const std::string &dsl_name)
Macro::Format
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) {
return cls->storage_scheme ();
}
@ -88,7 +88,7 @@ MacroInterpreter::storage_scheme (const std::string &dsl_name)
Macro::Interpreter
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) {
return cls->debugger_scheme ();
}
@ -100,7 +100,7 @@ MacroInterpreter::debugger_scheme (const std::string &dsl_name)
std::string
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) {
return cls->description ();
}
@ -112,7 +112,7 @@ MacroInterpreter::description (const std::string &dsl_name)
std::string
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) {
return cls->suffix ();
}
@ -125,6 +125,6 @@ MacroInterpreter::suffix (const std::string &dsl_name)
namespace tl
{
template<> tl::Registrar<lay::MacroInterpreter> *Registrar<lay::MacroInterpreter>::instance = 0;
template class LAY_PUBLIC tl::RegisteredClass<lay::MacroInterpreter>;
template<> LYM_PUBLIC tl::Registrar<lym::MacroInterpreter> *Registrar<lym::MacroInterpreter>::instance = 0;
template class LYM_PUBLIC tl::RegisteredClass<lym::MacroInterpreter>;
}

View File

@ -21,20 +21,20 @@
*/
#ifndef HDR_layMacroInterpreter
#define HDR_layMacroInterpreter
#ifndef HDR_lymMacroInterpreter
#define HDR_lymMacroInterpreter
#include "layCommon.h"
#include "lymCommon.h"
#include "gsiObject.h"
#include "tlClassRegistry.h"
#include "layMacro.h"
#include "lymMacro.h"
#include <string>
#include <vector>
namespace lay
namespace lym
{
/**
@ -50,7 +50,7 @@ namespace lay
* tl::RegisteredClass.
*/
class LAY_PUBLIC MacroInterpreter
class LYM_PUBLIC MacroInterpreter
: public gsi::ObjectBase
{
public:
@ -67,7 +67,7 @@ public:
*
* 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
@ -75,7 +75,7 @@ public:
* 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.
*/
virtual lay::Macro::Format storage_scheme () const
virtual lym::Macro::Format storage_scheme () const
{
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
* 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 ..
}
@ -144,12 +144,12 @@ public:
* This method locates the DSL interpreter with the given name and
* 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
*/
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

View File

@ -2,7 +2,7 @@
DESTDIR=$$OUT_PWD/..
include($$PWD/../klayout.pri)
include($$PWD/../unit_tests.pri)
include($$PWD/../with_all_libs.pri)
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
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
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/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
# shadow builds: