Skip to content

Commit

Permalink
Move entry point into XRay::Editor namespace (https://github.com/Xott…
Browse files Browse the repository at this point in the history
…ab-DUTY/xray-16/issues/1)

And some additional macro usages
  • Loading branch information
Xottab-DUTY committed Nov 5, 2017
1 parent 7252c9a commit 74095a5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 17 deletions.
27 changes: 17 additions & 10 deletions src/editors/xrWeatherEditor/entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma unmanaged
#include <windows.h>
#include "Common/xr_impexp_macros.h"
#include "Include/editor/engine.hpp"
#include "ide_impl.hpp"
#pragma managed
Expand All @@ -10,10 +11,14 @@

#pragma comment(lib, "user32.lib")

namespace XRay
{
namespace Editor
{
private ref class window_ide_final : public editor::window_ide
{
public:
window_ide_final(XRay::Editor::ide_base*& ide, XRay::Editor::engine_base* engine) : editor::window_ide(engine)
window_ide_final(ide_base*& ide, engine_base* engine) : editor::window_ide(engine)
{
m_ide = ide;
Application::Idle += gcnew System::EventHandler(this, &window_ide_final::on_idle);
Expand Down Expand Up @@ -44,45 +49,47 @@ private ref class window_ide_final : public editor::window_ide
private:
void on_idle(System::Object ^ sender, System::EventArgs ^ event_args)
{
XRay::Editor::ide_impl* impl = dynamic_cast<XRay::Editor::ide_impl*>(m_ide);
ide_impl* impl = dynamic_cast<ide_impl*>(m_ide);
impl->on_idle_start();

MSG message;
do
{
m_engine->on_idle();
impl->on_idle();
} while (m_engine && !PeekMessage(&message, HWND(0), 0, 0, 0));
} while (m_engine&&!PeekMessage(&message, HWND(0), 0, 0, 0));

impl->on_idle_end();
}
};

XRay::Editor::ide_impl* g_ide = nullptr;
ide_impl* g_ide = nullptr;

static void initialize_impl(XRay::Editor::ide_base*& ide, XRay::Editor::engine_base* engine)
static void initialize_impl(ide_base*& ide, engine_base* engine)
{
VERIFY(!g_ide);
g_ide = new XRay::Editor::ide_impl(engine);
g_ide = new ide_impl(engine);
ide = g_ide;
g_ide->window(gcnew window_ide_final(ide, engine));
}
} // namespace Editor
} // namespace XRay

#pragma unmanaged
#include <objbase.h>
WINOLEAPI CoInitializeEx(IN LPVOID pvReserved, IN DWORD dwCoInit);
#pragma comment(lib, "ole32.lib")

extern "C" __declspec(dllexport) void initialize(XRay::Editor::ide_base*& ide, XRay::Editor::engine_base* engine)
extern "C" XR_EXPORT void initialize(XRay::Editor::ide_base*& ide, XRay::Editor::engine_base* engine)
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
initialize_impl(ide, engine);
XRay::Editor::initialize_impl(ide, engine);
}

extern "C" __declspec(dllexport) void finalize(XRay::Editor::ide_base*& ide)
extern "C" XR_EXPORT void finalize(XRay::Editor::ide_base*& ide)
{
delete (ide);
ide = nullptr;
g_ide = nullptr;
XRay::Editor::g_ide = nullptr;
}
#pragma managed
8 changes: 5 additions & 3 deletions src/editors/xrWeatherEditor/pch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
// Created : 04.12.2007
// Modified : 04.12.2007
// Author : Dmitriy Iassenev
// Description : preocmpiled header for editor library
// Description : precompiled header for editor library
////////////////////////////////////////////////////////////////////////////

#ifndef PCH_HPP_INCLUDED
#define PCH_HPP_INCLUDED

#include "xrCommon/inlining_macros.h"

#ifdef DEBUG
#define VERIFY(expression) \
do \
Expand All @@ -19,14 +21,14 @@
#define NODEFAULT \
do \
{ \
__debugbreak(); \
DEBUG_BREAK; \
} while (0)
#else // #ifdef DEBUG
#define VERIFY(expression) \
do \
{ \
} while (0)
#define NODEFAULT __assume(0)
#define NODEFAULT XR_ASSUME(0)
#endif // #ifdef DEBUG

typedef unsigned int u32;
Expand Down
10 changes: 8 additions & 2 deletions src/editors/xrWeatherEditor/property_collection_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ using System::ComponentModel::Design::CollectionEditor;
typedef PropertyBag::PropertySpecDescriptor PropertySpecDescriptor;

#pragma unmanaged
extern XRay::Editor::ide_impl* g_ide;
namespace XRay
{
namespace Editor
{
extern ide_impl* g_ide;
}
}
#pragma managed

property_collection_editor::property_collection_editor(Type ^ type) : inherited(type) {}
Expand Down Expand Up @@ -58,7 +64,7 @@ String ^ property_collection_editor::GetDisplayText(Object ^ value)
return (to_string(buffer));
}

void property_collection_editor::on_move(Object ^ sender, EventArgs ^ e) { g_ide->window()->view().Invalidate(); }
void property_collection_editor::on_move(Object ^ sender, EventArgs ^ e) { XRay::Editor::g_ide->window()->view().Invalidate(); }
property_collection_editor::CollectionForm ^ property_collection_editor::CreateCollectionForm()
{
//VERIFY(!m_collection_form);
Expand Down
5 changes: 3 additions & 2 deletions src/editors/xrWeatherEditor/property_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace XRay
namespace Editor
{
class ide_impl;
extern ide_impl* g_ide;
}
}
extern XRay::Editor::ide_impl* g_ide;

#pragma managed

property_container::property_container(property_holder* holder, property_container_holder ^ container_holder)
Expand All @@ -41,7 +42,7 @@ property_container::!property_container()
if (!m_holder)
return;

if (!g_ide)
if (!XRay::Editor::g_ide)
return;

property_holder* holder = dynamic_cast<property_holder*>(m_holder);
Expand Down

0 comments on commit 74095a5

Please sign in to comment.