Skip to content

Commit

Permalink
c++ bindings: fix all pointer parameters being effectively optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cfillion committed May 13, 2024
1 parent e1976f4 commit c494c79
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/genbinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,16 @@ namespace ImGui {
struct nullopt_t {
constexpr explicit nullopt_t(int) {}
operator std::nullptr_t() const { return nullptr; }
};
constexpr details::nullopt_t nullopt { 0 };
constexpr nullopt_t nullopt { 0 };
template<typename T, typename E = void>
class optional {
public:
using value_type = T*;
optional(nullopt_t) : m_present { false } {}
optional(const T v) : m_value { v }, m_present { true } {}
optional(value_type) = delete;
operator value_type() { return m_present ? &m_value : nullptr; }
private:
Expand Down Expand Up @@ -396,9 +396,9 @@ namespace ImGui {
stream << "details::function<" << func.type << '(';
CommaSep cs { stream };
for(const Argument &arg : func.args) {
if(arg.isOptional() && !arg.isOutput()) {
if(arg.isOptional()) {
cs << "details::optional<";
if(arg.type.isScalarPtr())
if(!arg.isOutput() && arg.type.isScalarPtr())
stream << arg.type.removePtr();
else
stream << arg.type;
Expand Down

0 comments on commit c494c79

Please sign in to comment.