[vos-d] templates/macros

Peter Amstutz tetron at interreality.org
Tue Feb 19 00:12:09 EST 2008


Here's a quick brain dump of something I'm working on.  The specific 
goal is deal with the problem of parameterized types.  In this example, 
I show how one might define UInt8DynamicArrayProperty as a Property 
holding a DynamicArray of UInt8.

The idea is to set up "Template" vobjects which have TemplateParameters 
which are stand-ins for links other objects and are substituted when you 
actually create a template instance.  The "TemplateInstance" vobject 
links to the template and some set of parameters, and will have an 
"instantiate" method on it which produces a vobject structure with the 
appropriate parameter substitution.

Nothing coded yet, so this will likely change.  Incidentally, this is 
actually fairly similar to the template system coded for the original 
hypervos (which runs parts of interreality.org) so this idea of 
generalized subtree substitution is likely to be useful beyond the 
specific problem I'm trying to solve.

<vobject name="Property" type="/vos/core/Template">
  <vobject name="produces" linkTo="/vos/core/Class" />

  <vobject name="propertyType" type="/vos/core/TemplateParameter" />

  <child name="extends" type="/vos/core/Component" />

  <vobject name="value" type="/vos/core/Member">
    <child name="param" linkTo="../../propertyType" />
  </vobject>
</vobject>

<vobject name="DynamicArrayProperty" type="/vos/core/Template">
  <child name="extendsTemplate" linkTo="/vos/core/Property" />

  <vobject name="memberType" type="/vos/core/TemplateParameter" />

  <vobject name="propertyType" type="/vos/core/DynamicArray">
  	<child name="memberType" linkTo="../../memberType" />
  </vobject>

  <vobject name="size" type="/vos/core/Member">
	<child name="type" linkTo="/vos/core/UInt32" />
	<property name="readOnly" 
type="/vos/core/BooleanProperty">true</property>
  </vobject>

  <vobject name="getSlice" type="/vos/core/Method">
	<vobject name="formalParameters" type="/vos/core/Struct">
	  <vobject name="start" type="/vos/core/Member">
	    <child name="type" linkTo="/vos/core/UInt32" />
	  </vobject>
	  <vobject name="length" type="/vos/core/Member">
	    <child name="type" linkTo="/vos/core/UInt32" />
	  </vobject>
	</vobject>
	<child name="returnType" linkTo="../../../propertyType" />
  </vobject>
</vobject>

<vobject name="UInt8Property" type="/vos/core/TemplateInstance">
  <child name="template" linkTo="/vos/core/Property" />
  <child name="propertyType" linkTo="/vos/core/UInt8" />
</vobject>

<vobject name="UInt8DynamicArrayProperty" 
type="/vos/core/TemplateInstance">
  <child name="template" linkTo="/vos/core/DynamicArrayProperty" />
  <child name="memberType" linkTo="/vos/core/UInt8" />
</vobject>


-- 
[ Peter Amstutz ][ tetron at interreality.org ][peter.amstutz at tseboston.com]
[Lead Programmer][Interreality Project][Virtual Reality for the Internet]
[ VOS: Next Generation Internet Communication][ http://interreality.org ]
[ http://interreality.org/~tetron ][ pgpkey:  pgpkeys.mit.edu  18C21DF7 ]

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.interreality.org/pipermail/vos-d/attachments/20080219/496e1858/attachment.pgp 


More information about the vos-d mailing list