ENH: remove old commands

This commit is contained in:
Ken Martin 2006-12-12 14:40:21 -05:00
parent af2b0e023a
commit ed4d2ec51e
9 changed files with 0 additions and 1754 deletions

View File

@ -52,10 +52,6 @@
#include "cmSubdirDependsCommand.cxx" #include "cmSubdirDependsCommand.cxx"
#include "cmUseMangledMesaCommand.cxx" #include "cmUseMangledMesaCommand.cxx"
#include "cmUtilitySourceCommand.cxx" #include "cmUtilitySourceCommand.cxx"
#include "cmVTKMakeInstantiatorCommand.cxx"
#include "cmVTKWrapJavaCommand.cxx"
#include "cmVTKWrapPythonCommand.cxx"
#include "cmVTKWrapTclCommand.cxx"
#include "cmVariableRequiresCommand.cxx" #include "cmVariableRequiresCommand.cxx"
#include "cmWhileCommand.cxx" #include "cmWhileCommand.cxx"
#include "cmWriteFileCommand.cxx" #include "cmWriteFileCommand.cxx"
@ -110,10 +106,6 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands.push_back(new cmSubdirDependsCommand); commands.push_back(new cmSubdirDependsCommand);
commands.push_back(new cmUseMangledMesaCommand); commands.push_back(new cmUseMangledMesaCommand);
commands.push_back(new cmUtilitySourceCommand); commands.push_back(new cmUtilitySourceCommand);
commands.push_back(new cmVTKMakeInstantiatorCommand);
commands.push_back(new cmVTKWrapJavaCommand);
commands.push_back(new cmVTKWrapPythonCommand);
commands.push_back(new cmVTKWrapTclCommand);
commands.push_back(new cmVariableRequiresCommand); commands.push_back(new cmVariableRequiresCommand);
commands.push_back(new cmWhileCommand); commands.push_back(new cmWhileCommand);
commands.push_back(new cmWriteFileCommand); commands.push_back(new cmWriteFileCommand);

View File

