[x3d-public] updates to X3DJSAIL,pluspythonandjavaversionsofX3DExamples,X3DPSAIL; let Python be Python; missing from X3DUOM;

John Carlson yottzumm at gmail.com
Thu Jun 27 21:51:13 PDT 2019


I have been working on this some, and the errors are now different.  We have an SAI problem crop up because primitive wrappers were not used (which forced the code to use the concrete object, as previously analyzed).

I have checked the python files in this report into

https://github.com/carlsonsolutiondesign/x3dpsail

Please checkout and debug.  I have also removed wrappers from primitives.  There are new errors because of it.

.x3d files are under x3d/stylesheets/java/examples on sourceforge.

(attached errs.txt)

Distilled error report:

AttributeError: 'org.web3d.x3d.jsail.Core.ProtoBodyObject' object has no attribute 'addShaders' (missing, please add to X3DJSAIL or fix serializers—note this is a concrete object)
AttributeError: 'org.web3d.x3d.jsail.X3DConcreteNode' object has no attribute 'setCenterOfRotation' (use wrappers to fix)
AttributeError: 'org.web3d.x3d.sai.Navigation.ViewpointGroup' object has no attribute 'addChild' (use wrappers to fix)

I’m going to check in and then switch mine back to wrappers to see if I fixed the other error.

Still not fixed (previously reported):

abox.future.py ====================================
Traceback (most recent call last):^M
  File "abox.future.py", line 20, in <module>^M
    .addConnect(x3dpsail.connect().setNodeField("children").setProtoField("myShape"))))))^M
  File "jnius\jnius_export_class.pxi", line 760, in jnius.JavaMethod.__call__^M
  File "jnius\jnius_conversion.pxi", line 78, in jnius.populate_args^M
  File "jnius\jnius_utils.pxi", line 205, in jnius.check_assignable_from^M
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/X3DConcreteNode' passed for a 'org/web3d/x3d/sai/Core/X3DNode'^M

John

Sent from Mail for Windows 10

From: John Carlson
Sent: Thursday, June 27, 2019 8:01 PM
To: Brutzman, Donald (Don) (CIV)
Cc: X3D Graphics public mailing list; Peitso, Loren (CIV)
Subject: RE: updates to X3DJSAIL,pluspythonandjavaversionsofX3DExamples,X3DPSAIL; let Python be Python;missing from X3DUOM;

PROGRESS! We need to upgrade SceneObject.java in X3DJSAIL! There are 3 tasks for Don’s keen coding here.

Don, did you just call from San Diego? I stepped away from my phone. Please spend a lot of time on this message, thanks.  Review MAJOR task, mine, first then review others to see if we can simplify the tasks.  They all appear to be related.

I fully know that my serializers only work in some cases, because of a disconnect between X3DUOM and my serializers.  That’s one reason mapToMethod2.js was created. The other reason was because of a possible “blindspot” in X3DUOM, namely, how can I find out what nodes can have an IS statement child? In order to continue generating mapToMethod.js, I had to add additional method names in mapToMethod2.js (or alternatively, which I didn’t like, in all my serializers).  It is possible that mapToMethod2.js shows other failings of X3DUOM.  It’s the first place I’d go when looking for something that is missing from X3DUOM. Yes, the two mapToMethod*js files are complementary.

I’m perfectly fine with abandoning the Pipelining style of API, if this solves our abstract classes problem, and we will be forced to do this if we choose a current pythonic way of doing things—assignment without a return value. Abandoning pipelining will fix our pyjnius problems too, I believe, but have not tested extensively recently

