Xcos MVC: remove the "Deleted" adapter 49/16349/3
Clément DAVID [Tue, 7 Apr 2015 13:10:25 +0000 (15:10 +0200)]
An mlist("Deleted") datatype is suficient and more natural to use for
temporary deleted objects.

Change-Id: I64d92a8f4a7b55e38db153a9be12762262ea771d

scilab/modules/scicos/macros/scicos_scicos/do_delete1.sci
scilab/modules/scicos/macros/scicos_scicos/do_version.sci
scilab/modules/scicos/sci_gateway/cpp/sci_scicos_new.cpp
scilab/modules/scicos/sci_gateway/cpp/sci_scicos_setfield.cpp
scilab/modules/scicos/src/cpp/view_scilab/Adapters.cpp
scilab/modules/scicos/src/cpp/view_scilab/Adapters.hxx
scilab/modules/scicos/tests/unit_tests/model/Delete_objects.dia.ref
scilab/modules/scicos/tests/unit_tests/model/Delete_objects.tst
scilab/modules/scicos_blocks/macros/Sources/GEN_SQR.sci

index e63a73e..d73cf88 100644 (file)
@@ -32,13 +32,13 @@ function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
     // K and all other relevant objects (link, splits,..)
     //
     // deleted objects:
-    //  - are replaced by the value : scicos_new('Deleted')
+    //  - are replaced by the value : mlist("Deleted")
     //  - not to change the indexing: use do_purge to suppress them and to renumber objects
     //
     //**  Perform deletion of [scs_m] object whose index are given in the vector
     //**  [K] and all other relevant objects (link, splits,..) in recursive way
     //
-    //**  Deleted objects are replaced by the value : scicos_new('Deleted')
+    //**  Deleted objects are replaced by the value : mlist("Deleted")
     //**  ---> not to change the indexing:
     //**  ---> use [do_purge] to suppress them and to renumber objects
     //**  Similar strategy is used for the ghraphics object: to mantain the coherency
@@ -248,6 +248,6 @@ function [scs_m,DEL,DELL]=do_delete1(scs_m,K,gr)
 
     //** Scan all the deleted elements and update the graphics datastrucure
     for k = DEL
-        scs_m.objs(k) = scicos_new("Deleted"); //** mark the object as "Deleted"
+        scs_m.objs(k) = mlist("Deleted"); //** mark the object as "Deleted"
     end
 endfunction
index 2527401..2375822 100644 (file)
@@ -2099,7 +2099,7 @@ function scs_m_new=do_version27(scs_m)
         scs_m_new.props.options.Background=[8 1]
     end
 
-    scs_m_new.objs(1)=scicos_new("Deleted") // not to change the internal numbering
+    scs_m_new.objs(1)=mlist("Deleted") // not to change the internal numbering
     n=lstsize(scs_m)
     back_col=8   //white background
 
@@ -2175,7 +2175,7 @@ function scs_m_new=do_version27(scs_m)
             objsi.graphics.exprs=o(2)(4)
             scs_m_new.objs(i)=objsi
         elseif o(1)=="Deleted" then
-            scs_m_new.objs(i)=scicos_new("Deleted")
+            scs_m_new.objs(i)=mlist("Deleted")
         end
     end
 
@@ -2272,7 +2272,7 @@ function scs_m_new=do_versionxx(scs_m)
     if typeof(scs_m(1))<>"params" then scs_m_new=scs_m,return,end
     scs_m_new=scicos_diagram()
     scs_m_new.props=scs_m(1)
-    scs_m_new.objs(1)=scicos_new("Deleted") // not to change the internal numbering
+    scs_m_new.objs(1)=mlist("Deleted") // not to change the internal numbering
     n=lstsize(scs_m)
     for i=2:n //loop on objects
         o=scs_m(i)
index 5550172..4e66288 100644 (file)
@@ -186,10 +186,6 @@ types::Function::ReturnValue sci_scicos_new(types::typed_list &in, int _iRetCoun
             }
             out.push_back(returnType);
             break;
-        case view_scilab::Adapters::DELETED_ADAPTER:
-            returnType = new types::List();
-            out.push_back(returnType);
-            break;
         case view_scilab::Adapters::DIAGRAM_ADAPTER:
             returnType = alloc_and_set<view_scilab::DiagramAdapter, model::Diagram>(DIAGRAM, type_name, in);
             if (returnType == 0)