@ -1,491 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVTKMakeInstantiatorCommand.h"
#include "cmCacheManager.h"
#include "cmGeneratedFileStream.h"
#include "cmSourceFile.h"
bool
cmVTKMakeInstantiatorCommand
::InitialPass(std::vector<std::string> const& argsIn)
{
if(argsIn.size() < 3)
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
std::string sourceListValue;
this->ClassName = args[0];
std::vector<cmStdString> inSourceLists;
this->ExportMacro = "-";
bool includesMode = false;
bool oldVersion = true;
// Find the path of the files to be generated.
std::string filePath = this->Makefile->GetCurrentOutputDirectory();
std::string headerPath = filePath;
// Check whether to use the old or new form.
if(this->Makefile->GetDefinition("VTK_USE_INSTANTIATOR_NEW"))
{
oldVersion = false;
}
for(unsigned int i=2;i < args.size();++i)
{
if(args[i] == "HEADER_LOCATION")
{
includesMode = false;
if(++i < args.size())
{
headerPath = args[i];
}
else
{
this->SetError("HEADER_LOCATION option used without value.");
return false;
}
}
else if(args[i] == "EXPORT_MACRO")
{
includesMode = false;
if(++i < args.size())
{
this->ExportMacro = args[i];
}
else
{
this->SetError("EXPORT_MACRO option used without value.");
return false;
}
}
else if(args[i] == "INCLUDES")
{
includesMode = true;
}
// If not an option, it must be another input source list name or
// an include file.
else
{
if(!includesMode)
{
inSourceLists.push_back(args[i]);
}
else
{
this->Includes.push_back(args[i]);
}
}
}
if(this->ExportMacro == "-")
{
this->SetError("No EXPORT_MACRO option given.");
return false;
}
for(std::vector<cmStdString>::const_iterator s = inSourceLists.begin();
s != inSourceLists.end(); ++s)
{
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*s);
cmSourceFile *sf = this->Makefile->GetSource(s->c_str());
// Wrap-excluded and abstract classes do not have a New() method.
// vtkIndent and vtkTimeStamp are special cases and are not
// vtkObject subclasses.
if(
(!sf || (!sf->GetPropertyAsBool("WRAP_EXCLUDE") &&
!sf->GetPropertyAsBool("ABSTRACT"))) &&
((srcName != "vtkIndent") && (srcName != "vtkTimeStamp")))
{
this->Classes.push_back(srcName);
}
}
// Generate the header with the class declaration.
{
std::string fileName = this->ClassName + ".h";
std::string fullName = headerPath+"/"+fileName;
// Generate the output file with copy-if-different.
cmGeneratedFileStream fout(fullName.c_str());
fout.SetCopyIfDifferent(true);
// Actually generate the code in the file.
if(!oldVersion)
{
this->GenerateHeaderFile(fout);
}
else
{
this->OldGenerateHeaderFile(fout);
}
}
// Generate the implementation file.
{
std::string fileName = this->ClassName + ".cxx";
std::string fullName = filePath+"/"+fileName;
// Generate the output file with copy-if-different.
{
cmGeneratedFileStream fout(fullName.c_str());
fout.SetCopyIfDifferent(true);
// Actually generate the code in the file.
if(!oldVersion)
{
this->GenerateImplementationFile(fout);
}
else
{
this->OldGenerateImplementationFile(fout);
}
}
// Add the generated source file into the source list.
cmSourceFile file;
file.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
file.SetProperty("WRAP_EXCLUDE","1");
file.SetProperty("ABSTRACT","0");
file.SetName(fileName.c_str(), filePath.c_str(),
this->Makefile->GetSourceExtensions(),
this->Makefile->GetHeaderExtensions());
this->Makefile->AddSource(file);
sourceListValue += file.GetSourceName() + ".cxx";
}
if(oldVersion)
{
int groupSize = 10;
size_t numClasses = this->Classes.size();
size_t numFullBlocks = numClasses / groupSize;
size_t lastBlockSize = numClasses % groupSize;
size_t numBlocks = numFullBlocks + ((lastBlockSize>0)? 1:0);
// Generate the files with the ::New() calls to each class. These
// are done in groups to keep the translation unit size smaller.
for(unsigned int block=0; block < numBlocks;++block)
{
std::string fileName = this->OldGenerateCreationFileName(block);
std::string fullName = filePath+"/"+fileName;
// Generate the output file with copy-if-different.
{
cmGeneratedFileStream fout(fullName.c_str());
fout.SetCopyIfDifferent(true);
size_t thisBlockSize =
(block < numFullBlocks)? groupSize:lastBlockSize;
// Actually generate the code in the file.
this->OldGenerateCreationFile(fout,
block*groupSize,
static_cast<int>(thisBlockSize));
}
// Add the generated source file into the source list.
cmSourceFile file;
file.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
file.SetProperty("WRAP_EXCLUDE","1");
file.SetProperty("ABSTRACT","0");
file.SetName(fileName.c_str(), filePath.c_str(),
this->Makefile->GetSourceExtensions(),
this->Makefile->GetHeaderExtensions());
this->Makefile->AddSource(file);
sourceListValue += ";";
sourceListValue += file.GetSourceName() + ".cxx";
}
}
this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str());
return true;
}
// Generates the class header file with the definition of the class
// and its initializer class.
void
cmVTKMakeInstantiatorCommand
::GenerateHeaderFile(std::ostream& os)
{
os <<
"#ifndef __" << this->ClassName.c_str() << "_h\n"
"#define __" << this->ClassName.c_str() << "_h\n"
"\n"
"#include \"vtkInstantiator.h\"\n";
for(unsigned int i=0;i < this->Includes.size();++i)
{
os << "#include \"" << this->Includes[i].c_str() << "\"\n";
}
// Write the instantiator class definition.
os <<
"\n"
"class " << this->ExportMacro.c_str()
<< " " << this->ClassName.c_str() << "\n"
"{\n"
"public:\n"
" " << this->ClassName.c_str() << "();\n"
" ~" << this->ClassName.c_str() << "();\n"
"private:\n"
" static void ClassInitialize();\n"
" static void ClassFinalize();\n"
" static unsigned int Count;\n"
"};\n"
"\n";
// Write the initialization instance to make sure the creation
// functions get registered when this generated header is included.
os <<
"static "
<< this->ClassName.c_str() << " "
<< this->ClassName.c_str() << "Initializer;\n"
"\n"
"#endif\n";
}
// Generates the file with the implementation of the class. All
// methods except the actual object creation functions are generated
// here.
void
cmVTKMakeInstantiatorCommand
::GenerateImplementationFile(std::ostream& os)
{
// Include the instantiator class header.
os <<
"#include \"" << this->ClassName.c_str() << ".h\"\n"
"\n";
// Write the extern declarations for all the creation functions.
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << "extern vtkObject* vtkInstantiator" <<
this->Classes[i].c_str() << "New();\n";
}
// Write the ClassInitialize method to register all the creation functions.
os <<
"\n"
"void " << this->ClassName.c_str() << "::ClassInitialize()\n"
"{\n";
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << " vtkInstantiator::RegisterInstantiator(\""
<< this->Classes[i].c_str() << "\", vtkInstantiator"
<< this->Classes[i].c_str() << "New);\n";
}
// Write the ClassFinalize method to unregister all the creation functions.
os <<
"}\n"
"\n"
"void " << this->ClassName.c_str() << "::ClassFinalize()\n"
"{\n";
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << " vtkInstantiator::UnRegisterInstantiator(\""
<< this->Classes[i].c_str() << "\", vtkInstantiator"
<< this->Classes[i].c_str() << "New);\n";
}
// Write the constructor and destructor of the initializer class to
// call the ClassInitialize and ClassFinalize methods at the right
// time.
os <<
"}\n"
"\n" <<
this->ClassName.c_str() << "::" << this->ClassName.c_str() << "()\n"
"{\n"
" if(++" << this->ClassName.c_str() << "::Count == 1)\n"
" { " << this->ClassName.c_str() << "::ClassInitialize(); }\n"
"}\n"
"\n" <<
this->ClassName.c_str() << "::~" << this->ClassName.c_str() << "()\n"
"{\n"
" if(--" << this->ClassName.c_str() << "::Count == 0)\n"
" { " << this->ClassName.c_str() << "::ClassFinalize(); }\n"
"}\n"
"\n"
"// Number of translation units that include this class's header.\n"
"// Purposely not initialized. Default is static initialization to 0.\n"
"unsigned int " << this->ClassName.c_str() << "::Count;\n";
}
std::string
cmVTKMakeInstantiatorCommand::OldGenerateCreationFileName(unsigned int block)
{
cmOStringStream nameStr;
nameStr << this->ClassName.c_str() << block << ".cxx";
std::string result = nameStr.str();
return result;
}
// Generates a file that includes the headers of the classes it knows
// how to create and provides functions which create the classes with
// the New() method.
void
cmVTKMakeInstantiatorCommand
::OldGenerateCreationFile(std::ostream& os, unsigned int groupStart,
unsigned int groupSize)
{
// Need to include header of generated class.
os <<
"#include \"" << this->ClassName.c_str() << ".h\"\n"
"\n";
// Include class files.
for(unsigned int i=0;i < groupSize;++i)
{
os << "#include \"" << this->Classes[groupStart+i].c_str() << ".h\"\n";
}
os <<
"\n";
// Write the create function implementations.
for(unsigned int i=0;i < groupSize;++i)
{
os << "vtkObject* " << this->ClassName.c_str() << "::Create_"
<< this->Classes[groupStart+i].c_str() << "() { return "
<< this->Classes[groupStart+i].c_str() << "::New(); }\n";
}
}
// Generates the class header file with the definition of the class
// and its initializer class.
void
cmVTKMakeInstantiatorCommand
::OldGenerateHeaderFile(std::ostream& os)
{
os <<
"#ifndef __" << this->ClassName.c_str() << "_h\n"
"#define __" << this->ClassName.c_str() << "_h\n"
"\n"
"#include \"vtkInstantiator.h\"\n";
for(unsigned int i=0;i < this->Includes.size();++i)
{
os << "#include \"" << this->Includes[i].c_str() << "\"\n";
}
os <<
"\n"
"class " << this->ClassName.c_str() << "Initialize;\n"
"\n"
"class " << this->ExportMacro.c_str() << " "
<< this->ClassName.c_str() << "\n"
"{\n"
" friend class " << this->ClassName.c_str() << "Initialize;\n"
"\n"
" static void ClassInitialize();\n"
" static void ClassFinalize();\n"
"\n";
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << " static vtkObject* Create_"
<< this->Classes[i].c_str() << "();\n";
}
// Write the initializer class to make sure the creation functions
// get registered when this generated header is included.
os <<
"};\n"
"\n"
"class " << this->ExportMacro.c_str() << " "
<< this->ClassName.c_str() << "Initialize\n"
"{\n"
"public:\n"
" " << this->ClassName.c_str() << "Initialize();\n"
" ~" << this->ClassName.c_str() << "Initialize();\n"
"private:\n"
" static unsigned int Count;\n"
"};\n"
"\n"
"static " << this->ClassName.c_str() << "Initialize "
<< this->ClassName.c_str() << "Initializer;\n"
"\n"
"#endif\n";
}
// Generates the file with the implementation of the class. All
// methods except the actual object creation functions are generated
// here.
void cmVTKMakeInstantiatorCommand
::OldGenerateImplementationFile(std::ostream& os)
{
// Write the ClassInitialize method to register all the creation functions.
os <<
"#include \"" << this->ClassName.c_str() << ".h\"\n"
"\n"
"void " << this->ClassName.c_str() << "::ClassInitialize()\n"
"{\n";
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << " vtkInstantiator::RegisterInstantiator(\""
<< this->Classes[i].c_str() << "\", "
<< this->ClassName.c_str() << "::Create_"
<< this->Classes[i].c_str() << ");\n";
}
// Write the ClassFinalize method to unregister all the creation functions.
os <<
"}\n"
"\n"
"void " << this->ClassName.c_str() << "::ClassFinalize()\n"
"{\n";
for(unsigned int i=0;i < this->Classes.size();++i)
{
os << " vtkInstantiator::UnRegisterInstantiator(\""
<< this->Classes[i].c_str() << "\", "
<< this->ClassName.c_str() << "::Create_"
<< this->Classes[i].c_str() << ");\n";
}
// Write the constructor and destructor of the initializer class to
// call the ClassInitialize and ClassFinalize methods at the right
// time.
os <<
"}\n"
"\n" <<
this->ClassName.c_str() << "Initialize::" <<
this->ClassName.c_str() << "Initialize()\n"
"{\n"
" if(++" << this->ClassName.c_str() << "Initialize::Count == 1)\n"
" { " << this->ClassName.c_str() << "::ClassInitialize(); }\n"
"}\n"
"\n" <<
this->ClassName.c_str() << "Initialize::~" <<
this->ClassName.c_str() << "Initialize()\n"
"{\n"
" if(--" << this->ClassName.c_str() << "Initialize::Count == 0)\n"
" { " << this->ClassName.c_str() << "::ClassFinalize(); }\n"
"}\n"
"\n"
"// Number of translation units that include this class's header.\n"
"// Purposely not initialized. Default is static initialization to 0.\n"
"unsigned int " << this->ClassName.c_str() << "Initialize::Count;\n";
}

