Class: QML::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/qml/engine.rb,
lib/qml/engine.rb,
ext/qml/engine.c

Overview

Engine provides a QML engine.

See Also:

Instance Method Summary collapse

Instance Method Details

#add_import_path(path) ⇒ Object

Adds a QML import path to the QML::Engine.



49
50
51
52
53
54
# File 'ext/qml/engine.c', line 49

static VALUE engine_add_import_path(VALUE self, VALUE path) {
    qmlbind_engine engine = rbqml_get_engine(self);
    path = rb_funcall(path, rb_intern("to_s"), 0);
    qmlbind_engine_add_import_path(engine, rb_string_value_cstr(&path));
    return self;
}

#collect_garbageObject

Starts garbage collection on the QML::Engine.



115
116
117
118
119
# File 'ext/qml/engine.c', line 115

static VALUE engine_collect_garbage(VALUE self) {
    qmlbind_engine engine = rbqml_get_engine(self);
    qmlbind_engine_collect_garbage(engine);
    return self;
}

#evaluate(str, file = '<in QML::Engine#evaluate>', lineno = 1) ⇒ Object

Evaluates an JavaScript expression

Parameters:

  • str (String)

    The JavaScript string

  • file (String) (defaults to: '<in QML::Engine#evaluate>')

    The file name

  • lineno (Integer) (defaults to: 1)

    The line number



13
14
15
16
17
# File 'lib/qml/engine.rb', line 13

def evaluate(str, file = '<in QML::Engine#evaluate>', lineno = 1)
  evaluate_impl(str, file, lineno).tap do |result|
    raise result.to_error if result.is_a?(JSObject) && result.error?
  end
end

#new_array(len) ⇒ QML::JSArray

Returns:



89
90
91
92
93
94
95
96
97
# File 'ext/qml/engine.c', line 89

static VALUE engine_new_array(VALUE self, VALUE len) {
    qmlbind_engine engine = rbqml_get_engine(self);

    qmlbind_value array = qmlbind_engine_new_array(engine, NUM2INT(len));
    VALUE value = rbqml_js_object_new(rbqml_cJSArray, array);
    qmlbind_value_release(array);

    return value;
}

#new_objectQML::JSObject

Returns:



102
103
104
105
106
107
108
109
110
# File 'ext/qml/engine.c', line 102

static VALUE engine_new_object(VALUE self) {
    qmlbind_engine engine = rbqml_get_engine(self);

    qmlbind_value obj = qmlbind_engine_new_object(engine);
    VALUE value = rbqml_js_object_new(rbqml_cJSObject, obj);
    qmlbind_value_release(obj);

    return value;
}