ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
Receptors

Receptors provide the fundamental coherence contexts for ceptr. More...

Files

file  group.c
 implementation of some group communication receptors
 
file  group.h
 group communication receptors header file
 
file  process.c
 implementation of ceptr processing: instructions and run tree reduction
 
file  process.h
 processing header files
 
file  protocol.c
 implementation of protocol helpers
 
file  protocol.h
 protocol helpers header file
 
file  receptor.c
 receptor implementation
 
file  receptor.h
 receptor implementation header file
 
file  scape.c
 implementation of scapes
 
file  scape.h
 scape header files
 
file  shell.c
 implementation of a command line shell receptor
 
file  shell.h
 command line shell receptor header files
 

Macros

#define __r_make_addr(p, t, a)   ___r_make_addr(p,t,a,0)
 
#define is_null_symbol(s)   ((s).semtype == 0 && (s).context == 0 && (s).id == 0)
 
#define is_null_xaddr(x)   (is_null_symbol(x.symbol) && (x).addr == 0)
 
#define is_xaddr_eq(x, y)   (semeq(x.symbol,y.symbol) && (x).addr == (y).addr)
 
#define spec_is_symbol_equal(r, got, expected)   spec_total++; if (semeq(expected,got)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %s but was %s",__FUNCTION__,__LINE__,#got,_r_get_symbol_name(r,expected),_r_get_symbol_name(r,got));}
 
#define spec_is_structure_equal(r, got, expected)   spec_total++; if (semeq(expected,got)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %s but was %s",__FUNCTION__,__LINE__,#got,_r_get_structure_name(r,expected),_r_get_structure_name(r,got));}
 
#define spec_is_process_equal(r, got, expected)   spec_total++; if (semeq(expected,got)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %s but was %s",__FUNCTION__,__LINE__,#got,_r_get_process_name(r,expected),_r_get_process_name(r,got));}
 
#define spec_is_xaddr_equal(sem, got, expected)   spec_total++; if (is_xaddr_eq(got,expected)){putchar('.');} else {putchar('F');sprintf(failures[spec_failures++],"%s:%d expected %s to be %s.%d but was %s.%d",__FUNCTION__,__LINE__,#got,!is_null_symbol(expected.symbol)?_sem_get_name(sem,expected.symbol):"0",expected.addr,!is_null_symbol(got.symbol) ? _sem_get_name(sem,got.symbol):"0",got.addr);}
 
#define __r_make_tick()   __r_make_timestamp(TICK,00)
 

Enumerations

enum  { noDeliveryErr }
 

Functions

T__r_make_definitions ()
 
T_r_make_state ()
 
Receptor_r_new (SemTable *sem, SemanticID r)
 Creates a new receptor. More...
 
Receptor_r_new_receptor_from_package (SemTable *sem, Symbol s, T *p, T *bindings)
 Creates a new receptor from a receptor package. More...
 
T__r_build_expectation (Symbol carrier, T *pattern, T *action, T *with, T *until, T *using, T *cid)
 
void _r_add_expectation (Receptor *r, Aspect aspect, Symbol carrier, T *pattern, T *action, T *with, T *until, T *using, T *cid)
 Adds an expectation to a receptor's aspect. More...
 
void __r_add_expectation (Receptor *r, Aspect aspect, T *e)
 
void _r_remove_expectation (Receptor *r, T *expectation)
 
void _r_free (Receptor *r)
 
Symbol _r_define_symbol (Receptor *r, Structure s, char *label)
 
SemanticID _r_get_sem_by_label (Receptor *r, char *label)
 
Structure _r_define_structure (Receptor *r, char *label, int num_params,...)
 
Structure __r_define_structure (Receptor *r, char *label, T *structure_def)
 
Structure __r_get_symbol_structure (Receptor *r, Symbol s)
 find a symbol's structure More...
 
size_t __r_get_symbol_size (Receptor *r, Symbol s, void *surface)
 
Process _r_define_process (Receptor *r, T *code, char *name, char *intention, T *signature, T *link)
 
Protocol _r_define_protocol (Receptor *r, T *p)
 
T_r_build_def_semtrex (Receptor *r, Symbol s)
 
int _r_def_match (Receptor *r, Symbol s, T *t)
 
Xaddr _r_new_instance (Receptor *r, T *t)
 
T_r_get_instance (Receptor *r, Xaddr x)
 
T_r_set_instance (Receptor *r, Xaddr x, T *t)
 
