Skip to content

Commit

Permalink
Revert commit 1bea6f1 + a98b114.
Browse files Browse the repository at this point in the history
These were both part of PR #35 (Tim's graphics and signal
implementation). The changeset consisted of two unrelated parts:

- An attempt to work around defects in the menu open action.

- An ad-hoc implementation of object reloading functionality.

As the bugs in the menu open action have since been fixed, and the
pdx.lua live-coding extension already provides a way to get automatic
object reloading which improves over the method being used here in every
way, this code is now obsolete and can be removed.
  • Loading branch information
agraef committed Sep 4, 2024
1 parent 4a7c4ce commit 0151c27
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
27 changes: 1 addition & 26 deletions pd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
32 changes: 0 additions & 32 deletions pdlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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 */
}
/**/
Expand Down

0 comments on commit 0151c27

Please sign in to comment.