Difference between revisions of "NodeSpace.h"

From Organic Design wiki
m
(make "code", a pointer-to-function type)
Line 4: Line 4:
 
#define CODE 5
 
#define CODE 5
 
typedef int node;
 
typedef int node;
 +
typedef void (*code)();
  
 
node nodeTraverse(node subject, node path) {
 
node nodeTraverse(node subject, node path) {
Line 43: Line 44:
 
int nodeReduce(node subject) {
 
int nodeReduce(node subject) {
 
// return if no CURRENT node (either nonexistent, or ref to node 0)
 
// return if no CURRENT node (either nonexistent, or ref to node 0)
node n;
+
node cur;
if ((n = nodeGetValue(subject, CURRENT)) == 0) return;
+
if ((cur = nodeGetValue(subject, CURRENT)) == 0) return;
nodeSetValue(subject, CURRENT, nodeGetValue(n, AND));
+
nodeSetValue(subject, CURRENT, nodeGetValue(cur, AND));
if (nodeGetValue(n, CODE)) {
+
if (nodeGetValue(cur, CODE)) {
void (*code)() = nodeGetState(n);
+
code content = nodeGetState(cur);
code();
+
content();
 
// Later this must declare and build if no function-reference
 
// Later this must declare and build if no function-reference
 
// replace self in loop with n.THEN if non-zero
 
// replace self in loop with n.THEN if non-zero
} else nodeReduce(n);
+
} else nodeReduce(cur);
 
return 1;
 
return 1;
 
}
 
}

Revision as of 01:55, 6 July 2006

  1. define CURRENT 2
  2. define AND 3
  3. define THEN 4
  4. define CODE 5

typedef int node; typedef void (*code)();

node nodeTraverse(node subject, node path) { // select node wco selNode return subject; }

// set nodal value of node/path // - path is array-of-node node nodeGetValue(node subject, node path) { node value; return value; }

void nodeSetValue(node subject, node path, node value) { }

void* nodeGetState(node subject) { void* state; return state; }

void nodeSetState(node subject, void* state) { }

node nodeInsertKey(node subject, node key) { node instance; return instance; }

void nodeRemoveKey(node subject, node key) { }

// - Consumes quanta of execution // - Creates History from change events // - Builds, declares and executes functionality // - Should reduction handle cyles (current-cycle etc), or a separate root-thread // - returns false if no more to reduce int nodeReduce(node subject) { // return if no CURRENT node (either nonexistent, or ref to node 0) node cur; if ((cur = nodeGetValue(subject, CURRENT)) == 0) return; nodeSetValue(subject, CURRENT, nodeGetValue(cur, AND)); if (nodeGetValue(cur, CODE)) { code content = nodeGetState(cur); content(); // Later this must declare and build if no function-reference // replace self in loop with n.THEN if non-zero } else nodeReduce(cur); return 1; }