View File

@ -1,103 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVTKMakeInstantiatorCommand_h
#define cmVTKMakeInstantiatorCommand_h
#include "cmCommand.h"
/** \class cmVTKMakeInstantiatorCommand
* cmVTKMakeInstantiatorCommand implements the VTK_MAKE_INSTANTIATOR
* command. This generates a source file to add to a VTK library that
* registers instance creation functions with vtkInstantiator for every
* class in that library.
*/
class cmVTKMakeInstantiatorCommand : public cmCommand
{
public:
/** This is a virtual constructor for the command. */
virtual cmCommand* Clone()
{ return new cmVTKMakeInstantiatorCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/** The name of the command as specified in CMakeList.txt. */
virtual const char* GetName() { return "VTK_MAKE_INSTANTIATOR"; }
/** Succinct documentation. */
virtual const char* GetTerseDocumentation()
{
return "Deprecated. For use only in VTK 4.0.";
}
/** More documentation. */
virtual const char* GetFullDocumentation()
{
return
" VTK_MAKE_INSTANTIATOR(className outSourceList\n"
" src-list1 [src-list2 ..]\n"
" EXPORT_MACRO exportMacro\n"
" [HEADER_LOCATION dir]\n"
" [GROUP_SIZE groupSize]\n"
" [INCLUDES [file1 file2 ..]])\n"
"Generates a new class with the given name and adds its files to the "
"given outSourceList. It registers the classes from the other given "
"source lists with vtkInstantiator when it is loaded. The output "
"source list should be added to the library with the classes it "
"registers. "
"The EXPORT_MACRO argument must be given and followed by the export "
"macro to use when generating the class (ex. VTK_COMMON_EXPORT). "
"The HEADER_LOCATION option must be followed by a path. It specifies "
"the directory in which to place the generated class's header file. "
"The generated class implementation files always go in the build "
"directory corresponding to the CMakeLists.txt file containing "
"the command. This is the default location for the header. "
"The INCLUDES option can be followed by a list of zero or more files. "
"These files will be #included by the generated instantiator header, "
"and can be used to gain access to the specified exportMacro in the "
"C++ code.";
}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged()
{
return true;
}
cmTypeMacro(cmVTKMakeInstantiatorCommand, cmCommand);
protected:
std::string ClassName;
std::string ExportMacro;
std::vector<cmStdString> Includes;
std::vector<cmStdString> Classes;
void GenerateHeaderFile(std::ostream&);
void GenerateImplementationFile(std::ostream&);
void OldGenerateHeaderFile(std::ostream&);
void OldGenerateImplementationFile(std::ostream&);
std::string OldGenerateCreationFileName(unsigned int group);
void OldGenerateCreationFile(std::ostream&, unsigned int groupStart,
unsigned int groupSize);
};
#endif

View File

@ -1,199 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVTKWrapJavaCommand.h"
// cmVTKWrapJavaCommand
bool cmVTKWrapJavaCommand::InitialPass(std::vector<std::string> const& argsIn)
{
if(argsIn.size() < 3 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
// Now check and see if the value has been stored in the cache
// already, if so use that value and don't look for the program
if(!this->Makefile->IsOn("VTK_WRAP_JAVA"))
{
return true;
}
// what is the current source dir
std::string cdir = this->Makefile->GetCurrentDirectory();
// keep the library name
this->LibraryName = args[0];
this->SourceList = args[1];
std::string sourceListValue;
// was the list already populated
const char *def = this->Makefile->GetDefinition(this->SourceList.c_str());
if (def)
{
sourceListValue = def;
}
// Prepare java dependency file
const char* resultDirectory =
this->Makefile->GetRequiredDefinition("VTK_JAVA_HOME");
std::string res = this->Makefile->GetCurrentOutputDirectory();
std::string depFileName = res + "/JavaDependencies.cmake";
std::ofstream depFile(depFileName.c_str());
depFile << "# This file is automatically generated by CMake VTK_WRAP_JAVA"
<< std::endl << std::endl;
depFile <<
"SET(VTK_JAVA_DEPENDENCIES ${VTK_JAVA_DEPENDENCIES}" << std::endl;
// get the list of classes for this library
for(std::vector<std::string>::const_iterator j = (args.begin() + 2);
j != args.end(); ++j)
{
cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
// if we should wrap the class
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
{
cmSourceFile file;
file.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
if (curr)
{
file.SetProperty("ABSTRACT",curr->GetProperty("ABSTRACT"));
}
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
std::string newName = srcName + "Java";
file.SetName(newName.c_str(),
this->Makefile->GetCurrentOutputDirectory(), "cxx",false);
std::string hname = cdir + "/" + srcName + ".h";
this->WrapHeaders.push_back(hname);
// add starting depends
file.GetDepends().push_back(hname);
this->WrapClasses.push_back(file);
this->OriginalNames.push_back(srcName);
if (sourceListValue.size() > 0)
{
sourceListValue += ";";
}
sourceListValue += newName + ".cxx";
// Write file to java dependency file
std::string jafaFile = resultDirectory;
jafaFile += "/";
jafaFile += srcName;
jafaFile += ".java";
depFile << " " << jafaFile << std::endl;
}
}
// Finalize java dependency file
depFile << ")" << std::endl;
this->Makefile->AddDefinition(this->SourceList.c_str(),
sourceListValue.c_str());
return true;
}
void cmVTKWrapJavaCommand::FinalPass()
{
// first we add the rules for all the .h to Java.cxx files
size_t lastClass = this->WrapClasses.size();
std::vector<std::string> depends;
std::vector<std::string> depends2;
std::vector<std::string> alldepends;
const char* wjava =
this->Makefile->GetRequiredDefinition("VTK_WRAP_JAVA_EXE");
const char* pjava =
this->Makefile->GetRequiredDefinition("VTK_PARSE_JAVA_EXE");
const char* hints = this->Makefile->GetDefinition("VTK_WRAP_HINTS");
const char* resultDirectory =
this->Makefile->GetRequiredDefinition("VTK_JAVA_HOME");
// wrap all the .h files
depends.push_back(wjava);
depends2.push_back(pjava);
if(hints)
{
depends.push_back(hints);
depends2.push_back(hints);
}
for(size_t classNum = 0; classNum < lastClass; classNum++)
{
this->Makefile->AddSource(this->WrapClasses[classNum]);
// wrap java
std::string res = this->Makefile->GetCurrentOutputDirectory();
res += "/";
res += this->WrapClasses[classNum].GetSourceName() + ".cxx";
std::string res2 = resultDirectory;
res2 += "/";
res2 += this->OriginalNames[classNum];
res2 += ".java";
cmCustomCommandLine commandLineW;
commandLineW.push_back(wjava);
commandLineW.push_back(this->WrapHeaders[classNum]);
if(hints)
{
commandLineW.push_back(hints);
}
commandLineW.push_back((this->WrapClasses[classNum].
GetPropertyAsBool("ABSTRACT") ? "0" : "1"));
commandLineW.push_back(res);
cmCustomCommandLines commandLines;
commandLines.push_back(commandLineW);
std::vector<std::string> outputs;
outputs.push_back(res);
const char* no_comment = 0;
this->Makefile->AddCustomCommandOldStyle(this->LibraryName.c_str(),
outputs,
depends,
this->WrapHeaders[classNum].c_str(),
commandLines,
no_comment);
cmCustomCommandLine commandLineP;
commandLineP.push_back(pjava);
commandLineP.push_back(this->WrapHeaders[classNum]);
if(hints)
{
commandLineP.push_back(hints);
}
commandLineP.push_back((this->WrapClasses[classNum].
GetPropertyAsBool("ABSTRACT") ? "0" : "1"));
commandLineP.push_back(res2);
cmCustomCommandLines commandLines2;
commandLines2.push_back(commandLineP);
std::vector<std::string> outputs2;
outputs2.push_back(res2);
this->Makefile->AddCustomCommandOldStyle(this->LibraryName.c_str(),
outputs2,
depends2,
this->WrapHeaders[classNum].c_str(),
commandLines2,
no_comment);
alldepends.push_back(res2);
}
const char* no_working_directory = 0;
this->Makefile->AddUtilityCommand(
(this->LibraryName+"JavaClasses").c_str(),
true, alldepends, no_working_directory, "");
}

View File

@ -1,96 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVTKWrapJavaCommand_h
#define cmVTKWrapJavaCommand_h
#include "cmCommand.h"
#include "cmSourceFile.h"
/** \class cmVTKWrapJavaCommand
* \brief Create Java Language bindings for classes
*
* cmVTKWrapJavaCommand is used to create wrappers for classes into Java
*/
class cmVTKWrapJavaCommand : public cmCommand
{
public:
cmTypeMacro(cmVTKWrapJavaCommand, cmCommand);
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmVTKWrapJavaCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
virtual void FinalPass();
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "VTK_WRAP_JAVA";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Deprecated. For use only in VTK 4.0.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" VTK_WRAP_JAVA(resultingLibraryName SourceListName\n"
" class1 class2 ...)\n"
"Create Java wrappers for VTK classes.";
}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged()
{
return true;
}
private:
std::vector<cmSourceFile> WrapClasses;
std::vector<std::string> WrapHeaders;
std::vector<std::string> OriginalNames;
std::string LibraryName;
std::string SourceList;
};
#endif

View File

@ -1,262 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVTKWrapPythonCommand.h"
// cmVTKWrapPythonCommand
bool cmVTKWrapPythonCommand::InitialPass(std::vector<std::string> const&
argsIn)
{
if(argsIn.size() < 3 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
// Now check and see if the value has been stored in the cache
// already, if so use that value and don't look for the program
if(!this->Makefile->IsOn("VTK_WRAP_PYTHON"))
{
return true;
}
// what is the current source dir
std::string cdir = this->Makefile->GetCurrentDirectory();
// keep the library name
this->LibraryName = args[0];
this->SourceList = args[1];
std::string sourceListValue;
// was the list already populated
const char *def = this->Makefile->GetDefinition(this->SourceList.c_str());
if (def)
{
sourceListValue = def;
sourceListValue += ";";
}
// Create the init file
std::string res = this->LibraryName;
res += "Init.cxx";
// add the init file
std::string initName = this->LibraryName;
initName += "Init";
sourceListValue += initName + ".cxx";
// get the list of classes for this library
for(std::vector<std::string>::iterator j = (args.begin() + 2);
j != args.end(); ++j)
{
cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
// if we should wrap the class
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
{
cmSourceFile file;
file.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
if (curr)
{
file.SetProperty("ABSTRACT",curr->GetProperty("ABSTRACT"));
}
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
std::string newName = srcName + "Python";
file.SetName(newName.c_str(),
this->Makefile->GetCurrentOutputDirectory(),
"cxx",false);
std::string hname = cdir + "/" + srcName + ".h";
this->WrapHeaders.push_back(hname);
// add starting depends
file.GetDepends().push_back(hname);
this->WrapClasses.push_back(file);
sourceListValue += ";";
sourceListValue += newName + ".cxx";
}
}
cmSourceFile cfile;
cfile.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
cfile.SetProperty("ABSTRACT","0");
this->CreateInitFile(res);
cfile.SetName(initName.c_str(), this->Makefile->GetCurrentOutputDirectory(),
"cxx",false);
this->Makefile->AddSource(cfile);
this->Makefile->AddDefinition(this->SourceList.c_str(),
sourceListValue.c_str());
return true;
}
void cmVTKWrapPythonCommand::FinalPass()
{
// first we add the rules for all the .h to Python.cxx files
size_t lastClass = this->WrapClasses.size();
std::vector<std::string> depends;
const char* wpython =
this->Makefile->GetRequiredDefinition("VTK_WRAP_PYTHON_EXE");
const char* hints = this->Makefile->GetDefinition("VTK_WRAP_HINTS");
// wrap all the .h files
depends.push_back(wpython);
if(hints)
{
depends.push_back(hints);
}
for(size_t classNum = 0; classNum < lastClass; classNum++)
{
this->Makefile->AddSource(this->WrapClasses[classNum]);
std::string res = this->Makefile->GetCurrentOutputDirectory();
res += "/";
res += this->WrapClasses[classNum].GetSourceName() + ".cxx";
cmCustomCommandLine commandLine;
commandLine.push_back(wpython);
commandLine.push_back(this->WrapHeaders[classNum]);
if(hints)
{
commandLine.push_back(hints);
}
commandLine.push_back((this->WrapClasses[classNum].
GetPropertyAsBool("ABSTRACT") ? "0" : "1"));
commandLine.push_back(res);
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
std::vector<std::string> outputs;
outputs.push_back(res);
const char* no_comment = 0;
this->Makefile->AddCustomCommandOldStyle(this->LibraryName.c_str(),
outputs,
depends,
this->WrapHeaders[classNum].c_str(),
commandLines,
no_comment);
}
}
bool cmVTKWrapPythonCommand::CreateInitFile(std::string& res)
{
std::vector<std::string> classes;
size_t lastClass = this->WrapHeaders.size();
size_t classNum;
for(classNum = 0; classNum < lastClass; classNum++)
{
std::string cls = this->WrapHeaders[classNum];
cls = cls.substr(0,cls.size()-2);
std::string::size_type pos = cls.rfind('/');
if(pos != std::string::npos)
{
cls = cls.substr(pos+1);
}
classes.push_back(cls);
}
// open the init file
std::string outFileName =
this->Makefile->GetCurrentOutputDirectory();
outFileName += "/" + res;
return this->WriteInit(this->LibraryName.c_str(), outFileName, classes);
}
/* warning this code is also in getclasses.cxx under pcmaker */
bool cmVTKWrapPythonCommand::WriteInit(const char *kitName,
std::string& outFileName,
std::vector<std::string>& classes)
{
unsigned int i;
std::string tempOutputFile = outFileName + ".tmp";
FILE *fout = fopen(tempOutputFile.c_str(),"w");
if (!fout)
{
cmSystemTools::ReportLastSystemError("cmVTKWrapPythonCommand error:");
return false;
}
fprintf(fout,"// Generated by cmVTKWrapPythonCommand in CMake\n\n");
fprintf(fout,"#include <string.h>\n");
fprintf(fout,"#include \"Python.h\"\n\n");
fprintf(fout,"// Handle compiler warning messages, etc.\n"
"#if defined( _MSC_VER ) && !defined(VTK_DISPLAY_WIN32_WARNINGS)\n"
"#pragma warning ( disable : 4706 )\n"
"#endif // Windows Warnings \n\n");
for (i = 0; i < classes.size(); i++)
{
#ifdef _WIN32
fprintf(fout, "extern \"C\" {__declspec( dllexport) "
"PyObject *PyVTKClass_%sNew(char *); }\n", classes[i].c_str());
#else
fprintf(fout,"extern \"C\" {PyObject *PyVTKClass_%sNew(char *); }\n",
classes[i].c_str());
#endif
}
fprintf(fout,"\nstatic PyMethodDef Py%s_ClassMethods[] = {\n",
kitName);
fprintf(fout,"{NULL, NULL, 0, NULL}};\n\n");
#ifdef _WIN32
fprintf(fout,"extern \"C\" {__declspec( dllexport) void init%s();}\n\n",
kitName);
fprintf(fout,"void init%s()\n{\n",kitName);
#else
fprintf(fout,"extern \"C\" {void initlib%s();}\n\n",kitName);
fprintf(fout,"void initlib%s()\n{\n",kitName);
#endif
/* module init function */
fprintf(fout," PyObject *m, *d, *c;\n\n");
#ifdef _WIN32
fprintf(fout," static char modulename[] = \"%s\";\n",kitName);
#else
fprintf(fout," static char modulename[] = \"lib%s\";\n",kitName);
#endif
fprintf(fout," m = Py_InitModule(modulename, Py%s_ClassMethods);\n",
kitName);
fprintf(fout," d = PyModule_GetDict(m);\n");
fprintf(fout," if (!d) Py_FatalError"
"(\"can't get dictionary for module %s!\");\n\n", kitName);
for (i = 0; i < classes.size(); i++)
{
fprintf(fout," if ((c = PyVTKClass_%sNew(modulename)))\n",
classes[i].c_str());
fprintf(fout," if (-1 == PyDict_SetItemString(d, \"%s\", c))\n",
classes[i].c_str());
fprintf(fout,
" Py_FatalError(\"can't add class %s to dictionary!\");\n\n",
classes[i].c_str());
}
fprintf(fout,"}\n\n");
fclose(fout);
// copy the file if different
cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
outFileName.c_str());
cmSystemTools::RemoveFile(tempOutputFile.c_str());
return true;
}

View File

@ -1,102 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVTKWrapPythonCommand_h
#define cmVTKWrapPythonCommand_h
#include "cmCommand.h"
#include "cmSourceFile.h"
/** \class cmVTKWrapPythonCommand
* \brief Create Python Language bindings for classes
*
* cmVTKWrapPythonCommand is used to create wrappers for classes into Python
*/
class cmVTKWrapPythonCommand : public cmCommand
{
public:
cmTypeMacro(cmVTKWrapPythonCommand, cmCommand);
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmVTKWrapPythonCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
virtual void FinalPass();
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "VTK_WRAP_PYTHON";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Deprecated. For use only in VTK 4.0.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" VTK_WRAP_PYTHON(resultingLibraryName SourceListName\n"
" class1 class2 ...)\n"
"Create Python wrappers for VTK classes.";
}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged()
{
return true;
}
/**
* Helper methods
*/
virtual bool CreateInitFile(std::string &name);
virtual bool WriteInit(const char *kitName, std::string& outFileName,
std::vector<std::string>& classes);
private:
std::vector<cmSourceFile> WrapClasses;
std::vector<std::string> WrapHeaders;
std::string LibraryName;
std::string SourceList;
};
#endif

