+ // Make sure the path exposed to the theme (as Nageru.THEME_PATH;
+ // can be useful for locating files when talking to CEF) is absolute.
+ // In a sense, it would be nice if realpath() had a mode not to
+ // resolve symlinks, but it doesn't, so we only call it if we don't
+ // already have an absolute path (which may leave ../ elements etc.).
+ if (path[0] == '/') {
+ theme_path = path;
+ } else {
+ char *absolute_theme_path = realpath(path.c_str(), nullptr);
+ theme_path = absolute_theme_path;
+ free(absolute_theme_path);
+ }
+
+ // Set up the API we provide.
+ register_constants();
+ register_class("EffectChain", EffectChain_funcs);
+ register_class("LiveInputWrapper", LiveInputWrapper_funcs);
+ register_class("ImageInput", ImageInput_funcs);
+ register_class("VideoInput", VideoInput_funcs);
+ register_class("HTMLInput", HTMLInput_funcs);
+ register_class("WhiteBalanceEffect", WhiteBalanceEffect_funcs);
+ register_class("ResampleEffect", ResampleEffect_funcs);
+ register_class("PaddingEffect", PaddingEffect_funcs);
+ register_class("IntegralPaddingEffect", IntegralPaddingEffect_funcs);
+ register_class("OverlayEffect", OverlayEffect_funcs);
+ register_class("ResizeEffect", ResizeEffect_funcs);
+ register_class("MultiplyEffect", MultiplyEffect_funcs);
+ register_class("MixEffect", MixEffect_funcs);
+ register_class("InputStateInfo", InputStateInfo_funcs);
+ register_class("ThemeMenu", ThemeMenu_funcs);
+
+ // Now actually run the theme to get everything set up.
+ lua_rawgeti(L, LUA_REGISTRYINDEX, theme_code_ref);
+ luaL_unref(L, LUA_REGISTRYINDEX, theme_code_ref);
+ if (lua_pcall(L, 0, 0, 0)) {
+ fprintf(stderr, "Error when running %s: %s\n", path.c_str(), lua_tostring(L, -1));
+ exit(1);
+ }
+ assert(lua_gettop(L) == 0);
+