<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Updated x3dinput.py attached.</p>
<p>Proceeded with eval, removed JSON_Geometry class.</p>
<p>There is no need for a x3d.py Geometry class that I know of,
except for below.<br>
</p>
<p>Regexp still needed for security purposes (no constructing
arbitrary, possibly hidden classes, please).</p>
<p>Looks good, not sure of performance at this time, we could
provide factory, dispatch table, switch, or if/elif/else for
constructing geometry. Eval seems the least secure. Perhaps we
could run some benchmarks?</p>
<p>"DOM" API for creating scenegraph "elements" seems like a good
solution.</p>
<p>Please provide direction for desired implementation. If we
continue with eval, perhaps we could apply it in more places?<br>
</p>
<p>Enjoy JSON parsing HelloWorld.json!<br>
</p>
<p>John<br>
</p>
<div class="moz-cite-prefix">On 12/7/21 09:58, John Carlson wrote:<br>
</div>
<blockquote type="cite"
cite="mid:54231bdf-2f98-8512-f52e-544161761507@gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">Don, you may
want to create a Geometry class in x3d.py like:</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">class</span><span
style="background-color: rgb(255, 255, 255);"> </span><span
style="font-weight: bold; background-color: rgb(255, 255,
255);">Geometry</span><span style="background-color:
rgb(255, 255, 255);">(</span><span style="background-color:
rgb(255, 255, 84);">_X3D</span><span
style="background-color: rgb(255, 255, 255);">GeometryNode):
</span><span style="font-weight: bold; background-color:
rgb(255, 255, 255);"></span><span style="background-color:
rgb(255, 255, 255);"></span><br>
<span style="background-color: rgb(255, 255, 255);">def</span><span
style="background-color: rgb(255, 255, 255);"> </span><span
style="font-weight: bold; background-color: rgb(255, 255,
255);">FIELD_DECLARATIONS</span><span
style="background-color: rgb(255, 255, 255);">(cls): </span><br>
<span style="background-color: rgb(255, 255, 255);">return</span><span
style="background-color: rgb(255, 255, 255);"> [] </span><span
style="background-color: rgb(255, 255, 255);"></span><br>
<span style="background-color: rgb(255, 255, 255);">def</span><span
style="background-color: rgb(255, 255, 255);"> </span><span
style="font-weight: bold; background-color: rgb(255, 255,
255);">JSON</span><span style="background-color: rgb(255,
255, 255);">(self): </span><br>
<span style="background-color: rgb(255, 255, 255);">return</span><span
style="background-color: rgb(255, 255, 255);">
self.geometry.JSON(); </span><br>
<span style="background-color: rgb(255, 255, 255);">def</span><span
style="background-color: rgb(255, 255, 255);"> </span><span
style="font-weight: bold; background-color: rgb(255, 255,
255);">XML</span><span style="background-color: rgb(255,
255, 255);">(self): </span><br>
<span style="background-color: rgb(255, 255, 255);">return</span><span
style="background-color: rgb(255, 255, 255);">
self.geometry.XML();</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);"><br>
</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">Also, we would
have to provide parsers to fill in self.geometry.</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">Or test for
self.geometry in the JSON and XML methods, or add a
constructor.</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">This is mainly
for loading the -geometry field.</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">It could be
handled in the Shape class, with eval() figuring out which
geometry constructor to call. That is okay with me!</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">Obviously,
eval is a tiny bit dangerous, even if only resolving a
class. I recommend creating a regexp that matches all node
and statement names.</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">I'm going to
proceed with eval in the Shape class for now.<br>
</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">Thanks!</span></span></p>
<p><span style="font-family:monospace"><span
style="background-color: rgb(255, 255, 255);">John<br>
</span></span></p>
</blockquote>
</body>
</html>