Xcos tests: fix bug_8397 because of new funptr() and replaced disp(mprintf) by disp... 04/16704/5
Paul Bignier [Thu, 18 Jun 2015 14:08:38 +0000 (16:08 +0200)]
 * funptr doesn't return indexes anymore, so needed a new way to save & restore messagebox()
 * The mprintf fix notably concerns error_reporting_nw.tst, but 'try catch' is still failing so can't validate the test yet
mprintf directly prints in the console, so it makes no sense to add a disp to it!

Change-Id: I8d8c8bb30fab0ba92889117d41af657c59660a22

scilab/modules/scicos/macros/scicos_scicos/c_pass1.sci
scilab/modules/scicos/macros/scicos_scicos/c_pass2.sci
scilab/modules/scicos/macros/scicos_scicos/scicos_flat.sci
scilab/modules/xcos/tests/nonreg_tests/bug_8397.dia.ref
scilab/modules/xcos/tests/nonreg_tests/bug_8397.tst

index a31a5ed..92d9838 100644 (file)
@@ -58,12 +58,12 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
     blklst=[];cmat=[],ccmat=[],cor=[],corinv=[]
     [cor,corinvt,links_table,cur_fictitious,sco_mat,ok]=scicos_flat(scs_m);
     if ~ok then
-        disp(mprintf("%s: flat failed", "c_pass1"));
+        disp(msprintf("%s: flat failed", "c_pass1"));
         return;
     end
     [links_table,sco_mat,ok]=global_case(links_table,sco_mat)
     if ~ok then
-        disp(mprintf("%s: global case failed", "c_pass1"));
+        disp(msprintf("%s: global case failed", "c_pass1"));
         return;
     end
     index1=find((sco_mat(:,2)=="-1")& (sco_mat(:,5)<>"10"))
@@ -74,7 +74,7 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
             if flgcdgen<>-1 then full_path=[numk full_path];scs_m=all_scs_m;end
             hilite_path(full_path,"Error in compilation, There is a FROM ''"+(sco_mat(i,3))+ "'' without a GOTO",%t)
             ok=%f;
-            disp(mprintf("%s: invalid connection matrix", "c_pass1"));
+            disp(msprintf("%s: invalid connection matrix", "c_pass1"));
             return;
         end
     end
@@ -98,13 +98,13 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
             ind(kb)=-km;
             [modelx,ok]=build_block(o); // compile modelica block type 30004
             if ~ok then
-                disp(mprintf("%s: unable to build modelica block", "c_pass1"));
+                disp(msprintf("%s: unable to build modelica block", "c_pass1"));
                 return
             end
         else
             [model,ok]=build_block(o);
             if ~ok then
-                disp(mprintf("%s: unable to build block", "c_pass1"));
+                disp(msprintf("%s: unable to build block", "c_pass1"));
                 return,
             end
 
@@ -125,7 +125,7 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
             [links_table,blklst,corinvt,ind,ok,scs_m,flgcdgen,freof]=sample_clk(sco_mat,links_table,blklst,corinvt,scs_m,ind,flgcdgen)
         end
         if ~ok then
-            disp(mprintf("%s: unable to sample the whole diagram", "c_pass1"));
+            disp(msprintf("%s: unable to sample the whole diagram", "c_pass1"));
             return,
         end
     end
@@ -138,7 +138,7 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
         links_table=[links_table(:,1:3) matrix([1;1]*(1:nl),-1,1) ..
         links_table(:,4) ];
     else
-        disp(mprintf("%s: invalid links table size", "c_pass1"));
+        disp(msprintf("%s: invalid links table size", "c_pass1"));
         return
     end
     imp=find(ind<0)
@@ -214,7 +214,7 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
         if size(ccmat,1)>0 then
             if or(dsearch(ccmat(:,[1 3]),imp,"d")>0) then
                 messagebox("An implicit block has an event port","modal","error");
-                disp(mprintf("%s: implicit block with event port", "c_pass1"));
+                disp(msprintf("%s: implicit block with event port", "c_pass1"));
                 ok=%f;return
             end
         end
