Skip to content

[API] Add FFI wrapper modifier to strong typedefs - #8386

Merged
emesare merged 1 commit into
devfrom
similarity/support-ffi-wrapper
Aug 5, 2026
Merged

[API] Add FFI wrapper modifier to strong typedefs#8386
emesare merged 1 commit into
devfrom
similarity/support-ffi-wrapper

Conversation

@emesare

@emesare emesare commented Aug 4, 2026

Copy link
Copy Markdown
Member

Apart of https://github.com/Vector35/binaryninja/pull/1735 (Binary Similarity)
For a test_* build with this change see the above branch ^

This modifier is used for wrapping and unwrapping FFI structures representing the raw value type.

In particular we are using it in the binary similarity like:

namespace BinaryNinjaCore {
	namespace st = ::bn::base::strong_typedef;
	using SimilarityEntityId = ::bn::base::StrongTypedef<uint32_t, struct SimilarityEntityIdTag,
		st::FfiWrapper<BNSimilarityEntityId, &BNSimilarityEntityId::value>, st::Ordered, st::Hashable,
		st::Incrementable>;
}  // namespace BinaryNinjaCore

Where we want to use the strong_typedef modifiers to derive functionality for use in containers (hashable, ordered) and still preserve the relationship between the C++ and C (via FfiWrapper).

Also see https://github.com/Vector35/binaryninja/pull/1737 for unit tests.

@bdash bdash left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea, but there are a couple of changes that would help this fit better with our existing C++ <-> C API conversions.

Comment thread base/strong_typedef.h Outdated
Comment thread base/strong_typedef.h Outdated
Comment thread base/strong_typedef.h Outdated
@emesare

emesare commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Ah yes, the initializer change really does improve the usability, made the requested changes, thanks!

@emesare
emesare force-pushed the similarity/support-ffi-wrapper branch from 4b509c7 to 4b0bf92 Compare August 5, 2026 02:58
@emesare
emesare force-pushed the similarity/support-ffi-wrapper branch from 4b0bf92 to 8f99c77 Compare August 5, 2026 02:58
@emesare
emesare merged commit 8f99c77 into dev Aug 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants