// Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.CompilationUnit::printMain int main( int argc, char **argv ) { inceos_event_t op_status;// for exception handling DAL_assign( &serialiserMap,Construct_StringMap( ) ) ; initializeSerializerFunctions( ) ; initDALGlobalObjects( ) ; initUnixGlobalObjects( ) ; // Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.Sequence::complete NetStringSenderPNTR networktest_glob = NULL; DAL_assign(&networktest_glob , component_create( Construct_NetStringSender0, sizeof( NetStringSenderStruct ) , 126, 0, NULL ) ); component_yield( ) ; ; // Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.Connect::complete channel_bind( networktest_glob->input_comp,Keyboard_glob->output_comp ) ; ; // Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.Connect::complete channel_bind( networktest_glob->output_comp,NetworkSend_glob->input_comp ) ; ; // End of sequence sem_wait( &can_exit ) ; exit( 0 ) ; }
// function to construct an array IArrayPNTR Construct_Array(unsigned num_dims, unsigned type_size, void *init, bool contains_pointers, int *lengths){ //if(*lengths <= 0) return NULL; // have reached end of lengths array IArrayPNTR this = (IArrayPNTR) DAL_alloc(sizeof(IArrayStruct), true); if( this == NULL ) { DAL_error(OUT_OF_MEMORY_ERROR); return NULL; } this->decRef = Array_decRef; this->num_dims = num_dims; this->copyObject = copy_Array; this->length = lengths[0]; this->type_size = (num_dims > 1 ? sizeof(IArrayPNTR) : type_size); bool elements_are_pointers = (num_dims>1 ? true : contains_pointers); DAL_assign(&this->data, (IArrayPNTR*) (DAL_alloc(this->length * this->type_size, elements_are_pointers))); if(num_dims > 1){ // need array of arrays int i; for(i=0; i<this->length; i++){ DAL_assign( &((IArrayPNTR *) this->data)[i], Construct_Array(num_dims-1, type_size, init, contains_pointers, lengths+1)); } return this; } // if we get to here num_dims == 1 (we have got to last dim) // should fill array with init if it is not set to NULL if(init != NULL){ int i; void *pntr = this->data; for(i=0; i<this->length; i++){ memncpy(pntr, init, type_size); pntr = (((char *) pntr) + type_size); } } return this; }
NetPacket_PNTR construct_NetPacket(StringPNTR addr, AnyTypePNTR payload) { NetPacket_PNTR pntr = (NetPacket_PNTR) DAL_alloc(sizeof(NetPacket_struct), true); if(pntr == NULL) { DAL_error(OUT_OF_MEMORY_ERROR); return NULL; } pntr->_decRef = decRef_NetPacket; DAL_assign(&pntr->addr, addr); DAL_assign(&pntr->payload,payload); return pntr; }
// construct an array of given length and type_size IArrayPNTR Construct_Array(unsigned length, unsigned type_size, void *init, bool contains_pointers ) { IArrayPNTR this = (IArrayPNTR) DAL_alloc(sizeof(IArrayStruct), true); if( this == NULL ) { DAL_error(OUT_OF_MEMORY_ERROR); return NULL; } this->type_size=type_size; this->decRef=IArray_decRef; this->length=length; // set this->length (will be set to 0 if length is 0) if(length == 0) // if length is 0 ensure creation of element 0 to avoid deref length = 1; // problems, but maintain this->length = 0 DAL_assign(&this->data, DAL_alloc(type_size * length, contains_pointers)); if(this->data == NULL){ DAL_error(OUT_OF_MEMORY_ERROR); return NULL; } if(init != NULL){// initialise every element with init int i; void *pntr = this->data; for(i=0; i<length; i++){ if(contains_pointers) memncpy(pntr, &init, type_size); else memncpy(pntr, init, type_size); pntr = (((char *) pntr) + type_size); } // if init was pointer, add length n.o. refs to init's memory header if(contains_pointers) DAL_modRef_by_n(init, length); } return this; }
// Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.CompilationUnit::printMain int main( int argc, char **argv ) { inceos_event_t op_status;// for exception handling DAL_assign( &serialiserMap,Construct_StringMap( ) ) ; initializeSerializerFunctions( ) ; initDALGlobalObjects( ) ; initUnixGlobalObjects( ) ; // Generated from: uk.ac.stand.cs.insense.compiler.unixCCgen.Sequence::complete CompPNTR comp1_glob = NULL; DAL_assign(&comp1_glob , component_create( Construct_Comp0, sizeof( CompStruct ) , 86, 0, NULL ) ); component_yield( ) ; ; // End of sequence sem_wait( &can_exit ) ; exit( 0 ) ; }
void insertElement(List_PNTR l, void *element) { bool emptyList; emptyList = isEmpty(l); if(l==NULL){ DAL_error(NULL_POINTER_ERROR); return; } // putting NULL in the list is an issue if the list is supposed // to contain valid references to objects, so prevented here if(element == NULL){ DAL_error(NULL_ELEMENT_ERROR); return; } // duplicates in list are also prevented here during debug #if DEBUG if(!emptyList && containsElement(l, element)){ DAL_error(DUPLICATE_ELEMENT_ERROR); return; } #endif ListNode_PNTR newNode = Construct_ListNode(); if(newNode == NULL){ DAL_error(OUT_OF_MEMORY_ERROR); return; } DAL_assign(&newNode->payload, element); // increases ref count on element //newNode->payload = element; // or if payload not garbage collected newNode->tail = l->first; l->first = newNode; if(emptyList){ // we are about to add the first element to this list set the l->next = l->first; // iterator index to point to the first node } }
AnyTypePNTR Construct_PointerAnyType0(void* value, char* type) { AnyTypePNTR this = Construct_AnyType(); if(this != NULL){ DAL_assign(&this->value.pointer_value, value); this->type = type; } return this; }
struct_Suaddr_apayload___PNTR construct_struct_Suaddr_apayload__( unsigned addr,AnyTypePNTR payload ) { // Generated from: uk.ac.stand.cs.insense.compiler.incesosCCgen.Code::genMallocAssign struct_Suaddr_apayload___PNTR pntr=( struct_Suaddr_apayload___PNTR ) DAL_alloc( sizeof( struct_Suaddr_apayload___struct ) ,true ) ; if( pntr== NULL ) { DAL_error(OUT_OF_MEMORY_ERROR); return NULL; } pntr->_decRef=decRef_struct_Suaddr_apayload__; pntr->addr=addr; DAL_assign( &pntr->payload,payload ) ; return pntr; }