T_r_delete_instance (Receptor *r, Xaddr x)
 
TreeHash _r_hash (Receptor *r, Xaddr t)
 
void _r_serialize (Receptor *r, void **surfaceP, size_t *lengthP)
 
Receptor_r_unserialize (SemTable *sem, void *surface)
 
T___r_make_addr (T *parent, Symbol type, ReceptorAddress addr, bool is_run_node)
 
ReceptorAddress __r_get_addr (T *addr)
 
T__r_make_signal (ReceptorAddress from, ReceptorAddress to, Aspect aspect, Symbol carrier, T *signal_contents, UUIDt *in_response_to, T *until, T *conversation)
 
T__r_send (Receptor *r, T *signal)
 
T_r_send (Receptor *r, T *signal)
 
T_r_request (Receptor *r, T *signal, Symbol response_carrier, T *code_point, int process_id, T *cid)
 
void evaluateEndCondition (T *ec, bool *cleanup, bool *allow)
 
void __r_test_expectation (Receptor *r, T *expectation, T *signal)
 
bool __cid_equal (SemTable *sem, T *cid1, T *cid2)
 
T__cid_new (T *parent, UUIDt *c, T *topic)
 
UUIDt__cid_getUUID (T *cid)
 
T_r_add_conversation (Receptor *r, UUIDt *parent_u, UUIDt *u, T *until, T *wakeup)
 
T_r_find_conversation (Receptor *r, UUIDt *cuuid)
 
T__r_cleanup_conversation (Receptor *r, UUIDt *cuuid)
 
Error _r_deliver (Receptor *r, T *signal)
 
T__r_get_aspect (Receptor *r, Aspect aspect)
 
T__r_get_expectations (Receptor *r, Aspect aspect)
 
T__r_get_signals (Receptor *r, Aspect aspect)
 
Receptor__r_get_receptor (T *installed_receptor)
 
char * __td (Receptor *r, T *t, char *buf)
 
char * _td (Receptor *r, T *t)
 
char * _r_get_structure_name (Receptor *r, Structure s)
 
char * _r_get_symbol_name (Receptor *r, Symbol s)
 
char * _r_get_process_name (Receptor *r, Process p)
 
Receptor_r_makeStreamEdgeReceptor (SemTable *sem)
 
SocketListener_r_addListener (Receptor *r, int port, T *code, T *params, T *err_handler, char *delim)
 
void _r_addReader (Receptor *r, Stream *st, ReceptorAddress to, Aspect aspect, Symbol carrier, Symbol result_symbol, bool conversation)
 
void _r_addWriter (Receptor *r, Stream *st, Aspect aspect)
 
void _r_defineClockReceptor (SemTable *sem)
 
Receptor_r_makeClockReceptor (SemTable *sem)
 
void * ___clock_thread (void *arg)
 
T__r_make_timestamp (Symbol s, int delta)
 
void __r_kill (Receptor *r)
 
ReceptorAddress __r_get_self_address (Receptor *r)
 
void __r_dump_instances (Receptor *r)
 

Variables

Xaddr G_null_xaddr
 

Detailed Description

Receptors provide the fundamental coherence contexts for ceptr.

Function Documentation

void* ___clock_thread ( void *  arg)

bad implementation of the clock receptor thread (but easy):

  • wake up every second
  • build a TICK symbol based on the current time.
  • set the Xaddr of the current tick
Todo:
: a better implementation would be to analyze the semtrex expectations that have been planted and only wakeup when needed based on those semtrexes
Parameters
[in]theclock receptor
Todo:
this will skip some seconds over time.... make more sophisticated

Definition at line 1250 of file receptor.c.

Structure __r_define_structure ( Receptor r,
char *  label,
T structure_def 
)

define a new structure

version of _r_define_structure for complex structure defs where caller provides the STRUCTURE_DEF

Parameters
[in]rreceptor to provide a semantic context for new structure definitions
[in]sthe structure type for this symbol
[in]labela c-string label for this symbol
[in]structure_deftree of STRUCTURE_DEF structure
Returns
the new Structure

Definition at line 258 of file receptor.c.

Receptor* __r_get_receptor ( T installed_receptor)

get the Receptor structure from an installed receptor

Definition at line 1039 of file receptor.c.

size_t __r_get_symbol_size ( Receptor r,
Symbol  s,
void *  surface 
)

get the size of a symbol's surface

Returns
size

