Optional filter to LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess
Hi! Thank you for this awesome Rust crate. If you could give me pointers what would be best to modify this crate, I can also make this change.
So, the LLVMOrcSymbolPredicate Filter is optional. And I have already asked from the Rust users Discord channel, and seems there is no way to pass empty function pointer. So in order to make this Filter optional we should have:
Filter: LLVMOrcSymbolPredicate ---> Filter: Option<LLVMOrcSymbolPredicate>
Full function definition:
pub unsafe extern "C" fn LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(
Result: *mut LLVMOrcJITDylibDefinitionGeneratorRef,
GlobalPrefix: c_char,
Filter: Option<LLVMOrcSymbolPredicate>,
FilterCtx: *mut c_void
) -> LLVMErrorRef
So that we can pass None filter function. How it would be best to make this change to this crate?
This is the C code for LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess that shows the Filter is optional:
LLVMErrorRef LLVMOrcCreateDynamicLibrarySearchGeneratorForProcess(
LLVMOrcDefinitionGeneratorRef *Result, char GlobalPrefix,
LLVMOrcSymbolPredicate Filter, void *FilterCtx) {
assert(Result && "Result can not be null");
assert((Filter || !FilterCtx) &&
"if Filter is null then FilterCtx must also be null");
DynamicLibrarySearchGenerator::SymbolPredicate Pred;
if (Filter)
Pred = [=](const SymbolStringPtr &Name) -> bool {
return Filter(FilterCtx, wrap(OrcV2CAPIHelper::getRawPoolEntryPtr(Name)));
};
Edited by Tommi Pisto