00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 typeof DMSdebug=fun [S] I;
00035
00036 struct InitialTag{
00037 cbITag (fun [S [User r1]] I);modITag (DMI);timeoutITag (I);
00038 };
00039 typedef struct mkInitialTag InitialTag;
00040 struct ServerTag{
00041 idSTag (I);flagSTag (I);
00042 };
00043 typedef struct mkServerTag ServerTag;
00044
00045 typedef Tag=
00046 localTag InitialTag
00047 |serverTag ServerTag;;
00048
00049 typeof listSentTags=[TagToServer r1];
00050 struct TagToServer{
00051 baseTTS (Tag);idTTS (I);timeoutTTS (I);
00052 };
00053 typedef struct mkTagToServer TagToServer;
00054
00055
00056 typedef Pending=
00057 actionPending [DMI S S S [User r1] Tag]
00058 |msgPending S
00059 |hookPending I;;
00060
00061 struct DMI{
00062 numDMI (I);chnDMI (Chn);nameDMI (S);classDMI (S);stateDMI (I);
00063 sonsDMI ([DMI r1]);fatherDMI (DMI);
00064 linkDMI ([[S I S S S] r1]);
00065 eventsDMI ([S r1]);
00066 paramDMI (S);
00067 zonesDMI ([[S r1] r1]);
00068 beforecloseDMI (fun[] I);
00069 actionDMI (fun [DMI S S S] I); actionsDMI ([[S fun [DMI S S [User r1] Tag] I] r1]);
00070 fifoDMI ([[Pending r1] [Pending r1]]);
00071
00072 controlDMI ([[S r1] r1]);controlbufDMI (S);listDMI ([RSC r1]);curDMI (RSC);
00073
00074 ulistDMI ([UserI r1]);uclassDMI ([[DMI S] r1]);cbUcreateDMI (fun [UserI] I);
00075
00076 locDMI (tab [[S S] r1]);langDMI (S);
00077 neededDMI ([S r1]);neededbufDMI (S);thmDMI ([[S r1] r1]
00078 );
00079 };
00080 typedef struct mkDMI DMI;
00081
00082 struct User{
00083 idU (I);flagU (I);
00084 };
00085 typedef struct mkUser User;
00086
00087 struct VTree{
00088 commutVT (I);rightsVT ([S r1]);
00089 };
00090 typedef struct mkVTree VTree;
00091
00092 typedef Visibility=
00093 treeVisibility VTree;;
00094
00095 struct UserI{
00096 userUI (User);classUI (S);paramUI ([[S r1]r1]);locUI (DMI);
00097 cbDeleteUI (fun[UserI] I);cbCommUI (fun[UserI S S] I); msgUI ([[S fun[UserI S S] I] r1]);
00098 cbChgUI (fun[UserI I S] I);visiUI (Visibility);
00099
00100 uclassUI (DMI);cbClassDeleteUI (fun[UserI] I);cbClassCommUI (fun[UserI S S] I
00101 );
00102 };
00103 typedef struct mkUserI UserI;
00104
00105
00106 typeof this=DMI;
00107
00108 typeof DMSserver=Chn;
00109
00110 typeof DMSnbDmi=I;
00111
00112 typeof DMSdmi=[[I DMI] r1];
00113
00114 var DMIok=0;
00115 var DMIwait=1;
00116 var DMIoff=2;
00117 var DMIhook=3;
00118
00119
00120 defcom Cgoto=goto S;;
00121 defcom Clang=lang S;;
00122 defcom Center=enter I I S S S;;
00123 defcom Cping=ping;;
00124 defcom Csend=send I S;;
00125 defcom Cevent=event I S S S S I;;
00126 defcom CcliDel=cliDel I;;
00127 defcom CsendUI=sendUI I I S S;;
00128 defcom Cdeltag=deltag I;;
00129 defcom Cfiretag=firetag I S S;;
00130 defcom Chook=hook I I S I;;
00131 defcom Cdestroyed=destroyed;;
00132 defcom Clogin=login S;;
00133
00134
00135 defcom SIniDMI=IniDMI S;;
00136 defcom Sreg=reg I;;
00137 defcom Sregch=regch;;
00138 defcom Sload=_load S;;
00139
00140
00141 proto _DMSgetByHandle=fun[I] DMI;
00142 proto _on_=fun[u0 Comm] I;
00143 proto _DMSrootModule=fun[] DMI;
00144
00145
00146
00147
00148
00149 niltest(a,b){
00150 if a==nil then b else a;
00151 }
00152
00153
00154 Tunder(s){
00155 if strcmp s "_" then s else nil;
00156 }
00157
00158
00159 swbystr(a,b){
00160 let a->[x _] in !strcmp x b;
00161 }
00162
00163
00164 getSwitchStr(l,s){
00165 search_in_list l @swbystr s;
00166 }
00167
00168
00169
00170 typeof hookInactiveList=[[I [[S I] r1]] r1];
00171 var newHookid=0;
00172
00173
00174 _newHook(){
00175 set newHookid=newHookid+1;
00176 }
00177
00178
00179 var tagnumber=0;
00180 newtagnumber(){
00181 set tagnumber=tagnumber+1;
00182 }
00183
00184
00185 conc(p,q){
00186 if p==nil then q else (hd p)::conc tl p q;
00187 }
00188
00189
00190
00191 strFindList(l,a){
00192 if l==nil then 0 else let l->[x n] in
00193 if !strcmp a x then 1 else strFindList n a;
00194 }
00195
00196
00197
00198 getUlist(l){
00199 if l==nil then nil else let l->[u nxt] in
00200 (itoa u.idU)::getUlist nxt;
00201 }
00202
00203
00204 getUliststring(l){
00205 if l==nil then nil
00206 else strbuild (getUlist l)::nil;
00207 }
00208
00209
00210
00211 sendServerTag(t){
00212 if t==nil then nil else
00213 match t with
00214 (localTag x -> let newtagnumber -> id in
00215 (set listSentTags=(mkTagToServer [t id x.timeoutITag])::listSentTags;
00216 id));
00217 }
00218
00219
00220 _DMStagKeepAlive(t){
00221 match t with
00222 (serverTag x -> set x.flagSTag=1);
00223 }
00224
00225
00226 makeLocalTag(d,tag){
00227 if tag==nil then nil
00228 else let tag->[cb timeout _] in localTag mkInitialTag [cb d time+timeout];
00229 }
00230
00231
00232 _on_(srv,msg){
00233 _on DMSserver msg;
00234 }
00235
00236
00237 _DMSrootModule(){
00238 switch DMSdmi 0;
00239 }
00240
00241
00242 _DMSgetByHandle(h){
00243 switch DMSdmi h;
00244 }
00245
00246
00247 _DMSdefineActions(d,l){
00248 set d.actionsDMI=conc l d.actionsDMI;
00249 }
00250
00251
00252 _DMSremoveActions(d,l){
00253 if l==nil then 0
00254 else let getSwitchStr d.actionsDMI hd l -> x in
00255 (if x==nil then nil else set d.actionsDMI=remove_from_list d.actionsDMI x;
00256 _DMSremoveActions d tl l);
00257 }
00258
00259
00260 _DMSfindActionStartedByName(l, name){
00261 let sizelist l -> size in
00262 let nil -> ndata in
00263 let 0 -> i in
00264 (
00265 while i < size do
00266 (
00267 let nth_list l i -> [action _ ] in
00268 if (strcmp name (substr action 0 (strlen name))) then nil else
00269 set ndata = conc ndata action::nil;
00270
00271 set i = i + 1;
00272 );
00273 ndata;
00274 );
00275 }
00276
00277
00278 _DMSremoveActionStartedByName(d, name){
00279 let _DMSfindActionStartedByName d.actionsDMI name -> l in
00280 _DMSremoveActions d l;
00281 }
00282
00283
00284 removeDmiById(id){
00285 let sizelist DMSdmi -> size in
00286 let nil -> ndata in
00287 let 0 -> i in
00288 (
00289 while i < size do
00290 (
00291 let nth_list DMSdmi i -> elem in
00292 let elem -> [eid _] in
00293 if eid == id then nil else
00294 set ndata = conc ndata elem::nil;
00295 set i = i + 1;
00296 );
00297 set DMSdmi = ndata;
00298 );
00299 0;
00300 }
00301
00302
00303 addDmiById(id, d){
00304 let switch DMSdmi id -> dd in
00305 if dd == nil then nil else
00306 removeDmiById id;
00307
00308 set DMSdmi = conc DMSdmi [id d]::nil;
00309 d;
00310 }
00311
00312
00313 cbDebugConsol(mess){
00314 _fooS strcat ">>>>>>>>>>>>>> Mini DHDMS debug > " mess;
00315 0;
00316 }
00317
00318
00319 createDMI(){
00320 let switch DMSdmi 0 -> old in
00321 let mkDMI [0 _channel "root" "root" 0
00322 nil nil
00323 nil nil
00324 nil
00325 nil
00326 nil nil nil
00327 old.fifoDMI
00328 nil nil nil nil
00329 nil nil nil
00330 nil nil nil nil nil]
00331 ->d in
00332 (
00333 addDmiById 0 d;
00334
00335 set DMSdebug = @cbDebugConsol;
00336 set this = _DMSrootModule;
00337 set DMSserver = _channel;
00338 );
00339 }
00340
00341
00342
00343 fireEvent2(d,args,k){
00344 if d==nil then nil
00345 else if d.stateDMI!=DMIok || (k && d.fifoDMI!=nil) then
00346 (set d.fifoDMI=addFifo args d.fifoDMI;
00347 match args with (actionPending [_ _ _ _ _ tag] -> _DMStagKeepAlive tag);
00348 0)
00349 else
00350 match args with
00351 (actionPending [from act para repl ulist tag] ->
00352 (
00353 exec DMSdebug with [strcatn "Action : "::act::" with param : "::(if para == nil then "NIL" else para)::nil];
00354 if d.actionDMI==nil then execch d.chnDMI switchstr d.actionsDMI act [from act para ulist tag]
00355 else execch d.chnDMI d.actionDMI [from act para repl];
00356 )
00357 )
00358 |(msgPending c -> _scriptc d.chnDMI strcat "__" c)
00359 |(_->nil);
00360 }
00361
00362
00363 fireEvent(i,args){
00364 let _DMSgetByHandle i -> d in
00365 if d==nil then
00366 match args with
00367 (
00368 actionPending [from act _ _ _ tag] ->
00369
00370 if 0==switchstr (switch hookInactiveList i) act
00371 then let _newHook -> n in
00372 (
00373 set d=mkDMI [i nil nil nil DMIhook nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil nil];
00374
00375 addDmiById i d;
00376
00377 set d.fifoDMI=addFifo hookPending n d.fifoDMI;
00378 set d.fifoDMI=addFifo args d.fifoDMI;
00379 _on_ nil Chook [from.numDMI i act n];
00380 _DMStagKeepAlive tag;
00381 nil
00382 )
00383 else nil
00384 )
00385 else fireEvent2 d args 1;
00386 }
00387
00388
00389 DMSevent3(from,param,reply,ulist,tag,l,event){
00390 if l==nil then 0
00391 else let l->[[ev num action param2 reply2] nxt] in
00392 (if strcmp ev event then nil
00393 else
00394
00395 let if param2 == nil then param else param2 -> param in
00396 (
00397 exec DMSdebug with [strcatn "Event : "::ev::" with param : "::(if param == nil then "NIL" else param)::nil];
00398 fireEvent num actionPending [from action niltest param param2 niltest reply reply2 ulist tag];
00399 );
00400 DMSevent3 from param reply ulist tag nxt event);
00401 }
00402
00403
00404 DMSevent2(d,ev,para,repl,ulist,tag){
00405 if strFindList d.eventsDMI ev then _on_ nil Cevent [d.numDMI ev para repl getUliststring ulist sendServerTag tag] else nil;
00406 DMSevent3 d para repl ulist tag d.linkDMI ev;
00407 }
00408
00409
00410 _DMSevent(d,ev,para,repl){
00411 DMSevent2 d ev para repl nil nil;
00412 }
00413
00414
00415 _DMSeventTag(d,ev,param,ulist,tag){
00416 DMSevent2 d ev param nil ulist makeLocalTag d tag;
00417 }
00418
00419
00420 getModLinkByLink(event, action, param, reply){
00421 let sizelist this.linkDMI -> size in
00422 let nil -> ndata in
00423 let 0 -> i in
00424 (
00425 while i < size && ndata == nil do
00426 (
00427 let nth_list this.linkDMI i -> link in
00428 let link -> [oevent onum oaction oparam oreply] in
00429 (
00430 if (!strcmp oevent event) && (onum == 0) && (!strcmp oaction action) && (!strcmp oparam param) then
00431 set ndata = link
00432 else nil;
00433 );
00434 set i = i + 1;
00435 );
00436 ndata;
00437 );
00438 }
00439
00440
00441 delModLink(slink){
00442 let hd strextr slink -> [nevent [naction [nparam [nreply [ncond _]]]]] in
00443 let getModLinkByLink nevent naction (Tunder nparam) (Tunder nreply) -> link in
00444 set this.linkDMI = remove_from_list this.linkDMI link;
00445 0;
00446 }
00447
00448
00449 setModLink(oldlink, newlink){
00450 let hd strextr oldlink -> [oevent [oaction [oparam [oreply [ocond _]]]]] in
00451 let hd strextr newlink -> [nevent [naction [nparam [nreply [ncond _]]]]] in
00452 let getModLinkByLink nevent naction (Tunder nparam) (Tunder nreply) -> existlink in
00453 if existlink != nil then
00454 (
00455 0;
00456 )
00457 else
00458 (
00459 if oldlink == nil then
00460 (
00461
00462 set this.linkDMI = conc this.linkDMI [nevent 0 naction (Tunder nparam) (Tunder nreply)]::nil;
00463 1;
00464 )
00465 else
00466 (
00467 let getModLinkByLink oevent oaction (Tunder oparam) (Tunder oreply) -> olink in
00468 (
00469 set this.linkDMI = remove_from_list this.linkDMI olink;
00470 set this.linkDMI = conc this.linkDMI [nevent 0 naction (Tunder nparam) (Tunder nreply)]::nil;
00471 );
00472 1;
00473 );
00474 );
00475 }
00476
00477
00478 clearModLinks(){
00479 set this.linkDMI = nil;
00480 0;
00481 }
00482
00483
00484
00485
00486
00487 UsendMessage(p1, p2, p3){
00488 0;
00489 }
00490
00491 piUi(p1){
00492 0;
00493 }
00494
00495 UcbMessage(p1, p2){
00496 0;
00497 }
00498
00499 UgetParam(p1, p2){
00500 ""::nil;
00501 }
00502
00503 UsendSrv(d, ui, sid, params){
00504 0;
00505 }
00506
00507
00508 UcbComm(d, ui, cbfun){
00509 0;
00510 }
00511
00512
00513 listcat(p, q){
00514 if p==nil then
00515 q
00516 else
00517 (hd p)::listcat (tl p) q;
00518 }
00519
00520
00521
00522
00523
00524 typeof s3dMainSession=V3Dsession;
00525 typeof v3dMain=V3Dview;
00526
00527 struct C3DXdata{
00528
00529 C3DX_channel (Chn);
00530 C3DX_window (EdWindow);
00531 C3DX_sName (S);
00532 C3DX_sSceneFile (S);
00533 C3DX_3dView (V3Dview);
00534 C3DX_3dScene (V3Dsession);
00535 C3DX_3dLoader (V3Dsession);
00536 C3DX_lCursor ([[I ObjCursor] r1]);
00537 C3DX_bEditMode (I);
00538 C3DX_lGroups ([[I C3DXgroup] r1]);
00539 C3DX_lUserInstance ([UserI r1]);
00540 C3DX_owner (UserI
00541
00542 );
00543 };
00544 typedef struct mkC3DXdata C3DXdata;
00545
00546
00547 struct C3DXgroup{
00548
00549 C3DXGRP_iIndex (I);
00550 C3DXGRP_sXmlPath (S );
00551
00552
00553 };
00554 typedef struct mkC3DXgroup C3DXgroup;
00555
00556
00557 struct C3DXeditor{
00558
00559 C3DXE_win (EdWindow );
00560
00561
00562 };
00563 typedef struct mkC3DXeditor C3DXeditor;
00564
00565
00566 typeof strC3DX=C3DXdata;
00567
00568 c3dXsession(){
00569 s3dMainSession;
00570 }
00571 c3dXview(){
00572 v3dMain;
00573 }
00574 c3dXwin(){
00575 v3dMain.V3D_win;
00576 }
00577 DMSwin(){
00578 v3dMain.V3D_win;
00579 }
00580
00581
00582