Skip to content

Commit

Permalink
#5426: Fix compilation against pybind11 2.6+
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 22, 2020
1 parent 455dd46 commit 3e480af
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 21 deletions.
25 changes: 6 additions & 19 deletions include/iscript.h
Expand Up @@ -3,10 +3,6 @@
#include "imodule.h"
#include <sigc++/signal.h>

// Forward-declare the stuff in <pybind11/pybind11.h>
namespace pybind11 { class module; class dict; }
namespace py = pybind11;

namespace script
{

Expand All @@ -20,19 +16,8 @@ struct ExecutionResult
};
typedef std::shared_ptr<ExecutionResult> ExecutionResultPtr;

} // namespace script

class IScriptInterface
{
public:
virtual ~IScriptInterface() {}

/**
* This method is called by the Scripting System to let this class
* add its objects to the Python context.
*/
virtual void registerInterface(py::module& scope, py::dict& globals) = 0;
};
// Declared in iscriptinterface.h
class IScriptInterface;
typedef std::shared_ptr<IScriptInterface> IScriptInterfacePtr;

// Represents a named, executable .py script file
Expand Down Expand Up @@ -86,12 +71,14 @@ class IScriptingSystem :
};
typedef std::shared_ptr<IScriptingSystem> IScriptingSystemPtr;

} // namespace script

// String identifier for the script module
const char* const MODULE_SCRIPTING_SYSTEM("ScriptingSystem");

// This is the accessor for the scripting system
inline IScriptingSystem& GlobalScriptingSystem()
inline script::IScriptingSystem& GlobalScriptingSystem()
{
static module::InstanceReference<IScriptingSystem> _reference(MODULE_SCRIPTING_SYSTEM);
static module::InstanceReference<script::IScriptingSystem> _reference(MODULE_SCRIPTING_SYSTEM);
return _reference;
}
23 changes: 23 additions & 0 deletions include/iscriptinterface.h
@@ -0,0 +1,23 @@
#pragma once

#include <memory>
#include <pybind11/pybind11.h>
namespace py = pybind11;

namespace script
{

class IScriptInterface
{
public:
virtual ~IScriptInterface() {}

/**
* This method is called by the Scripting System to let this class
* add its objects to the Python context.
*/
virtual void registerInterface(py::module& scope, py::dict& globals) = 0;
};
typedef std::shared_ptr<IScriptInterface> IScriptInterfacePtr;

}
1 change: 1 addition & 0 deletions plugins/script/ScriptingSystem.h
Expand Up @@ -5,6 +5,7 @@
#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "PythonConsoleWriter.h"
#include "icommandsystem.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/BrushInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"
#include "ibrush.h"

#include "SceneGraphInterface.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/CameraInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"
#include "icameraview.h"

#include "MathInterface.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/CommandSystemInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

namespace script
{
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/DialogInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"
#include "idialogmanager.h"

namespace script
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/EClassInterface.h
Expand Up @@ -2,6 +2,7 @@

#include "ieclass.h"
#include "iscript.h"
#include "iscriptinterface.h"

#include <pybind11/pybind11.h>

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/EntityInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

#include "ientity.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/FileSystemInterface.h
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "ifilesystem.h"

namespace script
Expand Down
2 changes: 1 addition & 1 deletion plugins/script/interfaces/GameInterface.h
@@ -1,7 +1,7 @@
#pragma once

#include "iscript.h"

#include "iscriptinterface.h"
#include "igame.h"
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/GridInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

namespace script
{
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/MapInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

#include "SceneGraphInterface.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/MathInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

namespace script
{
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/ModelInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

#include "imodel.h"
#include "SceneGraphInterface.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/PatchInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"
#include "ipatch.h"

#include "SceneGraphInterface.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/RadiantInterface.h
Expand Up @@ -2,6 +2,7 @@

#include "iradiant.h"
#include "iscript.h"
#include "iscriptinterface.h"

#include "EntityInterface.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/RegistryInterface.h
Expand Up @@ -2,6 +2,7 @@

#include "iregistry.h"
#include "iscript.h"
#include "iscriptinterface.h"
#include <pybind11/pybind11.h>

namespace script
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SceneGraphInterface.h
Expand Up @@ -2,6 +2,7 @@

#include "inode.h"
#include "iscript.h"
#include "iscriptinterface.h"
#include "iscenegraph.h"
#include "math/AABB.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SelectionGroupInterface.h
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "iselectiongroup.h"

#include "SceneGraphInterface.h"
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SelectionInterface.h
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "selectionlib.h"
#include <map>

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SelectionSetInterface.h
Expand Up @@ -3,6 +3,7 @@
#include <pybind11/pybind11.h>

#include "iscript.h"
#include "iscriptinterface.h"
#include "iselectionset.h"

namespace script
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/ShaderSystemInterface.h
Expand Up @@ -4,6 +4,7 @@

#include "ishaders.h"
#include "iscript.h"
#include "iscriptinterface.h"

namespace script
{
Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SkinInterface.h
@@ -1,6 +1,7 @@
#pragma once

#include "iscript.h"
#include "iscriptinterface.h"

#include "modelskin.h"

Expand Down
1 change: 1 addition & 0 deletions plugins/script/interfaces/SoundInterface.h
Expand Up @@ -2,6 +2,7 @@

#include "isound.h"
#include "iscript.h"
#include "iscriptinterface.h"

namespace script
{
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/script/ScriptMenu.cpp
Expand Up @@ -31,7 +31,7 @@ ScriptMenu::ScriptMenu()
typedef std::multimap<std::string, std::string> SortedCommands;
SortedCommands sortedCommands;

GlobalScriptingSystem().foreachScriptCommand([&](const IScriptCommand& cmd)
GlobalScriptingSystem().foreachScriptCommand([&](const script::IScriptCommand& cmd)
{
sortedCommands.insert(std::make_pair(cmd.getDisplayName(), cmd.getName()));
});
Expand Down

0 comments on commit 3e480af

Please sign in to comment.