]> Creatis software - cpPlugins.git/blobdiff - appli/bash/cpPlugins_HostCreator.cxx
Now it compiles again on Windows.
[cpPlugins.git] / appli / bash / cpPlugins_HostCreator.cxx
index ee11adf24c667c3453baca007f984d2c88f88c46..445302fe9090bbe5d03d3f4664e96492dc56f070 100644 (file)
@@ -100,33 +100,34 @@ int main( int argc, char* argv[] )
   std::ofstream out_stream( argv[ 1 ] );
 
   // Write include section
-  out_stream
-    << "#include <map>" << std::endl
-    << "#include <set>" << std::endl;
   for( int i = 2; i < argc; ++i )
     out_stream << "#include \"" << argv[ i ] << "\"" <<std::endl;
 
   // Write init/finish section
-  out_stream
-    << std::endl
-    << "void __attribute__ ((constructor)) _initialize( )" << std::endl
-    << "{" << std::endl << "}" << std::endl << std::endl
-    << "void __attribute__ ((destructor)) _finalize( )" << std::endl
-    << "{" << std::endl << "}" << std::endl << std::endl;
+  /* TODO:
+     out_stream
+     << std::endl
+     << "void __attribute__ ((constructor)) _initialize( )" << std::endl
+     << "{" << std::endl << "}" << std::endl << std::endl
+     << "void __attribute__ ((destructor)) _finalize( )" << std::endl
+     << "{" << std::endl << "}" << std::endl;
+  */
 
   // Write access function
   out_stream
-    << "extern \"C\" std::map< std::string, std::set< std::string > > "
+    << std::endl
+    << "extern \"C\" __declspec(dllexport) const char* "
     << "cpPlugins_LoadedFilters( )" << std::endl << "{" << std::endl
-    << "  std::map< std::string, std::set< std::string > > classes;"
-    << std::endl;
+    << "  static std::string classes;"
+    << std::endl
+    << "  classes = \"\";" << std::endl;
   for( auto iIt = info.begin( ); iIt != info.end( ); ++iIt )
     for( auto jIt = iIt->second.begin( ); jIt != iIt->second.end( ); ++jIt )
       out_stream
-        << "  classes[ \"" << iIt->first
-        << "\" ].insert( \"" << jIt->first << "\" );" << std::endl;
+        << "  classes += std::string( \"" << iIt->first
+        << ":" << jIt->first << ";\" );" << std::endl;
   out_stream
-    << "  return( classes );" << std::endl
+    << "  return( classes.c_str( ) );" << std::endl
     << "}" << std::endl << std::endl;
 
   // Write creators
@@ -135,14 +136,12 @@ int main( int argc, char* argv[] )
     for( auto jIt = iIt->second.begin( ); jIt != iIt->second.end( ); ++jIt )
     {
       out_stream
-        << "extern \"C\" cpPlugins::ProcessObject::Pointer "
+        << "extern \"C\" __declspec(dllexport) void* "
         << iIt->first << "_" << jIt->first
         << "( )" << std::endl << "{" << std::endl
-        << std::endl
-        << "  cpPlugins::ProcessObject::Pointer p;" << std::endl
-        << "  " << jIt->second << "::" << jIt->first << "::Pointer f = "
-        << jIt->second << "::" << jIt->first << "::New( );" << std::endl
-        << "  p = f.GetPointer( );" << std::endl << "  return( p );"
+        << "  static " << jIt->second << "::" << jIt->first << "::Pointer f;" << std::endl
+        << "  f = " << jIt->second << "::" << jIt->first << "::New( );" << std::endl
+        << "  return( &f );"
         << std::endl;
       out_stream
         << "}" << std::endl << std::endl;