From: Samuele P. <pe...@in...> - 2001-07-15 01:44:09
|
So after the trouble of a few posts and of making me propose a bad and not working hack, you came out with some actual code <wink>. > Nonetheless, I understand that some things just can't or don't make it into > a project, for whatever reasons. The situation is as follow: in principle the following patch along the line of your code Index: Py.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/core/Py.java,v retrieving revision 2.46 diff -u -5 -r2.46 Py.java --- Py.java 2001/07/03 20:20:27 2.46 +++ Py.java 2001/07/15 01:26:25 @@ -1404,10 +1404,11 @@ Class proxyClass) { return makeClass(name, bases, code, doc, proxyClass, null); } + private static Class[] pyClassCtrSignature = {String.class,PyTuple.class,PyObject.class,Class.class}; public static PyObject makeClass(String name, PyObject[] bases, PyCode code, PyObject doc, Class proxyClass,PyObject[] closure_cells) { PyFrame frame = getFrame(); @@ -1430,11 +1431,19 @@ bases[i].safeRepr()); } return c.__call__(new PyString(name), new PyTuple(bases), dict); + } else if (bases[i] instanceof org.python.util.PyMetaClass) { + try { + return (PyObject)bases[i].getClass().getConstructor(pyClassCtrSignature).newInstance( + new Object[] { name, new PyTuple(bases), dict, proxyClass }); + } catch(Exception e) { + throw Py.TypeError("meta-class fails to supply proper ctr: "+bases[i].safeRepr()); + } } + } return new PyClass(name, new PyTuple(bases), dict, proxyClass); } plus an empty org.python.util.PyMetaClass interface could make into the code, no problem with that. I can play the good guy <wink> and if it's OK for Finn, it can be committed. The whole point is that the patch will last until 2.2 and maybe survive to that. But I'm not willing to commit on the actual internals design or the patch as something here to stay. The internals after 2.2 are something that should be designed to stay, that's my goal. E.g. the last PyJavaClasses related bug I had to solve I should resort to an hack because of the internals... this should be fixed (clearly not an easy thing, perfectly aware of that). So if you will not call me a bad guy <wink> if what you build on top of 2.1 internals will no longer work with 2.2, I think you can have the feature. Not really a technical point, more a "political" one, but not a personal ... regards, Samuele Pedroni. |