Skip to content

Commit b3d4483

Browse files
committed
Update Cpp::Destruct to return success/failure
1 parent 9c94230 commit b3d4483

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

include/CppInterOp/CppInterOp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ CPPINTEROP_API TCppObject_t Construct(TCppScope_t scope, void* arena = nullptr,
865865
/// destructor
866866
/// \param[in] count indicate the number of objects to destruct, if \c This
867867
/// points to an array of objects
868-
CPPINTEROP_API void Destruct(TCppObject_t This, TCppScope_t type,
868+
/// \returns true if wrapper generation and invocation succeeded.
869+
CPPINTEROP_API bool Destruct(TCppObject_t This, TCppScope_t type,
869870
bool withFree = true, TCppIndex_t count = 0UL);
870871

871872
/// @name Stream Redirection

lib/CppInterOp/CppInterOp.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,19 +3812,20 @@ TCppObject_t Construct(TCppScope_t scope, void* arena /*=nullptr*/,
38123812
return Construct(getInterp(), scope, arena, count);
38133813
}
38143814

3815-
void Destruct(compat::Interpreter& interp, TCppObject_t This, Decl* Class,
3815+
bool Destruct(compat::Interpreter& interp, TCppObject_t This, Decl* Class,
38163816
bool withFree, TCppIndex_t nary) {
38173817
if (auto wrapper = make_dtor_wrapper(interp, Class)) {
38183818
(*wrapper)(This, nary, withFree);
3819-
return;
3819+
return true;
38203820
}
3821-
// FIXME: Diagnose.
3821+
return false;
3822+
// FIXME: Enable stronger diagnostics
38223823
}
38233824

3824-
void Destruct(TCppObject_t This, TCppScope_t scope, bool withFree /*=true*/,
3825+
bool Destruct(TCppObject_t This, TCppScope_t scope, bool withFree /*=true*/,
38253826
TCppIndex_t count /*=0UL*/) {
38263827
auto* Class = static_cast<Decl*>(scope);
3827-
Destruct(getInterp(), This, Class, withFree, count);
3828+
return Destruct(getInterp(), This, Class, withFree, count);
38283829
}
38293830

38303831
class StreamCaptureInfo {

0 commit comments

Comments
 (0)