Definition at line 314 of file receptor.c.

Structure __r_get_symbol_structure ( Receptor r,
Symbol  s 
)

find a symbol's structure

Returns
structure id

Definition at line 299 of file receptor.c.

T* __r_make_signal ( ReceptorAddress  from,
ReceptorAddress  to,
Aspect  aspect,
Symbol  carrier,
T signal_contents,
UUIDt in_response_to,
T until,
T cid 
)

build a signal

Parameters
[in]fromsource Receptor Xaddr
[in]todestination Receptor Xaddr
[in]aspectAspect over which the message will be sent
[in]carrierCarrier used for matching expectations
[in]signal_contentsthe message to be sent, which will be wrapped in a BODY
[in]in_response_tooptional IN_RESPONSE_TO_UUID for request response
[in]untiloptional END_CONDITIONS for a request
[in]conversationoptional conversation id for signals that should be routed to a conversation
Todo:
signal should have timestamps

Definition at line 515 of file receptor.c.

void __r_test_expectation ( Receptor r,
T expectation,
T signal 
)

low level function for testing expectation patterns on signals and either adding a new run tree onto the current Q or reawakening the process that's been blocked waiting for the expectation to match

Definition at line 656 of file receptor.c.

void _r_add_expectation ( Receptor r,
Aspect  aspect,
Symbol  carrier,
T pattern,
T action,
T with,
T until,
T using,
T cid 
)

Adds an expectation to a receptor's aspect.

Parameters
[in]rreceptor to add to
[in]aspectaspect on which to install the expectation
[in]carrierpre-screeing of signals to match against
[in]patternsemtrex to match against signals
[in]actionprocess to run if match
[in]withparameters to pass into that process
[in]untilend conditions for cleaning up this expectation

Definition at line 164 of file receptor.c.

T* _r_build_def_semtrex ( Receptor r,
Symbol  s 
)

Walks the definition of a symbol to build a semtrex that would match that definiton

Parameters
[in]rthe receptor context in which things are defined
[in]sthe symbol to build a semtrex for
Returns
the completed semtrex

Definition at line 325 of file receptor.c.

int _r_def_match ( Receptor r,
Symbol  s,
T t 
)

Determine whether a tree matches a symbol definition, both structural and semantic

Parameters
[in]rthe receptor context in which things are defined
[in]sthe symbol we expect this tree to be
[in]tthe tree to match
Returns
true or false depending on the match
Todo:
currently this just matches on a semtrex. It should also look at the surface sizes to see if they meet the criteria of the structure definitions.

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
defineHouseLocation(r,&lat,&lon,&latlong,&house_loc);
T *t = _t_new_root(house_loc);
float x = 99.0;
T *t_lat = _t_new(t,lat,&x,sizeof(x));
T *t_lon = _t_new(t,lon,&x,sizeof(x));
T *stx = _r_build_def_semtrex(r,house_loc);
char buf[2000];
spec_is_str_equal(_dump_semtrex(r->sem,stx,buf),"/house location/(latitude,longitude)");
__t_dump(r->sem,stx,0,buf);
spec_is_str_equal(buf,"(SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:house location) (SEMTREX_SEQUENCE (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:latitude)) (SEMTREX_SYMBOL_LITERAL (SEMTREX_SYMBOL:longitude))))");
// a correctly structured tree should match its definition
spec_is_true(_r_def_match(r,house_loc,t));
// a correctly structured tree with different semantics shouldn't match its definition
t_lon->contents.symbol = lat;
spec_is_true(!_r_def_match(r,house_loc,t));
// an incorrectly structured tree (i.e. missing a child) shouldn't match its definition
spec_is_true(!_r_def_match(r,house_loc,t));
_t_free(stx);
_t_free(t);
_t_free(t_lon);
_r_free(r);

Definition at line 343 of file receptor.c.

Process _r_define_process ( Receptor r,
T code,
char *  name,
char *  intention,
T signature,
T link 
)

add a new process coding to a receptor

Parameters
[in]rthe receptor
[in]codethe code tree for this process
[in]namethe name of the process
[in]intentiona description of what the process intends to do/transform
[in]signaturethe signature for the process
[in]linkthe output signature for the process
Returns
the new Process

Definition at line 275 of file receptor.c.

Structure _r_define_structure ( Receptor r,
char *  label,
int  num_params,
  ... 
)

define a new structure (simple version)

