Skip to content

Commit

Permalink
Merge pull request GaijinEntertainment#657 from otakubeam/bind-smart-…
Browse files Browse the repository at this point in the history
…ptr-is-valid

Bind smart_ptr_is_valid function
  • Loading branch information
borisbat authored Jul 3, 2023
2 parents 79c7beb + cee1e15 commit 693c495
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/builtin/module_builtin_runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,12 @@ namespace das
}
}

__forceinline bool smart_ptr_is_valid (const smart_ptr_raw<void> dest, Context * context, LineInfoArg * at ) {
if (!dest.get()) return true;
ptr_ref_count * t = (ptr_ref_count *) dest.get();
return t->is_valid();
}

__forceinline void validate_smart_ptr ( void * ptr, Context * context, LineInfoArg * at ) {
if ( !ptr ) return;
ptr_ref_count * t = (ptr_ref_count *) ptr;
Expand Down Expand Up @@ -1599,6 +1605,9 @@ namespace das
addExtern<DAS_BIND_FUN(builtin_smart_ptr_use_count)>(*this, lib, "smart_ptr_use_count",
SideEffects::none, "builtin_smart_ptr_use_count")
->args({"ptr","context","at"});
addExtern<DAS_BIND_FUN(smart_ptr_is_valid)>(*this, lib, "smart_ptr_is_valid",
SideEffects::none, "smart_ptr_is_valid")
->args({"dest","context","at"});
addExtern<DAS_BIND_FUN(equ_sptr_sptr)>(*this, lib, "==", SideEffects::none, "equ_sptr_sptr");
addExtern<DAS_BIND_FUN(nequ_sptr_sptr)>(*this, lib, "!=", SideEffects::none, "nequ_sptr_sptr");
addExtern<DAS_BIND_FUN(equ_ptr_sptr)>(*this, lib, "==", SideEffects::none, "equ_ptr_sptr");
Expand Down

0 comments on commit 693c495

Please sign in to comment.