View File

@ -1,388 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVTKWrapTclCommand.h"
// cmVTKWrapTclCommand
bool cmVTKWrapTclCommand::InitialPass(std::vector<std::string> const& argsIn)
{
if(argsIn.size() < 3 )
{
this->SetError("called with incorrect number of arguments");
return false;
}
std::vector<std::string> args;
// keep the library name
this->LibraryName = argsIn[0];
if (argsIn[1] == std::string("SOURCES"))
{
this->Makefile->ExpandSourceListArguments(argsIn, args, 3);
}
else
{
this->Makefile->ExpandSourceListArguments(argsIn, args, 2);
}
// Now check and see if the value has been stored in the cache
// already, if so use that value and don't look for the program
if(!this->Makefile->IsOn("VTK_WRAP_TCL"))
{
return true;
}
// extract the sources and commands parameters
std::vector<std::string> sources;
bool doing_sources = true;
for(std::vector<std::string>::const_iterator j = (args.begin() + 1);
j != args.end(); ++j)
{
if(*j == "SOURCES")
{
doing_sources = true;
}
else if (*j == "COMMANDS")
{
doing_sources = false;
}
else
{
if(doing_sources)
{
sources.push_back(*j);
}
else
{
this->Commands.push_back(*j);
}
}
}
// get the list of classes for this library
if (sources.size())
{
// what is the current source dir
std::string cdir = this->Makefile->GetCurrentDirectory();
// get the resulting source list name
this->SourceList = sources[0];
std::string sourceListValue;
// was the list already populated
const char *def =
this->Makefile->GetDefinition(this->SourceList.c_str());
if (def)
{
sourceListValue = def;
sourceListValue += ";";
}
// Create the init file
std::string res = this->LibraryName;
res += "Init.cxx";
sourceListValue += res;
for(std::vector<std::string>::iterator j = (sources.begin() + 1);
j != sources.end(); ++j)
{
cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
// if we should wrap the class
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
{
cmSourceFile file;
file.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
std::string srcDir = cdir;
if (curr)
{
file.SetProperty("ABSTRACT",curr->GetProperty("ABSTRACT"));
srcDir = cmSystemTools::GetFilenamePath(curr->GetFullPath());
}
std::string srcName = cmSystemTools::GetFilenameWithoutExtension(*j);
std::string newName = srcName + "Tcl";
std::string hname = srcDir + "/" + srcName + ".h";
file.SetName(newName.c_str(),
this->Makefile->GetCurrentOutputDirectory(),
"cxx",false);
this->WrapHeaders.push_back(hname);
// add starting depends
file.GetDepends().push_back(hname);
this->WrapClasses.push_back(file);
sourceListValue += ";";
sourceListValue += newName + ".cxx";
}
}
// add the init file
cmSourceFile cfile;
cfile.GetProperties().SetCMakeInstance
(this->Makefile->GetCMakeInstance());
cfile.SetProperty("ABSTRACT","0");
std::string newName = this->LibraryName;
newName += "Init";
this->CreateInitFile(res);
cfile.SetName(newName.c_str(),
this->Makefile->GetCurrentOutputDirectory(),
"cxx",false);
this->Makefile->AddSource(cfile);
this->Makefile->AddDefinition(this->SourceList.c_str(),
sourceListValue.c_str());
}
return true;
}
void cmVTKWrapTclCommand::FinalPass()
{
// first we add the rules for all the .h to Tcl.cxx files
size_t lastClass = this->WrapClasses.size();
std::vector<std::string> depends;
const char* wtcl =
this->Makefile->GetRequiredDefinition("VTK_WRAP_TCL_EXE");
const char* hints = this->Makefile->GetDefinition("VTK_WRAP_HINTS");
// wrap all the .h files
depends.push_back(wtcl);
if(hints)
{
depends.push_back(hints);
}
for(size_t classNum = 0; classNum < lastClass; classNum++)
{
this->Makefile->AddSource(this->WrapClasses[classNum]);
cmCustomCommandLine commandLine;
commandLine.push_back(wtcl);
commandLine.push_back(this->WrapHeaders[classNum]);
if(hints)
{
commandLine.push_back(hints);
}
commandLine.push_back((this->WrapClasses[classNum].
GetPropertyAsBool("ABSTRACT") ? "0" : "1"));
std::string res = this->Makefile->GetCurrentOutputDirectory();
res += "/";
res += this->WrapClasses[classNum].GetSourceName() + ".cxx";
commandLine.push_back(res);
cmCustomCommandLines commandLines;
commandLines.push_back(commandLine);
std::vector<std::string> outputs;
outputs.push_back(res);
const char* no_comment = 0;
this->Makefile->AddCustomCommandOldStyle(this->LibraryName.c_str(),
outputs,
depends,
this->WrapHeaders[classNum].c_str(),
commandLines,
no_comment);
}
}
bool cmVTKWrapTclCommand::CreateInitFile(std::string& res)
{
/* we have to make sure that the name is the correct case */
std::string kitName = cmSystemTools::Capitalized(this->LibraryName);
std::vector<std::string> classes;
size_t lastClass = this->WrapHeaders.size();
size_t classNum;
for(classNum = 0; classNum < lastClass; classNum++)
{
if (!this->WrapClasses[classNum].GetPropertyAsBool("ABSTRACT"))
{
std::string cls = this->WrapHeaders[classNum];
cls = cls.substr(0,cls.size()-2);
std::string::size_type pos = cls.rfind('/');
if(pos != std::string::npos)
{
cls = cls.substr(pos+1);
}
classes.push_back(cls);
}
}
// open the init file
std::string outFileName =
this->Makefile->GetCurrentOutputDirectory();
outFileName += "/" + res;
return this->WriteInit(kitName.c_str(), outFileName, classes);
}
/* warning this code is also in getclasses.cxx under pcmaker */
bool cmVTKWrapTclCommand::WriteInit(const char *kitName,
std::string& outFileName,
std::vector<std::string>& classes)
{
unsigned int i;
std::string tempOutputFile = outFileName + ".tmp";
FILE *fout = fopen(tempOutputFile.c_str(),"w");
if (!fout)
{
cmSystemTools::Error("Failed to open TclInit file for ",
tempOutputFile.c_str());
cmSystemTools::ReportLastSystemError("");
return false;
}
// capitalized commands just once
std::vector<std::string> capcommands;
for (i = 0; i < this->Commands.size(); i++)
{
capcommands.push_back(cmSystemTools::Capitalized(this->Commands[i]));
}
fprintf(fout,"#include \"vtkTclUtil.h\"\n");
fprintf(fout,"#include \"vtkVersion.h\"\n");
fprintf(fout,"#define VTK_TCL_TO_STRING(x) VTK_TCL_TO_STRING0(x)\n");
fprintf(fout,"#define VTK_TCL_TO_STRING0(x) #x\n");
fprintf(fout,
"extern \"C\"\n"
"{\n"
"#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4) "
"&& (TCL_RELEASE_LEVEL >= TCL_FINAL_RELEASE)\n"
" typedef int (*vtkTclCommandType)(ClientData, Tcl_Interp *,"
"int, CONST84 char *[]);\n"
"#else\n"
" typedef int (*vtkTclCommandType)(ClientData, Tcl_Interp *,"
"int, char *[]);\n"
"#endif\n"
"}\n"
"\n");
for (i = 0; i < classes.size(); i++)
{
fprintf(fout,"int %sCommand(ClientData cd, Tcl_Interp *interp,\n"
,classes[i].c_str());
fprintf(fout," int argc, char *argv[]);\n");
fprintf(fout,"ClientData %sNewCommand();\n",classes[i].c_str());
}
if (!strcmp(kitName,"Vtkcommontcl"))
{
fprintf(fout,"int vtkCommand(ClientData cd, Tcl_Interp *interp,\n"
" int argc, char *argv[]);\n");
fprintf(fout,"\nTcl_HashTable vtkInstanceLookup;\n");
fprintf(fout,"Tcl_HashTable vtkPointerLookup;\n");
fprintf(fout,"Tcl_HashTable vtkCommandLookup;\n");
fprintf(fout,"int vtkCommandForward(ClientData cd, Tcl_Interp *interp,\n"
" int argc, char *argv[]){\n"
" return vtkCommand(cd, interp, argc, argv);\n"
"}\n");
}
else
{
fprintf(fout,"\nextern Tcl_HashTable vtkInstanceLookup;\n");
fprintf(fout,"extern Tcl_HashTable vtkPointerLookup;\n");
fprintf(fout,"extern Tcl_HashTable vtkCommandLookup;\n");
}
fprintf(fout,"extern void vtkTclDeleteObjectFromHash(void *);\n");
fprintf(fout,"extern void vtkTclListInstances(Tcl_Interp *interp,"
"ClientData arg);\n");
for (i = 0; i < this->Commands.size(); i++)
{
fprintf(fout,
"\nextern \"C\" {int VTK_EXPORT %s_Init(Tcl_Interp *interp);}\n",
capcommands[i].c_str());
}
fprintf(fout,"\n\nextern \"C\" {int VTK_EXPORT "
"%s_SafeInit(Tcl_Interp *interp);}\n", kitName);
fprintf(fout,"\nextern \"C\" {int VTK_EXPORT %s_Init"
"(Tcl_Interp *interp);}\n", kitName);
/* create an extern ref to the generic delete function */
fprintf(fout,"\nextern void vtkTclGenericDeleteObject(ClientData cd);\n");
if (!strcmp(kitName,"Vtkcommontcl"))
{
fprintf(fout,"extern \"C\"\n{\nvoid "
"vtkCommonDeleteAssocData(ClientData cd)\n");
fprintf(fout," {\n");
fprintf(fout," vtkTclInterpStruct *tis = "
"static_cast<vtkTclInterpStruct*>(cd);\n");
fprintf(fout," delete tis;\n }\n}\n");
}
/* the main declaration */
fprintf(fout,
"\n\nint VTK_EXPORT %s_SafeInit(Tcl_Interp *interp)\n{\n",kitName);
fprintf(fout," return %s_Init(interp);\n}\n",kitName);
fprintf(fout,"\n\nint VTK_EXPORT %s_Init(Tcl_Interp *interp)\n{\n",
kitName);
if (!strcmp(kitName,"Vtkcommontcl"))
{
fprintf(fout,
" vtkTclInterpStruct *info = new vtkTclInterpStruct;\n");
fprintf(fout,
" info->Number = 0; info->InDelete = 0; info->DebugOn = 0;\n");
fprintf(fout,"\n");
fprintf(fout,"\n");
fprintf(fout,
" Tcl_InitHashTable(&info->InstanceLookup, TCL_STRING_KEYS);\n");
fprintf(fout,
" Tcl_InitHashTable(&info->PointerLookup, TCL_STRING_KEYS);\n");
fprintf(fout,
" Tcl_InitHashTable(&info->CommandLookup, TCL_STRING_KEYS);\n");
fprintf(fout, " Tcl_SetAssocData(interp,(char *) "
"\"vtk\",NULL,(ClientData *)info);\n");
fprintf(fout, " Tcl_CreateExitHandler(vtkCommonDeleteAssocData"
",(ClientData *)info);\n");
/* create special vtkCommand command */
fprintf(fout,
" Tcl_CreateCommand(interp,(char *) \"vtkCommand\",\n"
" reinterpret_cast<vtkTclCommandType>("
"vtkCommandForward),\n"
" (ClientData *)NULL, NULL);\n\n");
}
for (i = 0; i < this->Commands.size(); i++)
{
fprintf(fout," %s_Init(interp);\n", capcommands[i].c_str());
}
fprintf(fout,"\n");
for (i = 0; i < classes.size(); i++)
{
fprintf(fout," vtkTclCreateNew(interp,(char *) \"%s\", %sNewCommand,\n",
classes[i].c_str(), classes[i].c_str());
fprintf(fout," %sCommand);\n",classes[i].c_str());
}
fprintf(fout," char pkgName[]=\"%s\";\n", this->LibraryName.c_str());
fprintf(fout," char pkgVers[]=VTK_TCL_TO_STRING(VTK_MAJOR_VERSION)"
" \".\" "
"VTK_TCL_TO_STRING(VTK_MINOR_VERSION);\n");
fprintf(fout," Tcl_PkgProvide(interp, pkgName, pkgVers);\n");
fprintf(fout," return TCL_OK;\n}\n");
fclose(fout);
// copy the file if different
cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(),
outFileName.c_str());
cmSystemTools::RemoveFile(tempOutputFile.c_str());
return true;
}

