author | francesco-ST <francesco.abbate@st.com> | 2010年12月02日 10:21:15 +0100 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2010年12月02日 10:21:15 +0100 |
commit | 1002c98152dc3dabad7b251103d60a587f7aa5b1 (patch) | |
tree | f4710447b154d4244ac861e70c3dce5917f6e2f8 /agg-plot/lua-plot.cpp | |
parent | 9a2e6443e486a5b417c7e0bfbcfef15ac9e0b6d8 (diff) | |
download | gsl-shell-1002c98152dc3dabad7b251103d60a587f7aa5b1.tar.gz |
-rw-r--r-- | agg-plot/lua-plot.cpp | 37 |
diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 6f036514..5b60ea3d 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -25,6 +25,7 @@ extern "C" { #include "lua-plot.h" #include "lua-plot-cpp.h" +#include "lua-cpp-utils.h" #include "bitmap-plot.h" #include "window.h" #include "gs-types.h" @@ -148,35 +149,39 @@ plot_free (lua_State *L) return object_free<lua_plot>(L, 1, GS_PLOT); } -int -plot_add_gener (lua_State *L, bool as_line) +void +plot_add_gener_cpp (lua_State *L, lua_plot *p, bool as_line, + gslshell::ret_status& st) { - lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT); - - agg::rgba8 color; - try { + agg::rgba8 color; drawable *obj = parse_graph_args (L, color); - object_refs_add (L, table_plot_obj, p->current_layer_index(), 1, 2); - AGG_LOCK(); - p->add(obj, color, as_line); - AGG_UNLOCK(); + object_refs_add (L, table_plot_obj, p->current_layer_index(), 1, 2); + if (p->sync_mode()) plot_flush (L); } - catch (std::bad_alloc&) - { - return luaL_error (L, OUT_OF_MEMORY_MSG); - } - catch (agg_spec_error& e) + catch (std::exception& e) { - return luaL_error (L, e.message()); + st.error(e.what(), "plot add or addline"); } +} + +int +plot_add_gener (lua_State *L, bool as_line) +{ + lua_plot *p = object_check<lua_plot>(L, 1, GS_PLOT); + + gslshell::ret_status st; + plot_add_gener_cpp (L, p, as_line, st); + + if (st.error_msg()) + return luaL_error (L, "%s in %s", st.error_msg(), st.context()); return 0; } |