- Removed Fallback::Constructor prototype since now Fallback are constructed
just like any regular Widget.
- Renamed Widget::Constructor and Widget::Destructor in modules to
bife_widget_constructor and bife_widget_destructor.
- Added some more check to dynamic object creation in Parser.
/**
* Base Container Class.
*
/**
* Base Container Class.
*
-Fallback::Fallback(const string& name): name(name) {
+Fallback::Fallback(void) {
- cerr << "In Fallback::Fallback(name = '" << name << "');" << endl;
+ cerr << "In Fallback::Fallback();" << endl;
-Fallback::Fallback(const string& name, const Hash& attrs):
- Container(attrs), name(name) {
+Fallback::Fallback(const Hash& attrs): Container(attrs) {
- cerr << "In Fallback::Fallback(name = '" << name
- << "', attrs = {" /* TODO << attrs */ << "});" << endl;
+ cerr << "In Fallback::Fallback(attrs = {" /* TODO << attrs */ << "});" << endl;
-Fallback::Fallback(const string& name, const Hash& attrs, Widget* content):
- Container(attrs, content), name(name) {
+Fallback::Fallback(const Hash& attrs, Widget* content): Container(attrs, content) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name
- << "', attrs = {" /* TODO << attrs */
+ cerr << "In Fallback::Fallback(attrs = {" /* TODO << attrs */
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
-Fallback::Fallback(const string& name, Widget* content, const Hash& attrs):
- Container(content, attrs), name(name) {
+Fallback::Fallback(Widget* content, const Hash& attrs): Container(content, attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Fallback::Fallback(name = '" << name
- << "', content = {" /* TODO << content */
+ cerr << "In Fallback::Fallback(content = {" /* TODO << content */
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
// Typedefs
public:
/// Fallback constructor function prototype.
// Typedefs
public:
/// Fallback constructor function prototype.
- typedef Fallback* Constructor(const string&, const string&, const Hash&);
+ //typedef Fallback* Constructor(const string&, const string&, const Hash&);
*
* @param name Name of the widget.
*/
*
* @param name Name of the widget.
*/
- Fallback(const string&);
* @param name Name of the widget.
* @param attrs Widget attributes.
*/
* @param name Name of the widget.
* @param attrs Widget attributes.
*/
- Fallback(const string&, const Hash&);
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Fallback(const string&, const Hash&, Widget*);
+ Fallback(const Hash&, Widget*);
* @param name Name of the widget.
* @param content Content of the widget.
*/
* @param name Name of the widget.
* @param content Content of the widget.
*/
- Fallback(const string&, Widget*);
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Fallback(const string&, Widget*, const Hash&);
+ Fallback(Widget*, const Hash&);
if (fbClass.empty()) {
throw string("Widget '") + name + "' not found and now using a fallback class.";
} else {
if (fbClass.empty()) {
throw string("Widget '") + name + "' not found and now using a fallback class.";
} else {
- stack.push(fbNew(fbClass, name, attrs));
+ Fallback* fb;
+ try {
+ fb = dynamic_cast<Fallback*>(fbNew(fbClass, attrs));
+ if (!fb) {
+ throw string("Fallback widget '") + fbClass + " not found!";
+ }
+ } catch (...) {
+ throw fbClass + " is not a Fallback Widget!";
+ }
+ fb->name = name;
+ stack.push(fb);
if (!dlh) {
throw string("No se puede cargar el plug-in: ") + dlerror();
}
if (!dlh) {
throw string("No se puede cargar el plug-in: ") + dlerror();
}
- fbNew = (Fallback::Constructor*)dlsym(dlh, "fallback_constructor");
- fbDel = (Widget::Destructor*)dlsym(dlh, "widget_destructor");
+ fbNew = (Widget::Constructor*)dlsym(dlh, "bife_widget_constructor");
+ fbDel = (Widget::Destructor*)dlsym(dlh, "bife_widget_destructor");
if (!fbNew || !fbDel) {
throw string("No se puede cargar el creador del plug-in: ") + dlerror();
}
if (!fbNew || !fbDel) {
throw string("No se puede cargar el creador del plug-in: ") + dlerror();
}
-Translate::Translate(const string& name): Fallback(name) {
+Translate::Translate(void) {
- cerr << "In Translate::Translate(name = '" << name << "');" << endl;
+ cerr << "In Translate::Translate();" << endl;
-Translate::Translate(const string& name, const Hash& attrs): Fallback(name, attrs) {
+Translate::Translate(const Hash& attrs): Fallback(attrs) {
- cerr << "In Translate::Translate(name = '" << name
- << "', attrs = {" /* TODO << attrs */ << "});" << endl;
+ cerr << "In Translate::Translate(attrs = {" /* TODO << attrs */ << "});" << endl;
-Translate::Translate(const string& name, const Hash& attrs, Widget* content):
- Fallback(name, attrs, content) {
+Translate::Translate(const Hash& attrs, Widget* content): Fallback(attrs, content) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name
- << "', attrs = {" /* TODO << attrs */
+ cerr << "In Translate::Translate(attrs = {" /* TODO << attrs */
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
<< "}, content = {" /* TODO << content */ << "});" << endl;
#endif
}
-Translate::Translate(const string& name, Widget* content, const Hash& attrs):
- Fallback(name, content, attrs) {
+Translate::Translate(Widget* content, const Hash& attrs): Fallback(content, attrs) {
// FIXME - this->content.push_back(content);
#ifdef DEBUG
// FIXME - this->content.push_back(content);
#ifdef DEBUG
- cerr << "In Translate::Translate(name = '" << name
- << "', content = {" /* TODO << content */
+ cerr << "In Translate::Translate(content = {" /* TODO << content */
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
<< "}, attrs = {" /* TODO << attrs */ << "});" << endl;
#endif
}
public:
/**
* Constructor.
public:
/**
* Constructor.
- *
- * @param name Name of the widget.
- Translate(const string&);
- * @param name Name of the widget.
* @param attrs Widget attributes.
*/
* @param attrs Widget attributes.
*/
- Translate(const string&, const Hash&);
+ Translate(const Hash&);
- * @param name Name of the widget.
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
* @param attrs Widget attributes.
* @param content Content of the widget.
*/
- Translate(const string&, const Hash&, Widget*);
+ Translate(const Hash&, Widget*);
- * @param name Name of the widget.
* @param content Content of the widget.
*/
* @param content Content of the widget.
*/
- Translate(const string&, Widget*);
- * @param name Name of the widget.
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
* @param content Content of the widget.
* @param attrs Widget attributes.
*/
- Translate(const string&, Widget*, const Hash&);
+ Translate(Widget*, const Hash&);
- * Fallback constructor.
- * @param classname Name of the class to construct.
- * @param widgetname Name of the widget to construct.
- * @param attrs Widget's attributes.
- * @return A new Fallback widget.
+ * @param name Name of the widget to construct.
+ * @param attrs Widget's attributes.
+ * @return A new Widget.
-Fallback* fallback_constructor(const string& classname, const string& widgetname, const Hash& attrs) {
- string cn = classname;
+Widget* bife_widget_constructor(const string& name, const Hash& attrs) {
+ string cn = name;
std::transform(cn.begin(), cn.end(), cn.begin(), std::tolower);
if (cn == "translate") {
std::transform(cn.begin(), cn.end(), cn.begin(), std::tolower);
if (cn == "translate") {
- return new Translate(widgetname, attrs);
+ return new Translate(attrs);
* @param w The widget to destroy.
*/
extern "C"
* @param w The widget to destroy.
*/
extern "C"
-void widget_destructor(Widget* w) {
+void bife_widget_destructor(Widget* w) {