Skip to content

Commit

Permalink
[#165] PyAcadApplicationImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
CEXT-Dan committed Jan 2, 2025
1 parent bcb7edf commit 1c02b7e
Show file tree
Hide file tree
Showing 37 changed files with 289 additions and 216 deletions.
8 changes: 8 additions & 0 deletions PyRxCore/PyAcadApplication.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "stdafx.h"
#include "PyAcadApplication.h"
#include "PyAcadApplicationImpl.h"

bool PyAcadApplication::runTest()
{
return PyAcadApplicationImpl::runTest();
}
10 changes: 10 additions & 0 deletions PyRxCore/PyAcadApplication.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#ifdef PYRXDEBUG
class PyAcadApplication
{
public:
static bool runTest();
};

#endif
57 changes: 57 additions & 0 deletions PyRxCore/PyAcadApplicationImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include "stdafx.h"
#include "PyAcadApplicationImpl.h"


#ifdef PYRXDEBUG
#include "propvarutil.h"

PyAcadApplicationImpl::PyAcadApplicationImpl()
: m_pimpl(acedGetIDispatch(FALSE))
{
}

void PyAcadApplicationImpl::Eval(const CString& csVal) const
{
_bstr_t bstrVal{ csVal };
PyThrowBadHr(impObj()->Eval(bstrVal));
}

std::vector<std::wstring> PyAcadApplicationImpl::ListArx()
{
VARIANT rtVal;
VariantInit(&rtVal);
#if defined(_ZRXTARGET)
PyThrowBadHr(impObj()->ListZrx(&rtVal));
#elif defined(_GRXTARGET)
PyThrowBadHr(impObj()->ListGrx(&rtVal));
#else
PyThrowBadHr(impObj()->ListArx(&rtVal));
#endif
ULONG pcElem = 0;
PWSTR* prgsz = nullptr;
std::vector<std::wstring> vec;
if (VariantToStringArrayAlloc(rtVal, &prgsz, &pcElem) == S_OK)
{
vec = std::vector<std::wstring>(prgsz, prgsz + pcElem);
CoTaskMemFree(prgsz);
}
return vec;
}

bool PyAcadApplicationImpl::runTest()
{
PyAcadApplicationImpl app;
for (const auto& item : app.ListArx())
acutPrintf(_T("\n%ls"), item.c_str());
return true;
}

IAcadApplication* PyAcadApplicationImpl::impObj(const std::source_location& src /*= std::source_location::current()*/) const
{
if (m_pimpl == nullptr) [[unlikely]] {
throw PyNullObject(src);
}
return static_cast<IAcadApplication*>(m_pimpl.GetInterfacePtr());
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#ifdef PYRXDEBUG

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

#if defined(_BRXTARGET) && (_BRXTARGET <= 250)
#import "axbricscaddb1.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "axbricscadapp1.tlb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
Expand Down Expand Up @@ -33,16 +35,37 @@

#if defined(_ZRXTARGET)
#define IAcadApplicationPtr IZcadApplicationPtr
#define IAcadApplication IZcadApplication

#define IAcadDocumentPtr IZcadDocumentPtr
#define IAcadDocument IZcadDocument
#endif

#if defined(_GRXTARGET)
#define IAcadApplicationPtr IGcadApplicationPtr
#define IAcadApplication IGcadApplication

#define IAcadDocumentPtr IGcadDocumentPtr
#define IAcadDocument IGcadDocument
#endif

class PyAxApplicationImpl
class PyAcadApplicationImpl
{
public:
PyAxApplicationImpl();
~PyAxApplicationImpl() = default;
PyAcadApplicationImpl();
~PyAcadApplicationImpl() = default;
void Eval(const CString& csVal) const;
//AcadState GetAcadState();
std::vector<std::wstring> ListArx();


static bool runTest();
public:
IAcadApplicationPtr m_pyimp;
IAcadApplication* impObj(const std::source_location& src = std::source_location::current()) const;
protected:
IAcadApplicationPtr m_pimpl;
};



#endif
2 changes: 2 additions & 0 deletions PyRxCore/PyAcadDatabase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "stdafx.h"
#include "PyAcadDatabase.h"
2 changes: 1 addition & 1 deletion PyRxCore/PyAxDatabase.h → PyRxCore/PyAcadDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#ifdef PYRXDEBUG

class PyAxDatabase
class PyAcadDatabase
{
};

Expand Down
2 changes: 2 additions & 0 deletions PyRxCore/PyAcadDatabaseImpl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "stdafx.h"
#include "PyAcadDatabaseImpl.h"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#ifdef PYRXDEBUG
class PyAxDatabaseImpl
class PyAcadDatabaseImpl
{
};
#endif
2 changes: 0 additions & 2 deletions PyRxCore/PyAxApplication.cpp

This file was deleted.

8 changes: 0 additions & 8 deletions PyRxCore/PyAxApplication.h

This file was deleted.

17 changes: 0 additions & 17 deletions PyRxCore/PyAxApplicationImpl.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions PyRxCore/PyAxDatabase.cpp

This file was deleted.

2 changes: 0 additions & 2 deletions PyRxCore/PyAxDatabaseImpl.cpp

This file was deleted.

16 changes: 8 additions & 8 deletions PyRxCore/PyRx24.0.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
<ClCompile Include="PlCore.cpp" />
<ClCompile Include="PyAcAx.cpp" />
<ClCompile Include="PyAcBr.cpp" />
<ClCompile Include="PyAxApplication.cpp" />
<ClCompile Include="PyAxApplicationImpl.cpp" />
<ClCompile Include="PyAxDatabase.cpp" />
<ClCompile Include="PyAxDatabaseImpl.cpp" />
<ClCompile Include="PyAcadApplication.cpp" />
<ClCompile Include="PyAcadApplicationImpl.cpp" />
<ClCompile Include="PyAcadDatabase.cpp" />
<ClCompile Include="PyAcadDatabaseImpl.cpp" />
<ClCompile Include="PyBrEntity.cpp" />
<ClCompile Include="PyBrTraverser.cpp" />
<ClCompile Include="PyDbDbLayerStateManager.cpp" />
Expand Down Expand Up @@ -277,10 +277,10 @@
<ClInclude Include="PlCore.h" />
<ClInclude Include="PyAcAx.h" />
<ClInclude Include="PyAcBr.h" />
<ClInclude Include="PyAxApplication.h" />
<ClInclude Include="PyAxApplicationImpl.h" />
<ClInclude Include="PyAxDatabase.h" />
<ClInclude Include="PyAxDatabaseImpl.h" />
<ClInclude Include="PyAcadApplication.h" />
<ClInclude Include="PyAcadApplicationImpl.h" />
<ClInclude Include="PyAcadDatabase.h" />
<ClInclude Include="PyAcadDatabaseImpl.h" />
<ClInclude Include="PyBrEntity.h" />
<ClInclude Include="PyBrTraverser.h" />
<ClInclude Include="PyDbDbLayerStateManager.h" />
Expand Down
16 changes: 8 additions & 8 deletions PyRxCore/PyRx24.0.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,16 @@
<ClCompile Include="PyAcAx.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxApplication.cpp">
<ClCompile Include="PyAcadApplication.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxDatabase.cpp">
<ClCompile Include="PyAcadDatabase.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxApplicationImpl.cpp">
<ClCompile Include="PyAcadApplicationImpl.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxDatabaseImpl.cpp">
<ClCompile Include="PyAcadDatabaseImpl.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -789,16 +789,16 @@
<ClInclude Include="PyAcAx.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxApplication.h">
<ClInclude Include="PyAcadApplication.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxDatabase.h">
<ClInclude Include="PyAcadDatabase.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxApplicationImpl.h">
<ClInclude Include="PyAcadApplicationImpl.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxDatabaseImpl.h">
<ClInclude Include="PyAcadDatabaseImpl.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
</ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions PyRxCore/PyRx24.1.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
<ClCompile Include="PlCore.cpp" />
<ClCompile Include="PyAcAx.cpp" />
<ClCompile Include="PyAcBr.cpp" />
<ClCompile Include="PyAxApplication.cpp" />
<ClCompile Include="PyAxApplicationImpl.cpp" />
<ClCompile Include="PyAxDatabase.cpp" />
<ClCompile Include="PyAxDatabaseImpl.cpp" />
<ClCompile Include="PyAcadApplication.cpp" />
<ClCompile Include="PyAcadApplicationImpl.cpp" />
<ClCompile Include="PyAcadDatabase.cpp" />
<ClCompile Include="PyAcadDatabaseImpl.cpp" />
<ClCompile Include="PyBrEntity.cpp" />
<ClCompile Include="PyBrTraverser.cpp" />
<ClCompile Include="PyDb3dProfile.cpp" />
Expand Down Expand Up @@ -277,10 +277,10 @@
<ClInclude Include="PlCore.h" />
<ClInclude Include="PyAcAx.h" />
<ClInclude Include="PyAcBr.h" />
<ClInclude Include="PyAxApplication.h" />
<ClInclude Include="PyAxApplicationImpl.h" />
<ClInclude Include="PyAxDatabase.h" />
<ClInclude Include="PyAxDatabaseImpl.h" />
<ClInclude Include="PyAcadApplication.h" />
<ClInclude Include="PyAcadApplicationImpl.h" />
<ClInclude Include="PyAcadDatabase.h" />
<ClInclude Include="PyAcadDatabaseImpl.h" />
<ClInclude Include="PyBrEntity.h" />
<ClInclude Include="PyBrTraverser.h" />
<ClInclude Include="PyDb3dProfile.h" />
Expand Down
16 changes: 8 additions & 8 deletions PyRxCore/PyRx24.1.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -388,16 +388,16 @@
<ClCompile Include="PyAcAx.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxApplication.cpp">
<ClCompile Include="PyAcadApplication.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxDatabase.cpp">
<ClCompile Include="PyAcadDatabase.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxApplicationImpl.cpp">
<ClCompile Include="PyAcadApplicationImpl.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
<ClCompile Include="PyAxDatabaseImpl.cpp">
<ClCompile Include="PyAcadDatabaseImpl.cpp">
<Filter>Source Files\PyAx</Filter>
</ClCompile>
</ItemGroup>
Expand Down Expand Up @@ -789,16 +789,16 @@
<ClInclude Include="PyAcAx.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxApplication.h">
<ClInclude Include="PyAcadApplication.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxDatabase.h">
<ClInclude Include="PyAcadDatabase.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxApplicationImpl.h">
<ClInclude Include="PyAcadApplicationImpl.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
<ClInclude Include="PyAxDatabaseImpl.h">
<ClInclude Include="PyAcadDatabaseImpl.h">
<Filter>Header Files\PyAx</Filter>
</ClInclude>
</ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions PyRxCore/PyRx24.2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
<ClCompile Include="PlCore.cpp" />
<ClCompile Include="PyAcAx.cpp" />
<ClCompile Include="PyAcBr.cpp" />
<ClCompile Include="PyAxApplication.cpp" />
<ClCompile Include="PyAxApplicationImpl.cpp" />
<ClCompile Include="PyAxDatabase.cpp" />
<ClCompile Include="PyAxDatabaseImpl.cpp" />
<ClCompile Include="PyAcadApplication.cpp" />
<ClCompile Include="PyAcadApplicationImpl.cpp" />
<ClCompile Include="PyAcadDatabase.cpp" />
<ClCompile Include="PyAcadDatabaseImpl.cpp" />
<ClCompile Include="PyBrEntity.cpp" />
<ClCompile Include="PyBrTraverser.cpp" />
<ClCompile Include="PyDb3dProfile.cpp" />
Expand Down Expand Up @@ -277,10 +277,10 @@
<ClInclude Include="PlCore.h" />
<ClInclude Include="PyAcAx.h" />
<ClInclude Include="PyAcBr.h" />
<ClInclude Include="PyAxApplication.h" />
<ClInclude Include="PyAxApplicationImpl.h" />
<ClInclude Include="PyAxDatabase.h" />
<ClInclude Include="PyAxDatabaseImpl.h" />
<ClInclude Include="PyAcadApplication.h" />
<ClInclude Include="PyAcadApplicationImpl.h" />
<ClInclude Include="PyAcadDatabase.h" />
<ClInclude Include="PyAcadDatabaseImpl.h" />
<ClInclude Include="PyBrEntity.h" />
<ClInclude Include="PyBrTraverser.h" />
<ClInclude Include="PyDb3dProfile.h" />
Expand Down
Loading

0 comments on commit 1c02b7e

Please sign in to comment.