this call is handy for building simple STRUCTURE_SEQUENCE style structures

Parameters
[in]rreceptor to provide a semantic context for new structure definitions
[in]sthe structure type for this symbol
[in]labela c-string label for this symbol
[in]num_paramsnumber of symbols in the structure
[in]...variable list of Symbol type symbols
Returns
the new Structure

Definition at line 236 of file receptor.c.

Symbol _r_define_symbol ( Receptor r,
Structure  s,
char *  label 
)

define a new symbol

Parameters
[in]rreceptor to provide a structural context for symbol declarations
[in]sthe structure type for this symbol
[in]labela c-string label for this symbol
Returns
the new Symbol

Definition at line 218 of file receptor.c.

T* _r_delete_instance ( Receptor r,
Xaddr  x 
)

delete the instance for a given xaddr

Parameters
[in]rthe receptor context in which things are defined
[in]xthe xaddr of the instance

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
defineHouseLocation(r,&lat,&lon,&latlong,&house_loc);
// create a house location tree
T *t = _t_new_root(house_loc);
float ll[] = {132.5,92.3};
T *t_lat = _t_new(t,lat,&ll[0],sizeof(float));
T *t_lon = _t_new(t,lon,&ll[1],sizeof(float));
spec_is_equal(x.addr,1);
spec_is_sem_equal(x.symbol,house_loc);
float *ill;
T *i = _r_get_instance(r,x);
wjson(r->sem,i,"houseloc",-1);
spec_is_ptr_equal(i,t);
i = _r_get_instance(r,x);
spec_is_ptr_equal(i,NULL);
_r_free(r);

Definition at line 407 of file receptor.c.

Error _r_deliver ( Receptor r,
T signal 
)

Send a signal to a receptor

This function checks to see if the signal is a response and if so activates the run-tree/action that's waiting for that response with the signal contents as the response value/param or, if it's a new signal, adds it to the flux, and then runs through all the expectations on the aspect the signal was sent on to see if it matches any expectation, and if so, builds action run-trees and adds them to receptor's process queue.

Parameters
[in]rdestination receptor
[in]signalsignal to be delivered to the receptor
Todo:
for now the signal param is added directly to the flux. Later it should probably be cloned? or there should be a parameter to choose?
Returns
Error
Todo:
figure out what kinds of errors could be returned by _r_deliver

Examples (from test suite):

Definition at line 954 of file receptor.c.

void _r_free ( Receptor r)

Destroys a receptor freeing all the memory it uses.

Definition at line 186 of file receptor.c.

T* _r_get_instance ( Receptor r,
Xaddr  x 
)

retrieve the instance for a given xaddr

Parameters
[in]rthe receptor context in which things are defined
[in]xthe xaddr of the instance
Returns
the instance tree

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
defineHouseLocation(r,&lat,&lon,&latlong,&house_loc);
// create a house location tree
T *t = _t_new_root(house_loc);
float ll[] = {132.5,92.3};
T *t_lat = _t_new(t,lat,&ll[0],sizeof(float));
T *t_lon = _t_new(t,lon,&ll[1],sizeof(float));
spec_is_equal(x.addr,1);
spec_is_sem_equal(x.symbol,house_loc);
float *ill;
T *i = _r_get_instance(r,x);
wjson(r->sem,i,"houseloc",-1);
spec_is_ptr_equal(i,t);
i = _r_get_instance(r,x);
spec_is_ptr_equal(i,NULL);
_r_free(r);

Definition at line 379 of file receptor.c.

SemanticID _r_get_sem_by_label ( Receptor r,
char *  label 
)

find a symbol by its label

Definition at line 288 of file receptor.c.

TreeHash _r_hash ( Receptor r,
Xaddr  t 
)

get the hash of a tree by Xaddr

Definition at line 414 of file receptor.c.

Receptor* _r_new ( SemTable sem,
SemanticID  r 
)

Creates a new receptor.

allocates all the memory needed in the heap

Parameters
[in]rsemantic ID for this receptor
Returns
pointer to a newly allocated Receptor

Examples (from test suite):

