Skip to content

Commit

Permalink
Switch back to pybind11 in setup.py before merge to dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Aug 7, 2024
1 parent 7bbce1e commit 76982ff
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def build_extension(self, ext):
print("extdir = " + extdir)
print("sourcedir" + ext.sourcedir)

#cmake_args = ['cmake', f'-DPYTHON_EXECUTABLE:FILEPATH={pyexec}']
cmake_args = ['cmake', f'-DPYTHON_EXECUTABLE:FILEPATH={pyexec}', f'-DPYTHON_BINDING_LIB=NANOBIND']
cmake_args = ['cmake', f'-DPYTHON_EXECUTABLE:FILEPATH={pyexec}']
#cmake_args = ['cmake', f'-DPYTHON_EXECUTABLE:FILEPATH={pyexec}', f'-DPYTHON_BINDING_LIB=NANOBIND']

cfg = 'Debug' if self.debug else 'Release'
build_args = ['--config', cfg]
Expand Down
23 changes: 23 additions & 0 deletions src/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ BND_TUPLE NullTuple()
#endif
}

BND_LIST CreateList()
{
#if defined(ON_PYTHON_COMPILE)
BND_LIST rc = py::list();
#else
emscripten::val rc(emscripten::val::array());
#endif
return rc;
}

BND_LIST NullList()
{
#if defined(ON_PYTHON_COMPILE)
#if defined(NANOBIND)
return py::list();
#else
return py::none();
#endif
#else
return emscripten::val::null();
#endif
}

BND_DateTime CreateDateTime(struct tm t)
{
#if defined(ON_PYTHON_COMPILE)
Expand Down
23 changes: 23 additions & 0 deletions src/bindings/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ void SetTuple(BND_TUPLE& tuple, int index, const T& value)
#endif
}

BND_LIST CreateList(int count);
BND_LIST NullList();
template<typename T>
void Insert(BND_LIST& list, int index, const T& value)
{
#if defined(ON_PYTHON_COMPILE)
list.insert(index, value);
#else
list.set(index, value);
#endif
}

template<typename T>
void Append(BND_LIST& list, const T& value)
{
#if defined(ON_PYTHON_COMPILE)
list.append(value);
#else
const int count = list["length"].as<int>();
list.set(count++, value);
#endif
}

BND_DateTime CreateDateTime(struct tm t);

#include "bnd_color.h"
Expand Down
23 changes: 23 additions & 0 deletions src/dotnet/opennurbs/opennurbs_viewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@ internal override IntPtr _InternalDuplicate(out bool applymempressure)
return UnsafeNativeMethods.ON_Viewport_New(const_ptr_this);
}

/// <summary>
/// If the viewport has a parent ViewInfo, return a NonConstPtr to the viewport.
/// </summary>
/// <returns>IntPtr</returns>
/// <since>8.10</since>
internal override IntPtr NonConstPointer()
{
if(m_parent != null && !IsNonConst)
{
var vi = m_parent as ViewInfo;
if (vi != null)
{
IntPtr pView = vi.NonConstPointer();
IntPtr v = UnsafeNativeMethods.ON_3dmView_ViewportPointer(pView);
if (v != IntPtr.Zero)
{
return v;
}
}
}
return base.NonConstPointer();
}

/// <summary>
/// Initializes a new instance.
/// </summary>
Expand Down

0 comments on commit 76982ff

Please sign in to comment.