[x3d-public] X3DJSAIL updated support for setting with doubles; pythonpyjniusmapping

John Carlson yottzumm at gmail.com
Sun May 12 09:00:11 PDT 2019

Not quite:

$ grep -w Viewpoint *|grep public
ViewpointObject.java:public class ViewpointObject extends org.web3d.x3d.jsail.X3DConcreteNode implements org.web3d.x3d.sai.Navigation.Viewpoint

$ grep setCenterOfRotation *
Viewpoint.java: public Viewpoint setCenterOfRotation(float[] newValue);

So, perhaps pyjjnius is going up the wrong inheritanace hierarchy with getSuperclass?   Seems logical.
This seems interesting in reflect.py:

    for iclass in c.getInterfaces():
        if iclass.getName() == 'java.util.List':
            classDict['__getitem__'] = _getitem
            classDict['__len__'] = lambda self: self.size()

It doesn’t appear to be part of autoclass, but it really is!  But it only does something when the interface is List. Hmm.

Hmm. Still stumbling around in the dark!

from Mail for Windows 10

From: John Carlson
Sent: Sunday, May 12, 2019 9:57 AM
To: Brutzman, Donald (Don) (CIV)
Cc: X3D Graphics public mailing list
Subject: RE: X3DJSAIL updated support for setting with doubles;pythonpyjniusmapping

Aha!  X3DViewpointNode has no setCenterOfRotation so when you call it on the X3DViewpointNode returned by setDEF, the fails.

I think the SAI interface may need setCenterOfRotation?

Good luck!


$ grep set X3DViewpointNode.java |grep public
        public X3DViewpointNode setDescription(String newValue);
        public X3DViewpointNode setJump(boolean newValue);
        public X3DViewpointNode setMetadata(X3DMetadataObject newValue); // acceptable node types #2: X3DMetadataObject
        public X3DViewpointNode setOrientation(float[] newValue);
        public boolean getRetainUserOffsets();
        public X3DViewpointNode setRetainUserOffsets(boolean newValue);
        public X3DViewpointNode setDEF(String newValue);
        public X3DViewpointNode setUSE(String newValue);
        public X3DViewpointNode setCssClass(String newValue);

Sent from Mail for Windows 10

From: John Carlson
Sent: Saturday, May 11, 2019 9:44 PM
To: Brutzman, Donald (Don) (CIV)
Cc: X3D Graphics public mailing list
Subject: RE: X3DJSAIL updated support for setting with doubles; pythonpyjniusmapping

Navigation/ViewpointObject.java:        public final ViewpointObject setDEF(String newValue)
Navigation/ViewpointObject.java:        public ViewpointObject setDEF(SFStringObject newValue)
Navigation/X3DViewpointNode.java:       public X3DViewpointNode setDEF(String newValue);

The only thing I can conclude is that somehow, the setDEF in X3DViewpointNode.java overrides the one in ViewpointObject.java.  Since the interface contract for setDEF returns an interface or abstract class, the method can’t be found.  I “patched’ this by wrapping in a SFStringObject, and there’s no interface contract for that method, so it chooses the concrete class.

Reflect.py travels up the inheritance hierarchy doing this:

       parent_class = parent_class.getSuperclass()

I think it’s overriding methods with one of these, but not sure:
       classDict[name] = cls(sig, varargs=varargs)

       classDict[lowername] = (lambda n: property(lambda self: getattr(self, n)()))(name)

       classDict[name] = JavaMultipleMethod(signatures)
My guess is it overrides with the first one, since there is only one method in the interface/abstract class.

But it will require some experimentation.

You can replace import jnius with import reflect in classpath.py, I think, or each individual org package .py file.

I’ve tried disabling the getSuperclass line without success

Next step might be figure out how to build pyjnius.


>5. we're still having trouble with pyjnius finding the appropriate method:

- - - - - -
Loading HelloWorld.py (pipeline syntax) with python, if successful then saving and validating as HelloWorld_RoundTrip2.x3d version:
Traceback (most recent call last):
   File "C:\x3d-code\www.web3d.org\x3d\content\examples\X3dForWebAuthors/Chapter01TechnicalOverview//HelloWorld.py", line 74, in <module>
     .addChild(Viewpoint().setDEF("ViewUpClose").setCenterOfRotation([0,-1,0]).setDescription("Hello world!").setPosition([0,-1,7]) \
AttributeError: 'org.web3d.x3d.sai.Navigation.X3DViewpointNode' object has no attribute 'setCenterOfRotation'
- - - - - -

As before, not clear why parent X3DViewpointNode object gets tagged.   Suspect it is because pyjnius can't find the correct method signature in ViewpointObject, and so goes to parent abstract class.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190512/068e3c03/attachment.html>

More information about the x3d-public mailing list