[x3d-public] X3DJSAIL updated; python pyjnius mapping,javascriptwarnings,cleaner .py export syntax

John Carlson yottzumm at gmail.com
Tue May 14 03:57:51 PDT 2019


It seems like adding this method would help my  version of the pipeline
serializer.   I don’t know how to fix which interface is returned.   Please
look at org and pyjnius folders and remove an mention of abstract classes
and interfaces.  I have already done so, for the most part (left a couple
in build.xml).

On Mon, May 13, 2019 at 8:50 AM John Carlson <yottzumm at gmail.com> wrote:

> How do we feel about adding an abstract method, addChild, to
> X3DConcreteNode, and @Override the method in subclasses?
>
>
> I believe that would drastically reduce the number of abstract errors I
> get.
>
>
>
> I don’t know though, since you’ve seemed to reduce the number of abstract
> class errors to 1.
>
>
>
> Perhaps we should open to the community how to fix remaining interface
> errors.
>
>
>
> Thanks,
>
>
>
> John
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *John Carlson <yottzumm at gmail.com>
> *Sent: *Monday, May 13, 2019 8:26 AM
> *To: *Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>
> *Cc: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *RE: X3DJSAIL updated; python pyjnius
> mapping,javascriptwarnings,cleaner .py export syntax
>
>
>
> Have removed all abstract classes and interfaces from the codebase, except
> for the full jar, referenced in classpath.py.  Please verify
>
>
>
> Will forward python build log in a bit.
> https://coderextreme.net/pyjniusbuild.txt
>
>
>
> Greatest move forward was wrapping SF and MF types around native values
> for me.
>
>
>
> Have not seen reduction in stackoverflows by increasing stacksize or
> heapsize. Please advise.
>
>
>
> $ cat classpath.py
>
> import jnius_config
>
> jnius_config.add_options('-Xss1g', '-Xmx8g')
>
> jnius_config.set_classpath('.', 'c:/x3d-code/
> www.web3d.org/x3d/stylesheets/java/jars/X3DJSAIL.3.3.full.jar',
> '../../../jars/X3DJSAIL.3.3.full.jar')
>
>
>
> Advise how to fix stacksize options to avoid overflows.
>
>
>
> Checked in results:
>
>
>
> Remaining interface errors: 133
>
> Remaining abstract class errors:  1
>
> Remaining stack overflow errors: 13 or so
>
> Total validations: 538
>
> Future.py validations: 268
>
>
>
> Add wrappers (what Don calls typecasting) results:
>
>
>
> Remaining interface errors: 3 (invalid instance passed)
>
> Remaining abstract class errors:16 (no attribute addChild on
> X3DConcreteNode)
>
> Remaining stack overflow errors: 61
>
>
>
> So it looks like your technique is better at reducing abstract class
> errors and stack overflow errors, and my technique is better at reducing
> interface errors (but not perfect).
>
>
>
> Do you have a solution that reduces all three classes of errors?
>
>
>
> If you’ve got working code in other folders, could we migrate it to the
> pyjnius folder, or otherwise tell me which ant targets to build.
>
>
>
> Interface error samples follow
>
>
>
> John
>
> processSingleScene.pythonValidation:
>
>      [echo] processSingleScene.python C:\x3d-code\www.web3d.org
> \x3d\content\examples\X3dForWebAuthors\Chapter15Metadata\
> MetadataNodeExamples.future.py
>
>      [echo] Loading X3D model as .py program, if successful then saving as
> round-trip .x3d version:
>
>      [exec] Traceback (most recent call last):
>
>      [exec]   File "C:\x3d-code\www.web3d.org
> \x3d\content\examples\X3dForWebAuthors\Chapter15Metadata\
> MetadataNodeExamples.future.py", line 53, in <module>
>
>      [exec]
> .addChild(MetadataString().setName(SFString("TestRootMetadataNode")).setValue(MFString(["Test
> satisfactory.","Note that all SFString values must be quoted."])))
>
>      [exec]   File "jnius\jnius_export_class.pxi", line 760, in
> jnius.JavaMethod.__call__
>
>      [exec]   File "jnius\jnius_conversion.pxi", line 78, in
> jnius.populate_args
>
>      [exec]   File "jnius\jnius_utils.pxi", line 205, in
> jnius.check_assignable_from
>
>      [exec] jnius.JavaException: Invalid instance of
> 'org/web3d/x3d/jsail/Core/MetadataStringObject' passed for a
> 'org/web3d/x3d/sai/Core/X3DChildNode'
>
>      [echo] =====================
>
>
>
>
>
>
>
> processSingleScene.pythonValidation:
>
>      [echo] processSingleScene.python C:\x3d-code\www.web3d.org
> \x3d\content\examples\X3dForWebAuthors\Chapter15Metadata\
> WorldInfo.future.py
>
>      [echo] Loading X3D model as .py program, if successful then saving as
> round-trip .x3d version:
>
>      [exec] Traceback (most recent call last):
>
>      [exec]   File "C:\x3d-code\www.web3d.org
> \x3d\content\examples\X3dForWebAuthors\Chapter15Metadata\
> WorldInfo.future.py", line 45, in <module>
>
>      [exec]
> .setMetadata(MetadataString().setDEF(SFString("MyMetadataStringNode")).setName(SFString("TestNode")).setReference(SFString("X3D")).setValue(MFString(["Hello","WorldInfo"]))))
>
>      [exec]   File "jnius\jnius_export_class.pxi", line 760, in
> jnius.JavaMethod.__call__
>
>      [exec]   File "jnius\jnius_conversion.pxi", line 78, in
> jnius.populate_args
>
>      [exec]   File "jnius\jnius_utils.pxi", line 205, in
> jnius.check_assignable_from
>
>      [exec] jnius.JavaException: Invalid instance of
> 'org/web3d/x3d/sai/Core/X3DNode' passed for a
> 'org/web3d/x3d/sai/Core/X3DChildNode'
>
>      [echo] =====================
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Brutzman, Donald (Don) (CIV) <brutzman at nps.edu>
> *Sent: *Sunday, May 12, 2019 9:23 PM
> *To: *John Carlson <yottzumm at gmail.com>
> *Cc: *X3D Graphics public mailing list <x3d-public at web3d.org>
> *Subject: *Re: X3DJSAIL updated; python pyjnius mapping,
> javascriptwarnings,cleaner .py export syntax
>
>
>
> On 5/12/2019 6:58 PM, John Carlson wrote:
>
> >  1. Cleaned up printSubArray, fixed non-scoped v.    Fixed nested if
> (type === “boolean”) that would not run inside another if (type === “int”)
>
>
>
> I had already fixed that, checked in, reported, and run a rebuild on all
> examples.  Hope we haven't worked at cross purposes or conflicted
> subversion.  Please invoke svn refresh frequently, I do.
>
>
>
> >  2. Added braces for consistency. I always use braces in JS and Java.  I
> believe this is best practice inherited from C.
>
>
>
> Not clear where you are referring to.  Example excerpt please.
>
>
>
> >  3. Replaced spaces with tabs.  I use tabs for indents. Your text editor
> should be able to handle this, that is, configure leading tabs to be the
> amount of whitespace you want, typically 4 virtual spaces in python I
> think.  Sugggest replaceing rest of left whitespace with tabs.
>
>
>
> As before, have set at two whitespace characters to match .java syntax for
> simplest comparability.
>
>
>
> Tab settings differ widely so they are not a good default.  Single
> whitespace doesn't show scene graph structure well enough.
>
>
>
> >  4. If you are still getting const errors, upgrade to ES6 node.js.  If
> not possible, change const to var.
>
>
>
> I get the const errors within Netbeans 8, will check on whether ES6 is
> upgraded in Netbeans 11.
>
>
>
> Are we requiring ES6 node.js?  Seems like a good idea.
>
>
>
> Why don't we add node.js verification checking of your .js files at the
> beginning of the build process?  Should be possible, do you know the
> invocation for that?  Probably could put jslint output in the logs too...
>
>
>
> > I think if we can’t solve this problem in pyjnius, we’ll have to punt
> and use wrapping or new methods in X3DJSAIL.
>
>
>
> I think I have added all of the constructor and set methods needed in
> X3DJSAIL yesterday.  Will check build logs and add double methods for float
> parameters if any  others look to be missing... should be good since
> autogeneration patterns were used, both spotchecks and unit tests looked
> good.
>
>
>
> > Adding casts will make the code look ugly, I think.  Wrapping is fairly
> clean and fixes most errors.  We’ll have to provide a good set of
> documentation for how to fix the other errors, like suggesting using a
> non-SAI setDEF method—no override, cast or additional, possibly programmer
> specialized wrapping.   We can look at how people are solving the problem,
> and adopt the best approach.
>
>
>
> Rephrased (I think) is how I said it before: we need to continue verifying
> all of your pyjnius invocations, good progress has been made.  Don't want
> to have any hack workarounds way up in the user's python source. We are
> chasing cleanly pythonic duck typing here.  This latest is getting there,
> seems like we have far fewer errors and those that remain seem to be
> repetitive in nature.
>
>
>
> > StackOverflows are getting out of hand, please address.
>
>
>
> They are much reduced in latest build log (90MB -> 11MB) ... more
> improvements to follow.
>
>
>
> The root problem is not repetitive diagnostic messages but inadequate
> memory reservation when invoking pyjnius.
>
>
>
> > I suggest talking to Oracle or other OpenJDK folks.
>
> Will continue Reading The Manual and testing until stuck, onward we go.
> Thanks for steady progress together.
>
>
>
> Meanwhile wondering, is there any way to move these into one of the python
> infrastructure files?  That would reduce source complexity significantly.
>
>
>
> from org.web3d.x3d.jsail.Core.X3DObject import X3DObject as X3D
>
> from org.web3d.x3d.jsail.fields.SFStringObject import SFStringObject as
> SFString
>
> from org.web3d.x3d.jsail.Core.headObject import headObject as head
>
> from org.web3d.x3d.jsail.Core.metaObject import metaObject as meta
>
> from org.web3d.x3d.jsail.Core.SceneObject import SceneObject as Scene
>
> from org.web3d.x3d.jsail.Grouping.GroupObject import GroupObject as Group
>
> // etc.
>
>
>
> > John
>
> >
>
> > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
> >
>
> > *From: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
>
> > *Sent: *Sunday, May 12, 2019 2:39 PM
>
> > *To: *John Carlson <mailto:yottzumm at gmail.com>
>
> > *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
>
> > *Subject: *Re: X3DJSAIL updated; python pyjnius mapping, javascript
> warnings,cleaner .py export syntax
>
> >
>
> > On 5/11/2019 6:46 PM, John Carlson wrote:
>
> >
>
> >  > Fixed, checked in.
>
> >
>
> > thank you.
>
> >
>
> > Found some issues with PythonPipeliningSerializer.js:
>
> >
>
> > - Netbeans provides a number of warnings, worked as follows to clear
> them.
>
> >
>
> > - semicolons added where indicated
>
> >
>
> > - printSubArray method had a number of issues
>
> >
>
> > -- nested variable v defined multiple times, renamed it to vv within
> nested scope
>
> >
>
> > -- irregular indentation led to variable v later being out of scope;
>
> >
>
> > -- reason was premature completion of integer "for (var v in values)"
> loop
>
> >
>
> > -- moved closing } to put everything appropriate within loop, please
> check
>
> >
>
> > - thanks for fixing "if (attrType.startsWith("SF"))"
>
> >
>
> > - changed some identity operators == to equality operators ===
>
> >
>
> >
> https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons
>
> >
>
> > note that Douglas Crockford is quoted as
>
> >
>
> >                  "JavaScript has two sets of equality operators: === and
> !==, and their evil twins == and !=. The good ones work the way you would
> expect. [...] The lack of transitivity is alarming. My advice is to never
> use the evil twins. Instead, always use === and !==."
>
> >
>
> > - i worked on removing line-continuation characters completely by
> wrapping entire expression in one extra set of parentheses
>
> >
>
> > - comments now appear on a new line for readability
>
> >
>
> > - changed \r\n to \n for consistency throughout, seemed OK
>
> >
>
> > - output line breaks inserted between sections and otherwise minimized
> for readability
>
> >
>
> > Still getting an error: Unexpected 'const'
>
> >
>
> > const DOUBLE_SUFFIX = '';
>
> >
>
> > Checked in these changes to PythonPipeliningSerializer.js.
>
> >
>
> > Clean example attached - better and better.
>
> >
>
> >  > Do you have an example we can test with?
>
> >
>
> > I continue focusing on HelloWorld.x3d and corresponding HelloWorld.py
>
> >
>
> > Moving around and removing sections of .x3d source can push the error
> around...
>
> >
>
> > Each time, am only able to get errors in .py file of the form
>
> >
>
> >
> .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'
>
> >
>
> >
> .setMaterial(Material().setDEF("MaterialLightBlue").setDiffuseColor(0.1,0.5,1))
>
> >
>
> >       AttributeError: 'org.web3d.x3d.sai.Shape.X3DMaterialNode' object
> has no attribute 'setDiffuseColor'
>
> >
>
> >
> .setTexture(ImageTexture().setDEF("ImageCloudlessEarth").setUrl(["earth-topo.png","earth-topo.jpg","earth-topo-small.gif","
> http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png","
> http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg","
> http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif
> "]))))))))
>
> >
>
> >       AttributeError: 'org.web3d.x3d.sai.Texturing.X3DTextureNode'
> object has no attribute 'setUrl'
>
> >
>
> > so it sure looks like it has something to do with incorrect handling of
> direct methods, it seems OK when a method is found in abstract parent of an
> object class.
>
> >
>
> >  > Thanks,
>
> >
>
> >  >
>
> >
>
> >  > John
>
> >
>
> >  >
>
> >
>
> >  > Index: PythonPipeliningSerializer.js
>
> >
>
> >  >
>
> >
>
> >  > ===================================================================
>
> >
>
> >  >
>
> >
>
> >  > --- PythonPipeliningSerializer.js       (revision 28463)
>
> >
>
> >  >
>
> >
>
> >  > +++ PythonPipeliningSerializer.js       (working copy)
>
> >
>
> >  >
>
> >
>
> >  > @@ -82,7 +82,7 @@
>
> >
>
> >  >
>
> >
>
> >  >                          values.pop();
>
> >
>
> >  >
>
> >
>
> >  >                  }
>
> >
>
> >  >
>
> >
>
> >  > -               if (type.startsWith("SF")) // TODO fix this
> javascript, test is not working
>
> >
>
> >  >
>
> >
>
> >  > +               if (attrType.startsWith("SF"))
>
> >
>
> >  >
>
> >
>
> >  >               return     lead+values.join(j)+trail; // avoid array
> brackets on SF types
>
> >
>
> >  >
>
> >
>
> >  >           else
>
> >
>
> >  >
>
> >
>
> >  >               return '['+lead+values.join(j)+trail+']';
>
> >
>
> >  >
>
> >
>
> >  > Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
> >
>
> >  >
>
> >
>
> >  > *From: *John Carlson <mailto:yottzumm at gmail.com>
>
> >
>
> >  > *Sent: *Saturday, May 11, 2019 8:39 PM
>
> >
>
> >  > *To: *Brutzman, Donald (Don) (CIV) <mailto:brutzman at nps.edu>
>
> >
>
> >  > *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
>
> >
>
> >  > *Subject: *RE: X3DJSAIL updated support for setting with doubles;
> pythonpyjniusmapping
>
> >
>
> >  >
>
> >
>
> >  > ==========================================
>
> >
>
> >  >
>
> >
>
> >  >  >2. Also tried to get PythonPipeliningSerializer.js to avoid
> brackets on simple and numeric types.
>
> >
>
> >  >
>
> >
>
> >  >  >Checked in block that didn't work, please fix and check back in:
>
> >
>
> >  >
>
> >
>
> >  >                                  if (type.startsWith("SF")) // TODO
> fix this javascript, test is not working
>
> >
>
> >  >
>
> >
>
> >  >               return     lead+values.join(j)+trail; // avoid array
> brackets on SF types
>
> >
>
> >  >
>
> >
>
> >  >           else
>
> >
>
> >  >
>
> >
>
> >  >               return '['+lead+values.join(j)+trail+']';
>
> >
>
> >  >
>
> >
>
> >  > ==========================================
>
> >
>
> >  >
>
> >
>
> >  > I logged type, and these appear to be Java types.  So we’ll have to
> change type to attrType or something. Will do.
>
> >
>
> >  >
>
> >
>
> >  > John
>
> >
>
> >  >
>
> >
>
> > all the best, Don
>
> >
>
> > --
>
> >
>
> > Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
>
> >
>
> > Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA
> +1.831.656.2149
>
> >
>
> > X3D graphics, virtual worlds, navy robotics
> http://faculty.nps.edu/brutzman
>
> >
>
>
>
>
>
> all the best, Don
>
> --
>
> Don Brutzman  Naval Postgraduate School, Code USW/Br
> brutzman at nps.edu
>
> Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
>
> X3D graphics, virtual worlds, navy robotics
> http://faculty.nps.edu/brutzman
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190514/b0495572/attachment-0001.html>


More information about the x3d-public mailing list