// -*- c -*- // // $Id: node_func.moc,v 1.5 2001/02/07 17:43:49 kmacleod Exp $ // @namespace a_uri some:uri @namespace itr urn:to-be-determined main () { /* [I1:1]Create a node subclass (say, MyNode) that derives from the orchard node class (say, Orchard.Node) */ id node = MyNode__new(NULL, 0); id a_value = (id)0xdeadbeef; printf ("1..6\n"); /* [I1:2]MyNode has an accessor node.node_type that is "MyNode" */ ok(@node.itr:node_type == MyNodeType, 1); /* [I1:3]create an accessor 'fubar' that combines the two properties 'foo' and 'bar' with a colon seperating them; test both set and get; note, 'foo' and 'bar' do not have accessor methods */ @node.fubar = (id)0x00010002; ok(@node.foo == (id)0x00000002, 2); ok(@node.bar == (id)0x00010000, 3); @node.foo = (id)0x10000000; @node.bar = (id)0x00002000; ok(@node.fubar == (id)0x10002000, 4); /* [I1:4]not tested -- can't possibly break */ /* [I1:5]confirm that node[(None, 'foo')] is the same (identity) as node.foo [I1:5]confirm that node[(None, 'fubar')] is the same (equality) as node.fubar Not applicable in C */ /* [I1:5]create a property node[('URI', 'blah')], testing both set and get */ @node.a_uri:a_name = a_value; ok(@node.a_uri:a_name == a_value, 5); /* [I1:5]confirm node.blah doesn't get node[('URI', 'blah')] */ ok(@node.a_name != a_value, 6); return 0; } @namespace itr urn:to-be-determined typedef id MyNode; @class MyNode(Node) @new() { self = Node__new(NULL, 0); self->isa_ = &MyNode_isa_; return self; } @.itr:node_type { return MyNodeType; } @.fubar { return (id)(((int)@self.foo) | ((int)@self.bar)); } @.fubar= { @self.foo = (id)(((int)value) & 0x0000ffff); @self.bar = (id)(((int)value) & 0xffff0000); return self; }