/[ascend]/trunk/base/generic/packages/defaultall.c
ViewVC logotype

Diff of /trunk/base/generic/packages/defaultall.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1302 by johnpye, Mon Feb 26 06:20:43 2007 UTC revision 1303 by johnpye, Thu Mar 1 06:04:21 2007 UTC
# Line 43  Line 43 
43  #include <compiler/watchpt.h>  #include <compiler/watchpt.h>
44  #include <compiler/initialize.h>  #include <compiler/initialize.h>
45    
46    /* #define DEFAULT_DEBUG */
47    
48  /**  /**
49      Find atom children in the present model and set them to their ATOM DEFAULT      Find atom children in the present model and set them to their ATOM DEFAULT
50      values.      values.
# Line 56  int Asc_DefaultSelf1(struct Instance *in Line 58  int Asc_DefaultSelf1(struct Instance *in
58      /* default any child atoms' values */      /* default any child atoms' values */
59      n = NumberChildren(inst);      n = NumberChildren(inst);
60      for(i = 1; i <= n; ++i){      for(i = 1; i <= n; ++i){
61    #ifdef DEFAULT_DEBUG
62          CONSOLE_DEBUG("Child %d...", i);          CONSOLE_DEBUG("Child %d...", i);
63    #endif
64          c = InstanceChild(inst,i);          c = InstanceChild(inst,i);
65            if(c==NULL)continue;
66    
67          type = InstanceTypeDesc(c);          type = InstanceTypeDesc(c);
68          if(BaseTypeIsAtomic(type)){          if(BaseTypeIsAtomic(type)){
69              if(!AtomDefaulted(type))continue;              if(!AtomDefaulted(type))continue;
# Line 69  int Asc_DefaultSelf1(struct Instance *in Line 75  int Asc_DefaultSelf1(struct Instance *in
75                  case set_type: /* what is the mechanism for defaulting of sets? */                  case set_type: /* what is the mechanism for defaulting of sets? */
76                  default: ASC_PANIC("invalid type");                  default: ASC_PANIC("invalid type");
77              }              }
78    #ifdef DEFAULT_DEBUG
79              CONSOLE_DEBUG("Reset atom to default value");              CONSOLE_DEBUG("Reset atom to default value");
80    #endif
81          }else if(GetBaseType(type)==array_type){          }else if(GetBaseType(type)==array_type){
82              /* descend into arrays */              /* descend into arrays */
83              Asc_DefaultSelf1(c);              Asc_DefaultSelf1(c);
# Line 99  int Asc_DefaultAll1(struct Instance *ins Line 107  int Asc_DefaultAll1(struct Instance *ins
107      n = NumberChildren(inst);      n = NumberChildren(inst);
108      for(i = 1; i <= n; ++i){      for(i = 1; i <= n; ++i){
109          c = InstanceChild(inst,i);          c = InstanceChild(inst,i);
110            if(c==NULL)continue;
111    
112          type = InstanceTypeDesc(c);          type = InstanceTypeDesc(c);
113          if(model_type == GetBaseType(type)){          if(model_type == GetBaseType(type)){
114              /* run 'default_all' for all child models */              /* run 'default_all' for all child models */
115              method = FindMethod(type,data->default_all);              method = FindMethod(type,data->default_all);
116              if(method){              if(method){
117    #ifdef DEFAULT_DEBUG
118                  CONSOLE_DEBUG("Running default_all on '%s'",SCP(GetName(type)));                  CONSOLE_DEBUG("Running default_all on '%s'",SCP(GetName(type)));
119    #endif
120                  pe = Initialize(c , CreateIdName(ProcName(method)), "__not_named__"                  pe = Initialize(c , CreateIdName(ProcName(method)), "__not_named__"
121                      ,ASCERR                      ,ASCERR
122                      ,0, NULL, NULL                      ,0, NULL, NULL
123                  );                  );
124                  if(pe!=Proc_all_ok)err += 1;                  if(pe!=Proc_all_ok)err += 1;
125              }else{              }else{
126    #ifdef DEFAULT_DEBUG
127                  CONSOLE_DEBUG("Recursing into array...");                  CONSOLE_DEBUG("Recursing into array...");
128    #endif
129                  ERROR_REPORTER_HERE(ASC_PROG_ERR,"No 'default_all' found for type '%s'",SCP(GetName(type)));                  ERROR_REPORTER_HERE(ASC_PROG_ERR,"No 'default_all' found for type '%s'",SCP(GetName(type)));
130                  return 1;                  return 1;
131              }              }

Legend:
Removed from v.1302  
changed lines
  Added in v.1303

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22