r = _r_new(G_sem,TEST_RECEPTOR);
spec_is_symbol_equal(r,_t_symbol(r->root),RECEPTOR_INSTANCE);
T *t;
// test that expectations and signals are set up correctly on the default aspect
t = __r_get_expectations(r,DEFAULT_ASPECT);
spec_is_symbol_equal(r,_t_symbol(t),EXPECTATIONS);
t = __r_get_signals(r,DEFAULT_ASPECT);
spec_is_symbol_equal(r,_t_symbol(t),SIGNALS);
// test that the flux is set up correctly
int p[] = {ReceptorInstanceStateIdx,ReceptorFluxIdx,TREE_PATH_TERMINATOR};
t = _t_get(r->root,p);
spec_is_symbol_equal(r,_t_symbol(r->flux),FLUX);
spec_is_ptr_equal(t,r->flux);
t = _t_child(r->flux,1);
spec_is_symbol_equal(r,_t_symbol(t),DEFAULT_ASPECT);
spec_is_str_equal(t2s(r->root),"(RECEPTOR_INSTANCE (INSTANCE_OF:TEST_RECEPTOR) (CONTEXT_NUM:3) (PARENT_CONTEXT_NUM:0) (RECEPTOR_STATE (FLUX (DEFAULT_ASPECT (EXPECTATIONS) (SIGNALS))) (PENDING_SIGNALS) (PENDING_RESPONSES) (CONVERSATIONS) (RECEPTOR_ELAPSED_TIME:0)))");
_r_free(r);

Definition at line 88 of file receptor.c.

Xaddr _r_new_instance ( Receptor r,
T t 
)

Create a new instance of a tree

Parameters
[in]rthe receptor context in which things are defined
[in]tthe tree to instantiate
Returns
xaddr of the instance
Todo:
currently stores instances in a hash of hashes, this will later be handled by interacting with the data-engine.

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
defineHouseLocation(r,&lat,&lon,&latlong,&house_loc);
// create a house location tree
T *t = _t_new_root(house_loc);
float ll[] = {132.5,92.3};
T *t_lat = _t_new(t,lat,&ll[0],sizeof(float));
T *t_lon = _t_new(t,lon,&ll[1],sizeof(float));
spec_is_equal(x.addr,1);
spec_is_sem_equal(x.symbol,house_loc);
float *ill;
T *i = _r_get_instance(r,x);
wjson(r->sem,i,"houseloc",-1);
spec_is_ptr_equal(i,t);
i = _r_get_instance(r,x);
spec_is_ptr_equal(i,NULL);
_r_free(r);

Definition at line 365 of file receptor.c.

Receptor* _r_new_receptor_from_package ( SemTable sem,
Symbol  s,
T p,
T bindings 
)

Creates a new receptor from a receptor package.

allocates all the memory needed in the heap, cloning the various parts from the package and binding the new receptor to the provided bindings

Parameters
[in]ssymbol for this receptor
Returns
pointer to a newly allocated Receptor
Todo:
implement bindings

Definition at line 114 of file receptor.c.

T* _r_request ( Receptor r,
T signal,
Symbol  response_carrier,
T code_point,
int  process_id,
T cid 
)

send a request signal

Parameters
[in]rsending receptor
[in]signalSignal tree
[in]response_carrierthe carrier on which to expect a response
[in]code_pointthe point in the code to re-awaken when a response comes back
[in]process_idthe id of the process in which that code point exists
Returns
a clone of the UUID of the message sent.
Todo:
signal should have timestamps and other meta info

Definition at line 575 of file receptor.c.

T* _r_send ( Receptor r,
T signal 
)

send a simple signal (say)

Parameters
[in]rthe receptor sending the signal
[in]signalSignal tree
Returns
a clone of the UUID of the message sent.

Definition at line 556 of file receptor.c.

void _r_serialize ( Receptor r,
void **  surfaceP,
size_t *  lengthP 
)

Serialize a receptor

Allocates a buffer for and serializes a receptor into the buffer

