// Clint - Source code checker for C++
// Copyright (C) 2001 David Pashley
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "python_rule.h"
#include <debug.h>
PythonRule::PythonRule() : m_class(Py_None) {
interpreter = python::Python::Instance();
}
void PythonRule::initialize() {
python::Tuple args;
m_class.run_method("initialize",args);
}
void PythonRule::finalize() {
python::Tuple args;
m_class.run_method("finalize",args);
}
void PythonRule::pre_cpp(std::string line) {
m_class.run_method("pre_cpp","(s)",line.c_str());
}
void PythonRule::post_cpp(std::string line) {
m_class.run_method("post_cpp","(s)",line.c_str());
}
void PythonRule::load_module(std::string filename) {
python::Tuple args;
std::string module_name(filename,0,filename.rfind("."));
DEBUG("loading " << module_name << " from " << filename);
python::Module module = interpreter->load_module(module_name);
m_class = module.run_method(module_name, args);
}
syntax highlighted by Code2HTML, v. 0.9.1