Beispiel #1
0
void GLWidget::onInputEvent(caValue* event)
{
    scripts_pre_message_send();

    caValue* msg = circa_alloc_list(2);

    circa_set_string(circa_index(msg, 0), "onInputEvent");

    circa_move(event, circa_index(msg, 1));
    circa_dealloc_value(event);

    circa_actor_run_message(g_world, "View", msg);

    circa_dealloc_value(msg);
    scripts_post_message_send();
}
Beispiel #2
0
int main(int argc, char** argv)
{
    caWorld* world = circa_initialize();

    circa_load_module_from_file(world, "ClassA", "ClassA.ca");

    // circa_dump_b(circa_kernel(world));

    caStack* stack = circa_alloc_stack(world);

    circa_push_function_by_name(stack, "create_ClassA");
    circa_run(stack);

    if (circa_has_error(stack))
        circa_print_error_to_stdout(stack);

    caValue* classA = circa_alloc_value();
    circa_move(circa_output(stack, 0), classA);
    circa_pop(stack);

    // Dump to stdout
    circa_push_function_by_name(stack, "ClassA.dump");
    circa_copy(classA, circa_input(stack, 0));
    circa_run(stack);
    if (circa_has_error(stack))
        circa_print_error_to_stdout(stack);
    circa_pop(stack);

    for (int i=0; i < 5; i++) {
        // Increment
        circa_push_function_by_name(stack, "ClassA.increment");
        circa_copy(classA, circa_input(stack, 0));
        circa_run(stack);
        if (circa_has_error(stack))
            circa_print_error_to_stdout(stack);

        // Using index #1 not 0:
        circa_move(circa_output(stack, 1), classA);
        circa_pop(stack);

        // And dump
        circa_push_function_by_name(stack, "ClassA.dump");
        circa_copy(classA, circa_input(stack, 0));
        circa_run(stack);
        if (circa_has_error(stack))
            circa_print_error_to_stdout(stack);
        circa_pop(stack);
    }

    circa_dealloc_value(classA);
    circa_dealloc_stack(stack);
    circa_shutdown(world);
}
Beispiel #3
0
static void after_write(uv_write_t* req, int status) {

    Value* msg = (Value*) req->data;
    circa_dealloc_value(msg);
    req->data = NULL;

    if (status == 0)
        return;

    printf("uv_write error: %s\n", uv_err_name(uv_last_error(req->handle->loop)));

    if (status == UV_ECANCELED)
        return;
#if 0
    uv_close((uv_handle_t*)req->handle, on_close);
#endif
}
Beispiel #4
0
void GLWidget::paintEvent(QPaintEvent*)
{
    QPainter painter;
    painter.begin(this);
    painter.setRenderHint(QPainter::Antialiasing);

    scripts_pre_message_send();

    // call onPaintEvent
    caValue* msg = circa_alloc_list(2);

    circa_set_string(circa_index(msg, 0), "onPaintEvent");
    circa_set_typed_pointer(circa_index(msg, 1),
        circa_find_type(NULL, "Painter"), &painter);

    circa_actor_run_message(g_world, "View", msg);

    circa_dealloc_value(msg);

    scripts_post_message_send();

    painter.end();
}