View File

@ -1,105 +0,0 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVTKWrapTclCommand_h
#define cmVTKWrapTclCommand_h
#include "cmCommand.h"
#include "cmSourceFile.h"
/** \class cmVTKWrapTclCommand
* \brief Create Tcl Wrappers for VTK classes.
*
* cmVTKWrapTclCommand is used to define a CMake variable include
* path location by specifying a file and list of directories.
*/
class cmVTKWrapTclCommand : public cmCommand
{
public:
cmTypeMacro(cmVTKWrapTclCommand, cmCommand);
/**
* This is a virtual constructor for the command.
*/
virtual cmCommand* Clone()
{
return new cmVTKWrapTclCommand;
}
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const& args);
/**
* This is called at the end after all the information
* specified by the command is accumulated. Most commands do
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
virtual void FinalPass();
/**
* The name of the command as specified in CMakeList.txt.
*/
virtual const char* GetName() { return "VTK_WRAP_TCL";}
/**
* Succinct documentation.
*/
virtual const char* GetTerseDocumentation()
{
return "Deprecated. For use only in VTK 4.0.";
}
/**
* More documentation.
*/
virtual const char* GetFullDocumentation()
{
return
" VTK_WRAP_TCL(resultingLibraryName [SOURCES]\n"
" SourceListName class1 class2 ...\n"
" [COMMANDS CommandName1 CommandName2 ...])\n"
"Create Tcl wrappers for VTK classes.";
}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged()
{
return true;
}
/**
* Helper methods
*/
virtual bool CreateInitFile(std::string &name);
virtual bool WriteInit(const char *kitName, std::string& outFileName,
std::vector<std::string>& classes);
private:
std::vector<cmSourceFile> WrapClasses;
std::vector<std::string> WrapHeaders;
std::string LibraryName;
std::string SourceList;
std::vector<std::string> Commands;
};
#endif