/* catblocks Android - NativeActivity sem Java. * Usa android_native_app_glue (fornece ANativeActivity_onCreate, exigido pelo * NativeActivity). Corre o interpretador de IR (catblocks) e registra a saida * no logcat. Backend grafico continua stub (ver docs/ANDROID.md). */ #include #include #include /* prototipos do nucleo catblocks compilado junto */ typedef struct cb_node cb_node; cb_node *cb_program_sum(void); char *cb_interp_run(cb_node *root, int nvars, char **out, size_t *outlen); void cb_node_free_all(void *p); static int g_ran = 0; static void on_app_cmd(struct android_app *app, int32_t cmd) { if (cmd == APP_CMD_INIT_WINDOW && !g_ran) { g_ran = 1; cb_node *root = cb_program_sum(); char *out = 0; size_t n = 0; cb_interp_run(root, 4, &out, &n); __android_log_print(ANDROID_LOG_INFO, "catblocks", "saida do IR:\n%s", out ? out : "(vazio)"); cb_node_free_all(0); } } void android_main(struct android_app *app) { app->onAppCmd = on_app_cmd; for (;;) { int events; struct android_poll_source *source; while (ALooper_pollAll(-1, 0, &events, (void **)&source) >= 0) { if (source) source->process(app, source); if (app->destroyRequested) return; } } }