$PH/COOL-LCP/pr_set_keyNotes041207.txt - RJL041207 and $PH/04s522/lcp04s/ajlopez/lcp/olc/AISetStateNotes041207.txt (linked to $CASE/04s522/ajlopez/lcp/olc/AISetStateNotes.txt) NOTE: This is not an earlier version of AISetStateNotes.txt. $CASE/gen/ver_12/sjaganat/srcMain/gen_defines.c currently has this invalid definition of pr_set_key as a simple assignment: [(tbl)->fld = (value); \\\n");] (preceded by conditional logging of this change to the database). Obviously this needs pr_unlink* and pr_link* calls to be added to generate a valid macro pr_set_key operation on an fkey field. Adding these calls, and testing them on e.g. Hominid or setGame is the project I suggested earlier to Marina.a For this case, the call to be tested could become pr_set_key(AIcurr, STid, TRcurr->STid2); iin the lcp/olc/doTransition functionof processoneevent.c. --------------------------- fprintf(schh_fp,"#define pr_set_key(tbl,fld,value) \\\n"); fprintf(schh_fp," do{\\\n"); fprintf(schh_fp," if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\\\n"); /* Sathya */ fprintf(schh_fp," {\\\n"); fprintf(schh_fp," hcg_key key_value = ( value ); \\\n"); /* Sathya */ fprintf(schh_fp," fprintf( hcg_logfileptr, \"PR_SET_KEY %%s %%s %%s\\n\",\\\n"); fprintf(schh_fp," decode_retstr( (hcg_key*)(tbl) ),\"fld\", decode_retstr(&key_value) );\\ \n");/* Sathya */ fprintf(schh_fp," }\\\n"); fprintf(schh_fp," (tbl)->fld = (value); \\\n"); fprintf(schh_fp," }while(0)\n\n"); --------------------------- However, this is not the case in any project olc subdirectory I know of. The state field of the current Active Instance is updated in file $CASE/04s522/ajlopez/lcp/olc/processevent.c by this function call sequence: ProcessOneEvent(EIid) calls DoTransition(TRcurr->STid2, AIid, EIid); DoTransition calls ActiveInstanceSetState(AIid, StateGetName(STid)); ActiveInstanceSetState (at activeinstance.h:43) Any schema.sch field can be updated by functions which are compile-time inline expansions of the SETROUTINE macro, defined for each updatable field of each schema table and field type in olc3common.h (e.g. ActiveInstanceSetState): There are 44 refs that invoke or comment on the GETROUTINE macro and 20 refs to the COPYROUTINE macro. However, there only 6 refs to SETROUTINE in $CASE/04s522/ajlopez/lcp/*/*{.c,.h}: two macro definitions (but no calls) in lcp/Team1 and lcp/olc versions of olc3common.h. ------------ In olc3common.h, these macros are well-documented: For int and float and char* fields, SETROUTINE is used: ---------------------- #define SETROUTINE(field_type, object_name, object_abbrev, field, value_type) \ FUNCTION2( \ void P3(object_name,Set,field), \ hcg_key, P(object_abbrev,id), \ value_type, value \ ) \ { \ pr_find(object_abbrev, P(object_abbrev,id), P(object_abbrev,id)); \ P(object_abbrev,curr)->field = (field_type)value; \ } ----------------------- The standard routines at activeinstance.c:70 deliver string values GETROUTINE(const char *,ActiveInstance,AI,State) COPYROUTINE(ActiveInstance,AI,State) However, I can find no invocation of SETROUTINE(hcg_key,ActiveInstance,AI,State, char*); The function ActiveInstanceSetState seems to have been custom-written at activeinstance.c:73 to do a strncpy: ----------- FUNCTION2( void ActiveInstanceSetState, hcg_key, AIid, const char *, NewState ) { pr_find(AI, AIid, AIid); //pr_find updates AIcurr - RJL041206 if (AIcurr != 0) { (void)strncpy(AIcurr->State, NewState, StatesNameMaxLen); } } -------------- Note added to olc3common.h: ------------------- /* Note by RJL 041207: TBD: olc's set macros assume strings are represented */ /* in type (struct XX) by a char* heap address, not an imbedded charstring. */ /* This is counter-intuitive to GEN's external ASCI format is a string */ /* of pre-defined length (Exception: last field of type tnn may be truncated.) */ /* TBChecked Assumption: chgen embeds space-filled char arrays in table rows, */ /* so ActiveInstanceSetState was custom-coded above. */ /* There are more efficient ways to do this. (TBD: a new macro AISetState */ /* with pointer AIcurr instead of pkey AIid as arg1.) */ ------------------