The Meta-Environment API
00001 #ifndef __RSCRIPT_LISTENERS__ 00002 #define __RSCRIPT_LISTENERS__ 00003 00004 #include <meta-namespace.h> 00005 #include <module-manager.tb> 00006 #include <rscript-namespace.h> 00007 #include <graph-namespace.h> 00008 #include <navigator.idef> 00009 00010 #include <rscriptchecker.idef> 00011 00012 #define BG_ERROR_COLOR rgb(224,64,60) 00013 #define BG_CHILD_ERROR_COLOR rgb(255,128,114) 00014 #define BG_CORRECT_COLOR rgb(255,255,221) 00015 #define BG_GRAYED_OUT rgb (211,211,211) 00016 00017 #define MODULE_OPENED set(RSCRIPT_NAMESPACE, "status", opened) 00018 #define MODULE_ERROR set(RSCRIPT_NAMESPACE, "status", error) 00019 #define MODULE_UNAVAILABLE set(RSCRIPT_NAMESPACE, "status", unavailable) 00020 #define MODULE_IDLE or(MODULE_OPENED,or(MODULE_UNAVAILABLE,MODULE_ERROR)) 00021 #define ALL_MODULES_IDLE and(MODULE_IDLE, all(MODULE_IDLE)) 00022 00023 process InitializeInheritedStatus is 00024 /* the first one must not have any <term> holes because of a ToolBus bug */ 00025 00026 /* Once we are opened and our kids are opened, then we become complete */ 00027 MM-RegisterAttributeUpdateRule(RSCRIPT_NAMESPACE, "status", and(set(RSCRIPT_NAMESPACE, "status", opened),all(set(RSCRIPT_NAMESPACE, "status", opened))), complete) 00028 00029 /* When we are not in error and one of our kids has an error, we become child-error */ 00030 . MM-RegisterAttributeUpdateRule(RSCRIPT_NAMESPACE, "status", and(not(set(RSCRIPT_NAMESPACE, "status", error)), one(set(RSCRIPT_NAMESPACE, "status", error))), child-error) 00031 00032 . MM-RegisterAttributeUpdateRule(META_NAMESPACE, "idle", ALL_MODULES_IDLE, yes) 00033 00034 /*Error -> Background color */ 00035 /*. MM-RegisterAttributeUpdateRule(GRAPH_NAMESPACE, "bgcolor", set(RSCRIPT_NAMESPACE, "status", error), fill-color(BG_ERROR_COLOR))*/ 00036 00037 /* Child-error -> Background color */ 00038 /*. MM-RegisterAttributeUpdateRule(GRAPH_NAMESPACE, "bgcolor", and(not(set(RSCRIPT_NAMESPACE, "status", error)), one(set(RSCRIPT_NAMESPACE, "status", error))), fill-color(BG_CHILD_ERROR_COLOR))*/ 00039 00040 toolbus(InitializeInheritedStatus) 00041 00042 process RSCRIPTModuleLabelSetter is 00043 let 00044 Event: attribute-changed-event, 00045 Extension: str, 00046 File: file, 00047 ModuleId: module-id, 00048 Modulename: str, 00049 Name: str, 00050 Prefix: str 00051 in 00052 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"name",<term>,<term>) 00053 . 00054 ( 00055 rec-note(mm-attribute-changed(Event?)) 00056 . ACE-GetModuleId(Event, ModuleId?) 00057 . ACE-GetNewValue(Event, Modulename?) 00058 . SplitFilename(Modulename, Name?, Prefix?, Extension?) 00059 . MM-SetModuleGraphAttribute(ModuleId, "label", label(Name)) 00060 . snd-msg(io-make-file(Modulename)) 00061 . rec-msg(io-file(Modulename, File?)) 00062 . MM-SetModuleGraphAttribute(ModuleId, "file", file(File)) 00063 ) 00064 * 00065 delta 00066 endlet 00067 00068 toolbus(RSCRIPTModuleLabelSetter) 00069 00070 process RSCRIPTModuleTooltipSetter is 00071 let 00072 Event: attribute-changed-event, 00073 ModuleId: module-id, 00074 Modulename: str 00075 in 00076 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"name",<term>,<term>) 00077 . 00078 ( 00079 rec-note(mm-attribute-changed(Event?)) 00080 . ACE-GetModuleId(Event, ModuleId?) 00081 . ACE-GetNewValue(Event, Modulename?) 00082 . MM-SetModuleGraphAttribute(ModuleId, "tooltip", tooltip(Modulename)) 00083 ) 00084 * 00085 delta 00086 endlet 00087 00088 toolbus(RSCRIPTModuleTooltipSetter) 00089 00090 process RSCRIPTModuleColorChanger is 00091 let 00092 Event: attribute-changed-event, 00093 ModuleId: module-id, 00094 NewPath: term, 00095 Tree: term, 00096 Value: term 00097 in 00098 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,error) 00099 . MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,child-error) 00100 . MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",error,<term>) 00101 . MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",child-error,<term>) 00102 . 00103 ( 00104 rec-note(mm-attribute-changed(Event?)) 00105 . ACE-GetModuleId(Event, ModuleId?) 00106 . ACE-GetNewValue(Event, Value?) 00107 . 00108 if equal(Value, error) then 00109 MM-SetModuleGraphAttribute(ModuleId, "bgcolor", fill-color(BG_ERROR_COLOR)) 00110 else 00111 if equal(Value,child-error) then 00112 MM-SetModuleGraphAttribute(ModuleId, "bgcolor", fill-color(BG_CHILD_ERROR_COLOR)) 00113 else 00114 MM-SetModuleGraphAttribute(ModuleId, "bgcolor", fill-color(BG_CORRECT_COLOR)) 00115 fi 00116 fi 00117 ) 00118 * 00119 delta 00120 endlet 00121 00122 toolbus(RSCRIPTModuleColorChanger) 00123 00124 process RSCRIPTModuleIconChanger is 00125 let 00126 Event: attribute-changed-event, 00127 ModuleId: module-id, 00128 Value: term 00129 in 00130 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,error) 00131 . MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",error,<term>) 00132 . 00133 ( 00134 rec-note(mm-attribute-changed(Event?)) 00135 . ACE-GetModuleId(Event, ModuleId?) 00136 . ACE-GetNewValue(Event, Value?) 00137 . 00138 if equal(Value, error) then 00139 snd-msg(nav-mark-module-error(ModuleId)) 00140 else 00141 snd-msg(nav-mark-module-normal(ModuleId)) 00142 fi 00143 ) 00144 * 00145 delta 00146 endlet 00147 00148 toolbus(RSCRIPTModuleIconChanger) 00149 00150 process RSCRIPTModuleVisualizeEditable is 00151 let 00152 Event: attribute-changed-event, 00153 ModuleId: module-id, 00154 NewPath: term, 00155 Tree: term, 00156 Value: term 00157 in 00158 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"editable",<term>,true) 00159 . MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"editable",<term>,false) 00160 . 00161 ( 00162 rec-note(mm-attribute-changed(Event?)) 00163 . ACE-GetModuleId(Event, ModuleId?) 00164 . ACE-GetNewValue(Event, Value?) 00165 . 00166 if equal(Value, quote(false)) then 00167 MM-SetModuleGraphAttribute(ModuleId, "bgcolor", fill-color(BG_GRAYED_OUT)) 00168 else 00169 MM-SetModuleGraphAttribute(ModuleId, "bgcolor", fill-color(BG_CORRECT_COLOR)) 00170 fi 00171 ) 00172 * 00173 delta 00174 endlet 00175 00176 toolbus(RSCRIPTModuleVisualizeEditable) 00177 00178 process RSCRIPTModuleParser is 00179 let 00180 Event: attribute-changed-event, 00181 ModuleId: module-id, 00182 Tree: term 00183 in 00184 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,available) 00185 . 00186 ( 00187 rec-note(mm-attribute-changed(Event?)) 00188 . ACE-GetModuleId(Event, ModuleId?) 00189 . GetRSCRIPTParsetree(ModuleId, Tree?) 00190 . 00191 if equal(Tree, UNDEFINED) then 00192 MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", error) 00193 else 00194 MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", parsed) 00195 fi 00196 . Tree := UNDEFINED 00197 ) 00198 * 00199 delta 00200 endlet 00201 00202 toolbus(RSCRIPTModuleParser) 00203 00204 process RSCRIPTModuleIdentifier is 00205 let 00206 Event: attribute-changed-event, 00207 ModuleId: module-id, 00208 Tree: term, 00209 Result: term 00210 in 00211 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,parsed) 00212 . 00213 ( 00214 rec-note(mm-attribute-changed(Event?)) 00215 . ACE-GetModuleId(Event, ModuleId?) 00216 . RSCRIPTIdentifyModule(ModuleId, Result?) 00217 . MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", Result) 00218 ) 00219 * 00220 delta 00221 endlet 00222 00223 toolbus(RSCRIPTModuleIdentifier) 00224 00225 process RSCRIPTChecker is 00226 let 00227 Event: attribute-changed-event, 00228 Summary: summary, 00229 Tree: term, 00230 ModuleId: module-id 00231 in 00232 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,parsed) 00233 . 00234 ( 00235 rec-note(mm-attribute-changed(Event?)) 00236 . ACE-GetModuleId(Event, ModuleId?) 00237 . CheckRSCRIPTModule(ModuleId) 00238 ) 00239 * 00240 delta 00241 endlet 00242 00243 toolbus(RSCRIPTChecker) 00244 00245 process RSCRIPTSetModuleImports is 00246 let 00247 Event: attribute-changed-event, 00248 Import: str, 00249 ImportId: module-id, 00250 Imports: list, 00251 ModuleId: module-id, 00252 Tree: term 00253 in 00254 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,identified) 00255 . 00256 ( 00257 rec-note(mm-attribute-changed(Event?)) 00258 . ACE-GetModuleId(Event, ModuleId?) 00259 . MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", opening) 00260 . GetRSCRIPTParsetree(ModuleId, Tree?) 00261 . MM-GetModuleDependencies(ModuleId, Imports?) 00262 . 00263 if not-equal(Imports, []) then 00264 MM-DeleteModuleDependencies(ModuleId) 00265 else 00266 tau 00267 fi 00268 . GetImportedModulenames(Tree, Imports?) 00269 . 00270 if not-equal(Imports, []) then 00271 if not-equal(Imports, []) then 00272 Import := first(Imports) 00273 . Imports := next(Imports) 00274 . OpenModule(Import, ImportId?) 00275 . MM-AddModuleDependency(ModuleId, ImportId) 00276 fi 00277 * 00278 if equal(Imports, []) then 00279 MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", opened) 00280 fi 00281 else 00282 MM-SetAttribute(ModuleId, RSCRIPT_NAMESPACE, "status", opened) 00283 fi 00284 ) 00285 * 00286 delta 00287 endlet 00288 00289 toolbus(RSCRIPTSetModuleImports) 00290 00291 process RSCRIPTRemoveDependencies is 00292 let 00293 Event: attribute-changed-event, 00294 ModuleId: module-id, 00295 Value: term 00296 in 00297 MM-Subscribe-Attribute-Changed(<module-id>,RSCRIPT_NAMESPACE,"status",<term>,unknown) 00298 . 00299 ( 00300 rec-note(mm-attribute-changed(Event?)) 00301 . ACE-GetOldValue(Event, Value?) 00302 . 00303 if not-equal(Value, undefined) then 00304 ACE-GetModuleId(Event, ModuleId?) 00305 . MM-DeleteModuleDependencies(ModuleId) 00306 else 00307 tau 00308 fi 00309 ) 00310 * 00311 delta 00312 endlet 00313 00314 toolbus(RSCRIPTRemoveDependencies) 00315 00316 #endif /* __RSCRIPT_LISTENERS__ */