I’ve heard that there will be a new way of doing things in Python using := assignment expressions that will return the object the assignment is called on, which is what we want, right? Can Loren show us how to do that if’s it’s available? https://www.python.org/dev/peps/pep-0572/  Should we sign up for a python 3.8 beta?
===========================================================================================================
I am attaching the errors from python programs from java/examples/*.x3d.  I see many errors. Now I know why you are complaining, Re: HelloWorld.

node ../src/python/pyjnius/xml2all.js *.x3d

So let’s do a quick search for AttributeError:

grep Attribute errs.txt
AttributeError: 'NoneType' object has no attribute 'addChild'
AttributeError: 'org.web3d.x3d.jsail.Core.SceneObject' object has no attribute 'setMetadata'
AttributeError: 'NoneType' object has no attribute 'addChild'
AttributeError: 'org.web3d.x3d.jsail.Core.SceneObject' object has no attribute 'setMetadata'
============================================================================================================
Don, task for you. Medium Priority. Suggestion: adding setMetadata in SceneObject.java

The next task, if accepted, will probably make this fix irrelevant.

The setMetadata error is an error in the serializer (should have generated addMetadata or addChild) or the stylesheet (no setMetadata method in SceneObject.java in X3DJSAIL).  It’s likely I could replace addMetadata in mapToMethod2.js, but this will require testing. We’ve been using setMetadata for a long time in other places than Scene
Files that produce the setMetadata error:

$ python HelloWorldProgramOutputTidy.py
Traceback (most recent call last):
  File "HelloWorldProgramOutputTidy.py", line 200, in <module>
    Scene31.setMetadata(MetadataString39)
AttributeError: 'org.web3d.x3d.jsail.Core.SceneObject' object has no attribute 'setMetadata'

coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/java/examples
$ python HelloWorldProgramOutputTidy_CommandLine.py
Traceback (most recent call last):
  File "HelloWorldProgramOutputTidy_CommandLine.py", line 200, in <module>
    Scene31.setMetadata(MetadataString39)
AttributeError: 'org.web3d.x3d.jsail.Core.SceneObject' object has no attribute 'setMetadata'

coderextreme at DESKTOP-DOPK2VD MINGW64 /c/x3d-code/www.web3d.org/x3d/stylesheets/java/examples
==========================================================================================================
This is for John. MAJOR change.  High Priority.  Needs review.  Suggestion:  Add additional test for Scene where number of children == 0 (no children added yet, first child).  Change first child’s method from set* to add* in Scene. In ALL serializers. This will mean that the first XML child of Scene will receive add instead of set in the Python code. Possible modifier:  add setChild to X3DJSAIL which returns SceneObject, and use that instead of setChildren.

The addChild issues appear to be from the serializer using setChildren, which returns a void.  The following script shows the issue.

import x3dpsail

X3D0 = (x3dpsail.X3D()
      .setScene(x3dpsail.Scene()
        .setChildren(x3dpsail.ViewpointGroup())
        .addChild(x3dpsail.NavigationInfo())))

Discovered by the following command:

$ find ../src/ -name SceneObject.java |xargs grep setChildren
        public SceneObject setChildren(ArrayList<X3DNode> newValue)
        public void setChildren(X3DNode newValue)
                setChildren(getChildren()); // also test getter/setter validation, which also includes checks for acceptableNodeTypes (if applicable)

Don’s task.  Extremely low priority, except to look for a pyjnius problem. Suggestion: Provide a way to pass multiple children to SceneObject.setChildren in python.

I tried wrapping the passed argument in [] and got:

Traceback (most recent call last):
  File "foo.py", line 5, in <module>
    .setChildren([x3dpsail.ViewpointGroup()])
  File "jnius\jnius_export_class.pxi", line 1034, in jnius.JavaMultipleMethod.__call__
jnius.JavaException: No methods matching your arguments, available: ['(Ljava/util/ArrayList;)Lorg/web3d/x3d/jsail/Core/SceneObject;', '(Lorg/web3d/x3d/sai/Core/X3DNode;)V']

So I don’t know how to convert a python list to a Java ArrayList apparently?  Something’s missing from pyjnius here I think. Here’s the code I tried:

import x3dpsail

X3D0 = (x3dpsail.X3D()
      .setScene(x3dpsail.Scene()
        .setChildren([x3dpsail.ViewpointGroup()])
        .addChild(x3dpsail.NavigationInfo())))
============================================================================================================
Don and John’s task: Medium priority.  Suggestion: Don: provide SceneObject.addChild(MetadataStringObject) we may want to use addMetadata instead. John:  Fix mapToMethod2.js to override addChild with addMetadata in Scene parent, MetadataString child—will this work with current X3DJSAIL?

Other generated errors look like this:

jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a 'org/web3d/x3d/sai/Core/X3DChildNode'
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a 'org/web3d/x3d/sai/Core/X3DChildNode'
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a 'org/web3d/x3d/sai/Core/X3DChildNode'
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a 'org/web3d/x3d/sai/Core/X3DChildNode'
jnius.JavaException: Invalid instance of 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a 'org/web3d/x3d/sai/Core/X3DChildNode'

Relevant code where error shows up:

import x3dpsail


X3D0 = (x3dpsail.X3D()
      .setScene(x3dpsail.Scene()
        .addChild(x3dpsail.MetadataString())))

Which can be solved in the stylesheet by adding an

public SceneObject addChild(MetadataStringObject newValue)

in SceneObject.java. At least I think it would work.
===========================================================================================================
There is a LOT more Exceptions we can work with now! See attachment.

I believe that once we complete these successfully, we will be a lot closer (with wrappers) to a Python/Java API. However, we will probably have a lot more crud to clean up.

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190627/6fbaea7b/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: errs.txt
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190627/6fbaea7b/attachment-0001.txt>


More information about the x3d-public mailing list