Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/path-length
Browse files Browse the repository at this point in the history
  • Loading branch information
sliptonic committed Jan 18, 2020
2 parents 0788ce1 + 120b69c commit ec80948
Show file tree
Hide file tree
Showing 13 changed files with 254 additions and 434 deletions.
38 changes: 29 additions & 9 deletions src/App/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@
using namespace App;
using namespace std;
using namespace boost;
using namespace boost::program_options;


// scriptings (scripts are built-in but can be overridden by command line option)
#include <App/InitScript.h>
#include <App/TestScript.h>
#include <App/CMakeScript.h>
using namespace boost::program_options;


// scriptings (scripts are built-in but can be overridden by command line option)
#include <App/InitScript.h>
#include <App/TestScript.h>
#include <App/CMakeScript.h>

#ifdef _MSC_VER // New handler for Microsoft Visual C++ compiler
# pragma warning( disable : 4535 )
Expand Down Expand Up @@ -1082,6 +1082,16 @@ void Application::addImportType(const char* Type, const char* ModuleName)
}
}

void Application::changeImportModule(const char* Type, const char* OldModuleName, const char* NewModuleName)
{
for (auto& it : _mImportTypes) {
if (it.filter == Type && it.module == OldModuleName) {
it.module = NewModuleName;
break;
}
}
}

std::vector<std::string> Application::getImportModules(const char* Type) const
{
std::vector<std::string> modules;
Expand Down Expand Up @@ -1195,6 +1205,16 @@ void Application::addExportType(const char* Type, const char* ModuleName)
}
}

void Application::changeExportModule(const char* Type, const char* OldModuleName, const char* NewModuleName)
{
for (auto& it : _mExportTypes) {
if (it.filter == Type && it.module == OldModuleName) {
it.module = NewModuleName;
break;
}
}
}

std::vector<std::string> Application::getExportModules(const char* Type) const
{
std::vector<std::string> modules;
Expand Down Expand Up @@ -2256,7 +2276,7 @@ void Application::LoadParameters(void)

#if defined(_MSC_VER)
// fix weird error while linking boost (all versions of VC)
// VS2010: https://forum.freecadweb.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
// VS2010: https://forum.freecadweb.org/viewtopic.php?f=4&t=1886&p=12553&hilit=boost%3A%3Afilesystem%3A%3Aget#p12553
namespace boost { namespace program_options { std::string arg="arg"; } }
#if (defined (BOOST_VERSION) && (BOOST_VERSION >= 104100))
namespace boost { namespace program_options {
Expand Down Expand Up @@ -2946,7 +2966,7 @@ std::string Application::FindHomePath(const char* sCall)
binPath += L"bin";
SetDllDirectoryW(binPath.c_str());

// https://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error
// https://stackoverflow.com/questions/5625884/conversion-of-stdwstring-to-qstring-throws-linker-error
#ifdef _MSC_VER
QString str = QString::fromUtf16(reinterpret_cast<const ushort *>(homePath.c_str()));
#else
Expand Down
6 changes: 6 additions & 0 deletions src/App/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class AppExport Application
//@{
/// Register an import filetype and a module name
void addImportType(const char* Type, const char* ModuleName);
/// Change the module name of a registered filetype
void changeImportModule(const char* Type, const char* OldModuleName, const char* NewModuleName);
/// Return a list of modules that support the given filetype.
std::vector<std::string> getImportModules(const char* Type) const;
/// Return a list of all modules.
Expand All @@ -316,6 +318,8 @@ class AppExport Application
//@{
/// Register an export filetype and a module name
void addExportType(const char* Type, const char* ModuleName);
/// Change the module name of a registered filetype
void changeExportModule(const char* Type, const char* OldModuleName, const char* NewModuleName);
/// Return a list of modules that support the given filetype.
std::vector<std::string> getExportModules(const char* Type) const;
/// Return a list of all modules.
Expand Down Expand Up @@ -458,8 +462,10 @@ class AppExport Application
static PyObject* sSetConfig (PyObject *self,PyObject *args);
static PyObject* sDumpConfig (PyObject *self,PyObject *args);
static PyObject* sAddImportType (PyObject *self,PyObject *args);
static PyObject* sChangeImportModule(PyObject *self,PyObject *args);
static PyObject* sGetImportType (PyObject *self,PyObject *args);
static PyObject* sAddExportType (PyObject *self,PyObject *args);
static PyObject* sChangeExportModule(PyObject *self,PyObject *args);
static PyObject* sGetExportType (PyObject *self,PyObject *args);
static PyObject* sGetResourceDir (PyObject *self,PyObject *args);
static PyObject* sGetUserAppDataDir (PyObject *self,PyObject *args);
Expand Down
28 changes: 28 additions & 0 deletions src/App/ApplicationPy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ PyMethodDef Application::Methods[] = {
"Dump the configuration to the output."},
{"addImportType", (PyCFunction) Application::sAddImportType, METH_VARARGS,
"Register filetype for import"},
{"changeImportModule", (PyCFunction) Application::sChangeImportModule, METH_VARARGS,
"Change the import module name of a registered filetype"},
{"getImportType", (PyCFunction) Application::sGetImportType, METH_VARARGS,
"Get the name of the module that can import the filetype"},
{"EndingAdd", (PyCFunction) Application::sAddImportType, METH_VARARGS, // deprecated
Expand All @@ -80,6 +82,8 @@ PyMethodDef Application::Methods[] = {
"deprecated -- use getImportType"},
{"addExportType", (PyCFunction) Application::sAddExportType, METH_VARARGS,
"Register filetype for export"},
{"changeExportModule", (PyCFunction) Application::sChangeExportModule, METH_VARARGS,
"Change the export module name of a registered filetype"},
{"getExportType", (PyCFunction) Application::sGetExportType, METH_VARARGS,
"Get the name of the module that can export the filetype"},
{"getResourceDir", (PyCFunction) Application::sGetResourceDir, METH_VARARGS,
Expand Down Expand Up @@ -526,6 +530,18 @@ PyObject* Application::sAddImportType(PyObject * /*self*/, PyObject *args)
Py_Return;
}

PyObject* Application::sChangeImportModule(PyObject * /*self*/, PyObject *args)
{
char *key,*oldMod,*newMod;

if (!PyArg_ParseTuple(args, "sss", &key,&oldMod,&newMod))
return nullptr;

GetApplication().changeImportModule(key,oldMod,newMod);

Py_Return;
}

PyObject* Application::sGetImportType(PyObject * /*self*/, PyObject *args)
{
char* psKey=0;
Expand Down Expand Up @@ -578,6 +594,18 @@ PyObject* Application::sAddExportType(PyObject * /*self*/, PyObject *args)
Py_Return;
}

PyObject* Application::sChangeExportModule(PyObject * /*self*/, PyObject *args)
{
char *key,*oldMod,*newMod;

if (!PyArg_ParseTuple(args, "sss", &key,&oldMod,&newMod))
return nullptr;

GetApplication().changeExportModule(key,oldMod,newMod);

Py_Return;
}

PyObject* Application::sGetExportType(PyObject * /*self*/, PyObject *args)
{
char* psKey=0;
Expand Down
6 changes: 6 additions & 0 deletions src/App/FreeCADInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,12 @@ def InitApplications():
FreeCAD.Console.PrintError("\n\nSeems the python standard libs are not installed, bailing out!\n\n")
raise

# Backward compatibility to Py2
import sys
if sys.version_info.major < 3:
import time
time.process_time = time.clock

class FCADLogger(object):
'''Convenient class for tagged logging.
Expand Down
Loading

0 comments on commit ec80948

Please sign in to comment.