diff --git a/pd.lua b/pd.lua index 53f32d8..649ebf1 100644 --- a/pd.lua +++ b/pd.lua @@ -20,13 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -- storage for Pd C<->Lua interaction pd._classes = { } -- take absolute paths and turn them into classes -pd._fullpaths = { } pd._pathnames = { } -- look up absolute path by creation name pd._objects = { } pd._clocks = { } pd._receives = { } pd._loadpath = "" -pd._currentpath = "" -- add a path to Lua's "require" search paths pd._setrequirepath = function(path) @@ -135,15 +133,6 @@ pd._whoami = function (object) end end ---whereami method dispatcher -pd._whereami = function(name) - if nil ~= pd._fullpaths[name] then - return pd._fullpaths[name] - end - - return nil -end - --class method dispatcher pd._get_class = function (object) if nil ~= pd._objects[object] then @@ -317,19 +306,10 @@ function pd.Class:register(name) else regname = name end - - --pd._fullpaths[regname] = pd._currentpath or (fullname .. ".pd_lua") - if pd._currentpath == nil or pd._currentpath == '' then - pd._fullpaths[regname] = fullname .. ".pd_lua" - else - pd._fullpaths[regname] = pd._currentpath - end - pd._pathnames[regname] = fullname pd._classes[fullname] = self -- record registration self._class = pd._register(name) -- register new class self._name = name - self._path = pd._fullpaths[regname] self._loadpath = fullpath if name == "pdlua" then self._scriptname = "pd.lua" @@ -442,7 +422,6 @@ function pd.Class:dofilex(file) local pathsave = pd._loadpath pd._loadname = nil pd._loadpath = self._loadpath - pd._currentpath = file local f, path = pd._dofilex(self._class, file) pd._loadname = namesave pd._loadpath = pathsave @@ -457,7 +436,6 @@ function pd.Class:dofile(file) local pathsave = pd._loadpath pd._loadname = nil pd._loadpath = self._loadpath - pd._currentpath = file local f, path = pd._dofile(self._object, file) pd._loadname = namesave pd._loadpath = pathsave @@ -472,10 +450,6 @@ function pd.Class:whoami() return self._scriptname or self._name end -function pd.Class:in_1__reload() - self:dofile(self._path) -end - function pd.Class:get_class() -- accessor for t_class* return self._class or nil end @@ -492,6 +466,7 @@ function lua:in_1_load(atoms) -- execute a script self:dofile(atoms[1]) end + local luax = pd.Class:new():register("pdluax") -- classless lua externals (like [pdluax foo]) function luax:initialize(sel, atoms) -- motivation: pd-list 2007-09-23 diff --git a/pdlua.c b/pdlua.c index 6533238..df8048c 100644 --- a/pdlua.c +++ b/pdlua.c @@ -771,13 +771,6 @@ static int pdlua_click(t_gobj *z, t_glist *gl, int xpos, int ypos, int shift, in return text_widgetbehavior.w_clickfn(z, gl, xpos, ypos, shift, alt, dbl, doit); } -// The _reload method will tell the pdlua object to reload the original script that spawned it -// This is used in plugdata for dynamic reloading, but can be useful in other environments too -// Prefixed with _ to prevent namespace pollution -static void pdlua_reload(t_gobj* z) -{ - pdlua_dispatch((t_pdlua *)z, 0, gensym("_reload"), 0, NULL); -} static void pdlua_displace(t_gobj *z, t_glist *glist, int dx, int dy){ t_pdlua *x = (t_pdlua *)z; @@ -917,30 +910,6 @@ void plugdata_forward_message(void* x, t_symbol *s, int argc, t_atom *argv); /** Here we find the lua code for the object and open it in an editor */ static void pdlua_menu_open(t_pdlua *o) { - #if PLUGDATA - // This is a more reliable method of finding out what file an object came from - // TODO: we might also want to use something like this for pd-vanilla? - lua_getglobal(__L(), "pd"); - lua_getfield(__L(), -1, "_whereami"); - lua_pushstring(__L(), o->pd.te_pd->c_name->s_name); - - if (lua_pcall(__L(), 1, 1, 0)) - { - pd_error(NULL, "lua: error in whereami:\n%s", lua_tostring(__L(), -1)); - lua_pop(__L(), 2); /* pop the error string and the global "pd" */ - return; - } - if(lua_isstring(__L(), -1)) { - const char* fullpath = luaL_checkstring(__L(), -1); - if(fullpath) { - t_atom arg; - SETSYMBOL(&arg, gensym(fullpath)); - plugdata_forward_message(o, gensym("open_textfile"), 1, &arg); - } - return; - } -#endif - const char *name; const char *path; char pathname[FILENAME_MAX]; @@ -1232,7 +1201,6 @@ static int pdlua_class_new(lua_State *L) if (c) { /* a class with a "menu-open" method will have the "Open" item highlighted in the right-click menu */ class_addmethod(c, (t_method)pdlua_menu_open, gensym("menu-open"), A_NULL);/* (mrpeach 20111025) */ - class_addmethod(c, (t_method)pdlua_reload, gensym("_reload"), A_NULL);/* (mrpeach 20111025) */ class_addmethod(c, (t_method)pdlua_dsp, gensym("dsp"), A_CANT, 0); /* timschoen 20240226 */ } /**/