[x3d-public] python pyjnius mapping

Brutzman, Donald (Don) (CIV) brutzman at nps.edu
Wed May 15 04:21:10 PDT 2019


On 5/15/2019 12:23 AM, John Carlson wrote:
> When I run my version of the pipelining serializer, I uncomment the code that inserts wrappers and comment out your code.  That is all.

OK thanks for clarifying.

When we cast any value to a field type, for example setDEF((SFStringObject)someValue) you are forcing which method is invoked, which in turn forces what type value is returned.

Please let's not call anything "your way" or "my way" since there are way more than two choices here.  We're not defending positions but rather seeking solutions.

The "wrappers" use field-object constructors to change type of a value to the SF/MF object.

Primary active options, named functionally:

- singleton method invocation, requires naming each node object, works
- pipelined method invocation with type casting of each value, works
- terse pipelined method invocation, duck typing with no type casting of each value, fails in some cases

The following statistics help show we are converging.

More to follow...

> I can double check my results, but here are the totals I got last time, albeit a bit adhoc:
> 
> Don’s style: No wrappers
> 
> As of 1 or 2 days ago followed by today if present.
> 
> Remaining interface errors: 133; 123 today
> 
> Remaining abstract class errors:  1; same today
> 
> Remaining stack overflow errors: 13 or so; 51  today
> 
> Total validations: 538; today 539
> 
> Future.py validations: 268
> 
> John’s style: Add wrappers (what Don calls typecasting) results:
> 
> Remaining interface errors: 3 (invalid instance passed; 0 today
> 
> Remaining abstract class errors:16 (no attribute addChild on X3DConcreteNode); 16 today
> 
> Remaining stack overflow errors: 61; 61 today
> 
> Could it be that my constructor parameters are off?
> 
> How much memory are you using on stack?
> 
> It looks like you fixed some!  Hurrah.
> 
> 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: *Wednesday, May 15, 2019 12:48 AM
> *To: *John Carlson <mailto:yottzumm at gmail.com>
> *Cc: *X3D Graphics public mailing list <mailto:x3d-public at web3d.org>
> *Subject: *Re: python pyjnius mapping
> 
> 1. [concept calibration, ensuring we are on the same sheet of music]
> 
> On 5/14/2019 4:58 AM, John Carlson wrote:
> 
>  > My version of the pipeline serializer clears up 130 of your problems in the interfaces.  My abstract classes error almost seems trivial, with only 2 sources, that I could determine, potentially clearing up 10s of problems.
> 
> Not sure what you mean here.  We are working with two mappings that your software creates, all designed cooperatively.
> 
> For the problem method, the first encoding is:
> 
>     Viewpoint27 = Viewpoint()
> 
>     Viewpoint27.setDEF("ViewUpClose")
> 
>     Viewpoint27.setCenterOfRotation([0,-1,0])
> 
>     Viewpoint27.setDescription("Hello world!")
> 
>     Viewpoint27.setPosition([0,-1,7])
> 
> while the second pipelined programming approach is:
> 
>     Viewpoint().setDEF("ViewUpClose").setCenterOfRotation(0,-1,0).setDescription("Hello world!").setPosition(0,-1,7)
> 
> These are equivalent, indeed we are compiling against the same X3DJSAIL in each case.
> 
> The first works with no complaint because the return values of each method invocation is ignored.  Thus the incorrect return type for setCenterOfRotation(0,-1,0) does not matter.
> 
> I think that the second fails because Python/pyjnius is finding an incorrect return type for setCenterOfRotation(0,-1,0) which the subsequent setDescription("Hello world!") can't be applied to.
> 
> Traceback (most recent call last):
> 
>     File "HelloWorld.future.py", line 54, 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'
> 
> oh no, that is not correct!  it is the setDEF() method that returns the incorrect return type, which the subsequent setCenterOfRotation(0,-1,0) can't operate on.
> 
> OK so that gets me closer to understanding what you were saying about setDEF.
> 
> Similar issue:  ViewpointObject setDEF() is an @Override method.
> 
>                  @Override
> 
>                  public final ViewpointObject setDEF(String newValue)
> 
> i'll take a deeper look at setDEF() lineage next time.
> 
> -----------------
> 
> 2. meanwhile tonight, i mistakenly deleted the org/* tree from the pyjnius directory.
> 
> ran makeorg.sh to restore it. console attached.
> 
> not sure what happened next, it appeared to break classes.json:
> 
> ================================================================================
> 
> create python:
> 
> node xml2all.js HelloWorld.x3d
> 
> ================================================================================
> 
> File: HelloWorld.x3d
> 
> Error: SyntaxError: Unexpected token } in JSON at position 47595
> 
>       at JSON.parse (<anonymous>)
> 
>       at PythonSerializer.serializeToString (C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\PythonSerializer.js:43:23)
> 
>       at serializeXML (C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\convertXML.js:26:25)
> 
>       at convertXML (C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\convertXML.js:55:16)
> 
>       at Object.<anonymous> (C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\xml2all.js:10:1)
> 
>       at Module._compile (internal/modules/cjs/loader.js:701:30)
> 
>       at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
> 
>       at Module.load (internal/modules/cjs/loader.js:600:32)
> 
>       at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
> 
>       at Function.Module._load (internal/modules/cjs/loader.js:531:3)
> 
> C:\x3d-code\www.web3d.org\x3d\stylesheets\java\src\python\pyjnius\convertXML.js:67
> 
>                                                                  throw("Wrote nothing, serializer returned nothing");
> 
>                                                                  ^
> 
> Wrote nothing, serializer returned nothing
> 
> Result: 1
> 
> ================================================================================
> 
> i restored classes.json via subversion and that seemed to fix things again.  not sure why makeorg failed though.
> 
> 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


More information about the x3d-public mailing list