@@ -270,7 +270,7 @@ function  [blklst,cmat,ccmat,cor,corinv,ok,scs_m,flgcdgen,freof]=c_pass1(scs_m,f
         [model,ok]=build_modelica_block(blklstm,corinvm,cmmat,NiM,NoM,NvM,scs_m,TMPDIR+"/");
 
         if ~ok then
-            disp(mprintf("%s: build the modelica meta-block failed", "c_pass1"));
+            disp(msprintf("%s: build the modelica meta-block failed", "c_pass1"));
             return
         end
 
index 9890ffc..4d9c5c5 100644 (file)
@@ -521,7 +521,7 @@ function [ordclk,ordptr,cord,typ_l,clkconnect,connectmat,bllst,dep_t,dep_u,dep_u
     //testing event algebraic loops
     ok=is_alg_event_loop(typ_l,clkconnect)
     if ~ok then
-        disp(mprintf("%s: alg_event_loop failed", "c_pass2"));
+        disp(msprintf("%s: alg_event_loop failed", "c_pass2"));
         messagebox(_("Algebraic loop on events."),"modal","error");
         return
     end
@@ -562,7 +562,7 @@ function [ordclk,ordptr,cord,typ_l,clkconnect,connectmat,bllst,dep_t,dep_u,dep_u
 
                     [balg,vec]=ini_ordo3(primary)
                     if balg then
-                        disp(mprintf("%s: ini_ordo (3) failed", "c_pass2"));
+                        disp(msprintf("%s: ini_ordo (3) failed", "c_pass2"));
                         messagebox(_("Algebraic loop."),"modal","error"),
                         ok=%f
                         return
@@ -597,7 +597,7 @@ function [ordclk,ordptr,cord,typ_l,clkconnect,connectmat,bllst,dep_t,dep_u,dep_u
                             if show_comment then mprintf("found non convergence\n"),pause,end
                             i=lp(1)  // first typ_l
                             if i==[] then
-                                disp(mprintf("%s: ini_ordo (2) failed", "c_pass2"));
+                                disp(msprintf("%s: ini_ordo (2) failed", "c_pass2"));
                                 messagebox(_("Algebraic loop."),"modal","error")
                                 ok=%f
                                 return
@@ -989,7 +989,7 @@ function [ordclk,iord,oord,zord,typ_z,ok]=scheduler(inpptr,outptr,clkptr,execlk_
     end
     //
     if ~ok then
-        disp(mprintf("%s: scheduling failed", "c_pass2"));
+        disp(msprintf("%s: scheduling failed", "c_pass2"));
         messagebox(_("Algebraic loop."),"modal","error");
         iord=[],oord=[],zord=[],critev=[]
         return,
@@ -1093,7 +1093,7 @@ function [ord,ok]=tree3(vec,dep_ut,typ_l)
         for i=1:nb
             if vec(i)==j-1&typ_l(i)<>-1 then
                 if j==nb+2 then
-                    disp(mprintf("%s: tree (3) failed", "c_pass2"));
+                    disp(msprintf("%s: tree (3) failed", "c_pass2"));
                     messagebox(_("Algebraic loop."),"modal","error");ok=%f;ord=[];return;
                 end
                 if typ_l(i)==1 then
@@ -1476,7 +1476,7 @@ function [ord,ok]=tree2(vec,outoin,outoinptr,dep_ut)
         for i=1:nb
             if vec(i)==j-1 then
                 if j==nb+2 then
-                    disp(mprintf("%s: tree (2) failed", "c_pass2"));
+                    disp(msprintf("%s: tree (2) failed", "c_pass2"));
                     messagebox(_("Algebraic loop."),"modal","error");ok=%f;ord=[];return;
                 end
                 for k=outoinptr(i):outoinptr(i+1)-1
index 5610397..2d1a7de 100644 (file)
@@ -116,7 +116,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                         else
                             hilite_path([path,k], "There is another local GOTO in this diagram with the same tag ''"+loc_mat($,3)+"''",%t);
                         end
-                        disp(mprintf("%s: goto tag not unique", "scicos_flat"));
+                        disp(msprintf("%s: goto tag not unique", "scicos_flat"));
                         ok=%f;return
                     end
                 else
@@ -161,14 +161,14 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                 if ksup==0 then
                     scs_m=scs_m_s
                     hilite_path([path,k],gettext("I/O blocks must be only used in a Super Block"),%f)
-                    disp(mprintf("%s: Port out of hierarchy", "scicos_flat"));
+                    disp(msprintf("%s: Port out of hierarchy", "scicos_flat"));
                     ok=%f;return
                 end
                 connected=get_connected(scs_m,k)
                 if connected==[] then
                     scs_m=scs_m_s
                     hilite_path([path,k],gettext("This Super block input port is not connected."),%t)
-                    disp(mprintf("%s: Not connected super block input", "scicos_flat"));
+                    disp(msprintf("%s: Not connected super block input", "scicos_flat"));
                     ok=%f;return
                 end
                 if or(o.gui==["IN_f","INIMPL_f"]) then
@@ -205,7 +205,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                 //ficitious blocks
                 Pinds=[];if exists("Pind") then Pinds=Pind,end
                 Pind=[] //base of ports numbering
-                //mprintf("entering superblock at level "+string(size(path,'*'))+"\r\n")
+                //msprintf("entering superblock at level "+string(size(path,'*'))+"\r\n")
                 nb_pin=size(scs_m.objs(k).graphics("pin"),1);
                 nb_pein=size(scs_m.objs(k).graphics("pein"),1);
                 for port_type=["pin","pout","pein","peout"]
@@ -266,7 +266,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                 //Analyze the superblock contents
                 [cors,corinvs,lt,cur_fictitious,scop_mat,ok, localIN, localOUT, localEIN, localEOUT]=scicos_flat(o.model.rpar,cur_fictitious,MaxBlock)
                 if ~ok then
-                    disp(mprintf("%s: Invalid super block at %d", "scicos_flat", k));
+                    disp(msprintf("%s: Invalid super block at %d", "scicos_flat", k));
                     return
                 end
 
@@ -276,7 +276,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                     ok=%f;
                     msg=gettext("Input ports are not numbered properly.")
                     hilite_path(path,msg,%t)
-                    disp(mprintf("%s: Input ports are not numbered properly.", "scicos_flat"))
+                    disp(msprintf("%s: Input ports are not numbered properly.", "scicos_flat"))
                     return
                 end
                 localOUT=-gsort(-localOUT);
@@ -284,7 +284,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                     ok=%f;
                     msg=gettext("Output ports are not numbered properly.")
                     hilite_path(path,msg,%t)
-                    disp(mprintf("%s: Output ports are not numbered properly.", "scicos_flat"))
+                    disp(msprintf("%s: Output ports are not numbered properly.", "scicos_flat"))
                     return
                 end
                 localEIN=-gsort(-localEIN);
@@ -292,7 +292,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                     ok=%f;
                     msg=gettext("Event input ports are not numbered properly.")
                     hilite_path(path,msg,%t)
-                    disp(mprintf("%s: Event input ports are not numbered properly.", "scicos_flat"))
+                    disp(msprintf("%s: Event input ports are not numbered properly.", "scicos_flat"))
                     return
                 end
                 localEOUT=-gsort(-localEOUT);
@@ -300,7 +300,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                     ok=%f;
                     msg=gettext("Event output ports are not numbered properly.")
                     hilite_path(path,msg,%t)
-                    disp(mprintf("%s: Event output ports are not numbered properly.", "scicos_flat"))
+                    disp(msprintf("%s: Event output ports are not numbered properly.", "scicos_flat"))
                     return
                 end
 
@@ -417,7 +417,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                 messagebox(["Error In Compilation. You cannot have multiple GotoTagVisibility";..
                 " with the same tag value in the same scs_m"],"modal")
                 ok=%f;
-                disp(mprintf("%s: Multiple GotoTagVisibility at the same level", "scicos_flat"));
+                disp(msprintf("%s: Multiple GotoTagVisibility at the same level", "scicos_flat"));
                 return
             end
         end
@@ -428,7 +428,7 @@ function  [cor,corinv,links_table,cur_fictitious,sco_mat,ok, IN, OUT, EIN, EOUT]
                 if size(index,"*")>1 then
                     messagebox(["Error in compilation";"Multiple GOTO are taged by the same GotoTagVisibility"],"modal")
                     ok=%f
-                    disp(mprintf("%s: Shared GotoTagVisibility across GOTO", "scicos_flat"));
+                    disp(msprintf("%s: Shared GotoTagVisibility across GOTO", "scicos_flat"));
                     return
                 end
                 index1=find((sco_mat(:,2)=="-1")&(sco_mat(:,3)==tag_exprs(i,1))&(sco_mat(:,5)==tag_exprs(i,2)))
index 056420e..fb2fec6 100644 (file)
@@ -35,12 +35,12 @@ fd = mopen(src_file, "wt");
 mputl(mo_content, fd);
 mclose(fd);
 // override messagebox method
-previous_ptr = funptr("messagebox");
-clearfun("messagebox");
+save_messagebox = messagebox;
+p = funcprot();
+funcprot(0);
 function messagebox(msg, Title, icon, isModal), endfunction
+funcprot(p);
 // modelicac call
 ok = modelicac(src_file, function_file, xml_file, %t, c_file, %f);
 assert_checkequal(ok, %f);
-clear("messagebox");
-newfun("messagebox", previous_ptr);
-clear("previous_ptr");
+messagebox = save_messagebox;
index cf56a7a..7d2300d 100644 (file)
@@ -41,15 +41,14 @@ mputl(mo_content, fd);
 mclose(fd);
 
 // override messagebox method
-previous_ptr = funptr("messagebox");
-clearfun("messagebox");
+save_messagebox = messagebox;
+p = funcprot();
+funcprot(0);
 function messagebox(msg, Title, icon, isModal), endfunction
+funcprot(p);
 
 // modelicac call
 ok = modelicac(src_file, function_file, xml_file, %t, c_file, %f);
 assert_checkequal(ok, %f);
 
-clear("messagebox");
-newfun("messagebox", previous_ptr);
-clear("previous_ptr");
-
+messagebox = save_messagebox;