[Code] Update perlbind to 1.1.0 (#4529)

- Adds a perl::ref alias for perl::reference

- Optimizes array return pushes by accessing SV* values directly instead
  of using operator[] scalar_proxy

- Allows functions with a perl::hash parameter to accept hashes with any
  scalar key type instead of requiring explicit string keys

  e.g., foo(123 => 1) will now work on functions accepting a perl::hash
This commit is contained in:
hg 2024-11-05 21:14:29 -05:00 committed by GitHub
parent 95249889a6
commit 25ef3d2cdb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 5 deletions

View File

@ -251,4 +251,6 @@ private:
scalar m_value; scalar m_value;
}; };
using ref = reference;
} // namespace perlbind } // namespace perlbind

View File

@ -28,8 +28,8 @@ struct pusher
++m_pushed; ++m_pushed;
} }
void push(const std::string& value) { mPUSHp(value.c_str(), value.size()); ++m_pushed; } void push(const std::string& value) { mPUSHp(value.c_str(), value.size()); ++m_pushed; }
void push(scalar value) { mPUSHs(value.release()); ++m_pushed; }; void push(scalar value) { mPUSHs(value.release()); ++m_pushed; }
void push(reference value) { mPUSHs(value.release()); ++m_pushed; }; void push(reference value) { mPUSHs(value.release()); ++m_pushed; }
void push(array value) void push(array value)
{ {
@ -38,7 +38,8 @@ struct pusher
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
// mortalizes one reference to array element to avoid copying // mortalizes one reference to array element to avoid copying
PUSHs(sv_2mortal(SvREFCNT_inc(value[i].sv()))); SV** sv = av_fetch(static_cast<AV*>(value), i, true);
mPUSHs(SvREFCNT_inc(*sv));
} }
m_pushed += count; m_pushed += count;
} }

View File

@ -242,7 +242,7 @@ struct read_as<hash>
static bool check(PerlInterpreter* my_perl, int i, int ax, int items) static bool check(PerlInterpreter* my_perl, int i, int ax, int items)
{ {
int remaining = items - i; int remaining = items - i;
return remaining > 0 && remaining % 2 == 0 && SvTYPE(ST(i)) == SVt_PV; return remaining > 0 && remaining % 2 == 0 && SvTYPE(ST(i)) < SVt_PVAV;
} }
static hash get(PerlInterpreter* my_perl, int i, int ax, int items) static hash get(PerlInterpreter* my_perl, int i, int ax, int items)

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
constexpr int perlbind_version_major = 1; constexpr int perlbind_version_major = 1;
constexpr int perlbind_version_minor = 0; constexpr int perlbind_version_minor = 1;
constexpr int perlbind_version_patch = 0; constexpr int perlbind_version_patch = 0;
constexpr int perlbind_version() constexpr int perlbind_version()