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); }
void ImprovWindow::redraw() { #ifndef NACL circa_update_changed_files(_world); #endif if (_width == 0 && _height == 0) { printf("error: App::redraw() called before setSize()\n"); return; } double startTime = get_time(); glClear( GL_COLOR_BUFFER_BIT /*| GL_DEPTH_BUFFER_BIT*/ ); circa_copy(_inputEvents, circa_env_insert(_stack, "inputEvents")); circa_set_vec2(circa_env_insert(_stack, "mouse"), _mouseX, _mouseY); circa_set_vec2(circa_env_insert(_stack, "windowSize"), _width, _height); circa_set_float(circa_env_insert(_stack, "time"), _elapsedTime); circa_set_float(circa_env_insert(_stack, "lastFrameDuration"), _lastFrameDuration); #ifdef NACL circa_set_bool(circa_env_insert(_stack, "gl_es2"), true); #endif circa_run(_stack); if (circa_has_error(_stack)) { circa_dump_stack_trace(_stack); #ifndef NACL exit(1); #endif } // Cleanup stack circa_restart(_stack); // Cleanup circa_set_list(_inputEvents, 0); _lastFrameDuration = get_time() - startTime; #define DUMP_PERF_STATS 0 #if DUMP_PERF_STATS printf("frame duration = %f\n", (float) _lastFrameDuration); circa_perf_stats_dump(); circa_perf_stats_reset(); #endif }
void Server__connections(Stack* stack) { Server* server = (Server*) circa_native_ptr(circa_index(circa_input(stack, 0), 0)); circa_copy(&server->connections, circa_output(stack, 0)); }