Salome HOME
[EDF27816] : management of proxy from/to Foreach
[modules/yacs.git] / src / runtime / TypeConversions.cxx
index f75e20abf45c4bb71a8e53241a6e760b8cdf2510..23701e50eb7c7a7e8352d3c1968d178071f8593a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -33,6 +33,7 @@
 #include "TypeCode.hxx"
 #include "Cstr2d.hxx"
 #include "SALOME_GenericObj.hh"
+#include "PythonNode.hxx"
 
 #include <iostream>
 #include <iomanip>
@@ -59,22 +60,6 @@ namespace YACS
 {
   namespace ENGINE
   {
-    void printbin(const std::string& bin)
-      {
-        register char c;
-        for(int i=0;i<bin.length();i++)
-          {
-            c=bin[i];
-            if (c < ' ' || c >= 0x7f) 
-              {
-                fprintf(stderr,"\\x%02x",c & 0xff);
-              }
-            else
-              fprintf(stderr,"%c",c);
-          }
-        fprintf(stderr,"\n");
-      }
-
     std::string getImplName(ImplType impl)
       {
          switch(impl)
@@ -801,9 +786,14 @@ namespace YACS
             }
           if(strncmp(t->id(),"python",6)==0)
             {
+              bool somthingToDo = YACS::ENGINE::PythonEntry::GetDestroyStatus(o);
+              if( somthingToDo )
+                YACS::ENGINE::PythonEntry::DoNotTouchFileIfProxy(o);
               // It's a native Python object pickle it
               PyObject* mod=PyImport_ImportModule("pickle");
               PyObject *pickled=PyObject_CallMethod(mod,(char *)"dumps",(char *)"Oi",o,protocol);
+              if( somthingToDo )
+                YACS::ENGINE::PythonEntry::UnlinkOnDestructorIfProxy(o);
               DEBTRACE(PyObject_Repr(pickled) );
               Py_DECREF(mod);
               if(pickled==NULL)