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

John Carlson yottzumm at gmail.com
Sun May 12 18:58:38 PDT 2019


1. Cleaned up printSubArray, fixed non-scoped v.    Fixed nested if (type === “boolean”) that would not run inside another if (type === “int”)
2. Added braces for consistency. I always use braces in JS and Java.  I believe this is best practice inherited from C.
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.
4. If you are still getting const errors, upgrade to ES6 node.js.  If not possible, change const to var.

I think if we can’t solve this problem in pyjnius, we’ll have to punt and use wrapping or new methods in X3DJSAIL.   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.

StackOverflows are getting out of hand, please address.  I suggest talking to Oracle or other OpenJDK folks.

John

Sent from Mail for Windows 10

From: Brutzman, Donald (Don) (CIV)
Sent: Sunday, May 12, 2019 2:39 PM
To: John Carlson
Cc: X3D Graphics public mailing list
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

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


More information about the x3d-public mailing list