index bf43966..0ac3b26 100644 (file)
@@ -118,10 +118,6 @@ types::Function::ReturnValue sci_scicos_setfield(types::typed_list &in, int _iRe
             }
             out.push_back(returnType);
             break;
-        case view_scilab::Adapters::DELETED_ADAPTER:
-            returnType = new types::List();
-            out.push_back(returnType);
-            break;
         case view_scilab::Adapters::DIAGRAM_ADAPTER:
             returnType = set<view_scilab::DiagramAdapter, model::Diagram>(adaptor, field, value);
             if (returnType == 0)
index 74814ee..bddd91a 100644 (file)
@@ -48,7 +48,6 @@ Adapters::Adapters()
 
     adapters.push_back(adapter_t(view_scilab::BlockAdapter::getSharedTypeStr(), BLOCK_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::CprAdapter::getSharedTypeStr(), CPR_ADAPTER));
-    adapters.push_back(adapter_t(L"Deleted", DELETED_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::DiagramAdapter::getSharedTypeStr(), DIAGRAM_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::GraphicsAdapter::getSharedTypeStr(), GRAPHIC_ADAPTER));
     adapters.push_back(adapter_t(view_scilab::LinkAdapter::getSharedTypeStr(), LINK_ADAPTER));
index 9f5984a..f10e67d 100644 (file)
@@ -31,7 +31,6 @@ public:
     {
         BLOCK_ADAPTER = 0,  //!< \see view_scilab::BlockAdapter
         CPR_ADAPTER,        //!< \see view_scilab::CprAdapter
-        DELETED_ADAPTER,    //!< \see view_scilab::DeletedAdapter
         DIAGRAM_ADAPTER,    //!< \see view_scilab::DiagramAdapter
         GRAPHIC_ADAPTER,    //!< \see view_scilab::GraphicAdapter
         LINK_ADAPTER,       //!< \see view_scilab::LinkAdapter
index 7a2e100..507be5a 100644 (file)
@@ -281,7 +281,8 @@ propertyUpdated( 21 , LINK , SOURCE_PORT ) : NO_CHANGES
 propertyUpdated( 21 , LINK , DESTINATION_PORT ) : NO_CHANGES
 // Consecutively delete the diagram objects,
 // check that they were replaced with "Deleted" mlists.
-scs_m.objs(1)=scicos_new("Deleted");
+DeletedBlock = mlist("Deleted");
+scs_m.objs(1) = DeletedBlock;
 propertyUpdated( 1 , DIAGRAM , CHILDREN ) : SUCCESS
 propertyUpdated( 12 , BLOCK , PARENT_DIAGRAM ) : SUCCESS
 propertyUpdated( 12 , BLOCK , INPUTS ) : SUCCESS
@@ -306,8 +307,8 @@ propertyUpdated( 17 , PORT , CONNECTED_SIGNALS ) : SUCCESS
 propertyUpdated( 20 , LINK , DESTINATION_PORT ) : NO_CHANGES
 propertyUpdated( 21 , LINK , SOURCE_PORT ) : NO_CHANGES
 propertyUpdated( 21 , LINK , DESTINATION_PORT ) : NO_CHANGES
-assert_checkequal(scs_m.objs(1), mlist("Deleted"));
-scs_m.objs(2)=scicos_new("Deleted");
+assert_checkequal(scs_m.objs(1), DeletedBlock);
+scs_m.objs(2) = DeletedBlock;
 propertyUpdated( 1 , DIAGRAM , CHILDREN ) : SUCCESS
 propertyUpdated( 16 , BLOCK , PARENT_DIAGRAM ) : SUCCESS
 propertyUpdated( 16 , BLOCK , INPUTS ) : SUCCESS
@@ -329,24 +330,24 @@ objectDeleted( 19 , PORT )
 objectDeleted( 16 , BLOCK )
 propertyUpdated( 21 , LINK , SOURCE_PORT ) : NO_CHANGES
 propertyUpdated( 21 , LINK , DESTINATION_PORT ) : NO_CHANGES
-assert_checkequal(scs_m.objs(2), mlist("Deleted"));
-scs_m.objs(3)=scicos_new("Deleted");
+assert_checkequal(scs_m.objs(2), DeletedBlock);
+scs_m.objs(3) = DeletedBlock;
 propertyUpdated( 1 , DIAGRAM , CHILDREN ) : SUCCESS
 propertyUpdated( 20 , LINK , PARENT_DIAGRAM ) : SUCCESS
 objectDeleted( 20 , LINK )
 propertyUpdated( 21 , LINK , SOURCE_PORT ) : NO_CHANGES
 propertyUpdated( 21 , LINK , DESTINATION_PORT ) : NO_CHANGES
-assert_checkequal(scs_m.objs(3), mlist("Deleted"));
-scs_m.objs(4)=scicos_new("Deleted");
+assert_checkequal(scs_m.objs(3), DeletedBlock);
+scs_m.objs(4) = DeletedBlock;
 propertyUpdated( 1 , DIAGRAM , CHILDREN ) : SUCCESS
 propertyUpdated( 21 , LINK , PARENT_DIAGRAM ) : SUCCESS
 objectDeleted( 21 , LINK )
-assert_checkequal(scs_m.objs(4), mlist("Deleted"));
+assert_checkequal(scs_m.objs(4), DeletedBlock);
 // Test that all objects are simultaneously "deleted"
-assert_checkequal(scs_m.objs(1), mlist("Deleted"));
-assert_checkequal(scs_m.objs(2), mlist("Deleted"));
-assert_checkequal(scs_m.objs(3), mlist("Deleted"));
-assert_checkequal(scs_m.objs(4), mlist("Deleted"));
+assert_checkequal(scs_m.objs(1), DeletedBlock);
+assert_checkequal(scs_m.objs(2), DeletedBlock);
+assert_checkequal(scs_m.objs(3), DeletedBlock);
+assert_checkequal(scs_m.objs(4), DeletedBlock);
 // Check that all the model items are freed
 clear
 propertyUpdated( 2 , BLOCK , INPUTS ) : SUCCESS
index 5ebbc5e..aecd845 100644 (file)
@@ -25,23 +25,25 @@ scs_m.objs(4) = lnk2;
 
 // Consecutively delete the diagram objects,
 // check that they were replaced with "Deleted" mlists.
-scs_m.objs(1)=scicos_new("Deleted");
-assert_checkequal(scs_m.objs(1), mlist("Deleted"));
+DeletedBlock = mlist("Deleted");
 
-scs_m.objs(2)=scicos_new("Deleted");
-assert_checkequal(scs_m.objs(2), mlist("Deleted"));
+scs_m.objs(1) = DeletedBlock;
+assert_checkequal(scs_m.objs(1), DeletedBlock);
 
-scs_m.objs(3)=scicos_new("Deleted");
-assert_checkequal(scs_m.objs(3), mlist("Deleted"));
+scs_m.objs(2) = DeletedBlock;
+assert_checkequal(scs_m.objs(2), DeletedBlock);
 
-scs_m.objs(4)=scicos_new("Deleted");
-assert_checkequal(scs_m.objs(4), mlist("Deleted"));
+scs_m.objs(3) = DeletedBlock;
+assert_checkequal(scs_m.objs(3), DeletedBlock);
+
+scs_m.objs(4) = DeletedBlock;
+assert_checkequal(scs_m.objs(4), DeletedBlock);
 
 // Test that all objects are simultaneously "deleted"
-assert_checkequal(scs_m.objs(1), mlist("Deleted"));
-assert_checkequal(scs_m.objs(2), mlist("Deleted"));
-assert_checkequal(scs_m.objs(3), mlist("Deleted"));
-assert_checkequal(scs_m.objs(4), mlist("Deleted"));
+assert_checkequal(scs_m.objs(1), DeletedBlock);
+assert_checkequal(scs_m.objs(2), DeletedBlock);
+assert_checkequal(scs_m.objs(3), DeletedBlock);
+assert_checkequal(scs_m.objs(4), DeletedBlock);
 
 
 // Check that all the model items are freed
index 7bc93a9..6ff65a0 100644 (file)
@@ -325,8 +325,8 @@ function [x,y,typ]=GEN_SQR(job,arg1,arg2)
         ct=[5,-1],..
         from=[7,2,0],..
         to=[4,2,1])
-        scs_m_1.objs(11)=scicos_new("Deleted")
-        scs_m_1.objs(12)=scicos_new("Deleted")
+        scs_m_1.objs(11)=mlist("Deleted")
+        scs_m_1.objs(12)=mlist("Deleted")
         scs_m_1.objs(13)=scicos_block(..
         gui="OUT_f",..
         graphics=scicos_graphics(..