Receptor *__r_new(Symbol s,T *defs,T *aspects) { T *t = _t_new_root(s); _t_add(t,defs); _t_add(t,aspects); T *f = _t_newr(t,FLUX); T *a = _t_newi(f,ASPECT,DEFAULT_ASPECT); _t_newr(a,LISTENERS); _t_newr(a,SIGNALS); _t_newr(t,RECEPTOR_STATE); _t_newr(t,PENDING_SIGNALS); _t_newr(t,PENDING_RESPONSES); return __r_init(t); }
/** * @brief Creates a new receptor * * allocates all the memory needed in the heap * * @param[in] r semantic ID for this receptor * @returns pointer to a newly allocated Receptor * * <b>Examples (from test suite):</b> * @snippet spec/receptor_spec.h testReceptorCreate */ Receptor *_r_new(SemTable *sem,SemanticID r) { T *t = _t_new_root(RECEPTOR_INSTANCE); _t_news(t,INSTANCE_OF,r); if (semeq(r,SYS_RECEPTOR)) { _t_newi(t,CONTEXT_NUM,0); _t_newi(t,PARENT_CONTEXT_NUM,-1); } else { _t_newi(t,CONTEXT_NUM,_d_get_receptor_context(sem,r)); _t_newi(t,PARENT_CONTEXT_NUM,r.context); } T *state = _r_make_state(); _t_add(t,state); return __r_init(t,sem); }