Parameters
[in]rReceptor to serialize
[in,out]surfacePpointer to a void * to hold the resulting serialized data
[in,out]lengthPpointer to a size_t to hold the resulting serialized data length

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
lat = _r_get_sem_by_label(r,"latitude");
lon = _r_get_sem_by_label(r,"longitude");
house_loc = _r_get_sem_by_label(r,"house location");
latlong = _r_get_sem_by_label(r,"latlong");
// create a house location tree
T *t = _t_new_root(house_loc);
float ll[] = {132.5,92.3};
T *t_lat = _t_new(t,lat,&ll[0],sizeof(float));
T *t_lon = _t_new(t,lon,&ll[1],sizeof(float));
// also add a sub-receptor as an instance so we can test proper
// serialization of nested receptors
Receptor *r2 = _r_new(G_sem,TEST_RECEPTOR);
T *ir = _t_new_receptor(0,TEST_RECEPTOR,r2);
Xaddr xr = _r_new_instance(r,ir);
T *t2 = _t_newi(0,TEST_INT_SYMBOL,314);
Xaddr x2 = _r_new_instance(r2,t2);
void *surface;
size_t length;
char buf[2000];
char buf1[2000];
T *signal_contents = _t_newi(0,TEST_INT_SYMBOL,314);
ReceptorAddress from = {3}; // DUMMY ADDR
ReceptorAddress to = {4}; // DUMMY ADDR
// add a signal too
T *s = __r_make_signal(from,to,DEFAULT_ASPECT,TESTING,signal_contents,0,0,0);
_r_deliver(r,s);
_r_serialize(r,&surface,&length);
// serialized receptor is two stacked serialized mtrees, first one for the state tree
// and then the second for the receptor's instances
S *s1 = (S *)surface;
S *s2 = (S *)(surface + s1->total_size);
spec_is_long_equal(length,s1->total_size+s2->total_size);
// spec_is_long_equal(length,250);
// spec_is_long_equal(*(size_t *)surface,250);
Receptor *ru = _r_unserialize(G_sem,surface);
// __r_dump_instances(r);
// __r_dump_instances(ru);
// check that the structures look the same by comparing a string dump of the two
// receptors
__t_dump(r->sem,r->root,0,buf);
__t_dump(ru->sem,ru->root,0,buf1);
spec_is_str_equal(buf1,buf);
// check flux
spec_is_sem_equal(_t_symbol(ru->flux),FLUX);
spec_is_sem_equal(_t_symbol(ru->pending_signals),PENDING_SIGNALS);
spec_is_sem_equal(_t_symbol(ru->pending_responses),PENDING_RESPONSES);
// check that the unserialized receptor is matched up to the correct definitions in the semtable
spec_is_sem_equal(_r_get_sem_by_label(ru,"latitude"),lat);
spec_is_sem_equal(_r_get_sem_by_label(ru,"latlong"),latlong);
// check that the unserialized receptor has all the instances loaded into the instance store too
T *t1 = _r_get_instance(ru,x);
buf[0] = buf1[0] = 0;
__t_dump(r->sem,t,0,buf);
__t_dump(ru->sem,t1,0,buf1);
spec_is_str_equal(buf1,buf);
t1 = _r_get_instance(ru,xr);
spec_is_true(t1 != NULL);
if (t1) {
buf[0] = buf1[0] = 0;
__t_dump(r->sem,ir,0,buf);
__t_dump(ru->sem,t1,0,buf1);
spec_is_str_equal(buf1,buf);
t1 = _r_get_instance(r3,x2);
spec_is_equal(*(int*)_t_surface(t1),314);
_r_free(ru);
}
//__r_dump_instances(r3); // show the 314 int
free(surface);
_r_free(r);

Definition at line 432 of file receptor.c.

T* _r_set_instance ( Receptor r,
Xaddr  x,
T t 
)

set the instance for a given xaddr

Parameters
[in]rthe receptor context in which things are defined
[in]xthe xaddr of the instance
[in]tthe new tree to set the instance value to
Returns
the instance tree

Examples (from test suite):

Receptor *r = _r_new(G_sem,TEST_RECEPTOR);
Symbol lat,lon,house_loc;
Structure latlong;
defineHouseLocation(r,&lat,&lon,&latlong,&house_loc);
// create a house location tree
T *t = _t_new_root(house_loc);
float ll[] = {132.5,92.3};
T *t_lat = _t_new(t,lat,&ll[0],sizeof(float));
T *t_lon = _t_new(t,lon,&ll[1],sizeof(float));
spec_is_equal(x.addr,1);
spec_is_sem_equal(x.symbol,house_loc);
float *ill;
T *i = _r_get_instance(r,x);
wjson(r->sem,i,"houseloc",-1);
spec_is_ptr_equal(i,t);
i = _r_get_instance(r,x);
spec_is_ptr_equal(i,NULL);
_r_free(r);

Definition at line 394 of file receptor.c.

Receptor* _r_unserialize ( SemTable sem,
void *  surface 
)

Unserialize a receptor

Given a serialized receptor, return an instantiated receptor tree

Parameters
[in]surfaceserialized receptor data
Returns
Receptor

Definition at line 459 of file receptor.c.