Class: QML::PluginLoader
- Inherits:
-
Object
- Object
- QML::PluginLoader
- Defined in:
- lib/qml/plugin_loader.rb,
ext/qml/plugin_loader.c
Overview
PluginLoader loads Qt C++ plugins and enables you to use your Qt C++ codes from Ruby easily.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, libname = nil) ⇒ PluginLoader
constructor
A new instance of PluginLoader.
-
#instance ⇒ QML::JSObject
Loads the plugin and returns the instance of the plugin.
Constructor Details
#initialize(path) ⇒ PluginLoader #initialize(dir, libname) ⇒ PluginLoader
Returns a new instance of PluginLoader.
18 19 20 21 |
# File 'lib/qml/plugin_loader.rb', line 18 def initialize(path, libname = nil) path = Pathname(path) + self.class.lib_filename(libname) if libname initialize_impl(path.to_s) end |
Class Method Details
Instance Method Details
#instance ⇒ QML::JSObject
Loads the plugin and returns the instance of the plugin.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'ext/qml/plugin_loader.c', line 46
static VALUE plugin_loader_instance(VALUE self) {
qmlbind_plugin plugin = rbqml_get_plugin(self);
qmlbind_string qmlerror = qmlbind_plugin_get_error_string(plugin);
if (qmlerror) {
VALUE errorStr = rb_enc_str_new(qmlbind_string_get_chars(qmlerror), qmlbind_string_get_length(qmlerror), rb_utf8_encoding());
qmlbind_string_release(qmlerror);
VALUE error = rb_funcall(cPluginError, rb_intern("new"), 1, errorStr);
rb_exc_raise(error);
}
qmlbind_value loaded = qmlbind_plugin_get_instance(plugin, rbqml_get_engine(rbqml_engine));
return rbqml_to_ruby(loaded);
}
|