[L2Ork-dev] Name clash
Guillem Bartrina
guillembartrina at gmail.com
Wed Jul 15 06:01:38 EDT 2020
TRACES
------------------------------------
_Case 1: absolute path_
new_anything
-> sys_load_lib:
if (sys_isabsolutepath(classname))
{
/* this is just copied from sys_open_absolute()
LATER avoid code duplication */
char dirbuf[MAXPDSTRING], *z = strrchr(classname, '/');
int dirlen;
if (!z)
return (0);
dirlen = z - classname;
if (dirlen > MAXPDSTRING-1)
dirlen = MAXPDSTRING-1;
strncpy(dirbuf, classname, dirlen);
dirbuf[dirlen] = 0;
data.classname=classname+(dirlen+1);
sys_loadlib_iter(dirbuf, &data);
}
"/..path.." and "basename" are passed separately, "/..path.." fills the
role of the search path.
-> sys_loadlib_iter
-> sys_do_load_abs
-> class_new: added two methods, "basename" and "/..path../basename".
---
For example if you try to instantiate a "/..path../float", the following
error is thrown:
"consistency check failed: class_addmethod: objectmaker_float: bad
argument types"
Because it tries to add the method "float" to pd_objectmaker using
'class_addmethod', and all special methods are handled different:
[...]
else if (sel == &s_float)
{
if (argtype != A_FLOAT || va_arg(ap, t_atomtype)) goto phooey;
class_doaddfloat(c, fn);
}
[...]
It fails to replace the built-in "float" method because the argtype for
abstractions is A_GIMME, but in other situations it could be replaced
successfully.
------------------------------------
_Case 2: relative path_
new_anything
-> sys_load_lib
data.classname = classname;
if(!data.ok)
canvas_path_iterate(canvas,
(t_canvas_path_iterator)sys_loadlib_iter, &data);
-> canvas_path_iterate: the different sources (canvas path, search
paths, global paths, ...) are passed as the directory and the relative
path as the classname
-> sys_loadlib_iter
-> sys_do_load_abs
-> class_new: added two identical methods, "..relative path..". Because
'class_loadsym' is the relative path as well.
In this case, the classname is the relative path so the method
"basename" is not added and therefore there's no name clash with the
built-in special methods (e.j. "float"), and the error described above
is not thrown.
------------------------------------
In conclusion, absolute and relative paths are treated differently.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://disis.music.vt.edu/pipermail/l2ork-dev/attachments/20200715/ae23add1/attachment.html>
More information about the L2Ork-dev
mailing list