-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] - Create MemoryBuffer from byte array #196
Comments
Indeed, it looks like the Bindings configuration for the interop layer doesn't have the mapping for that function. (For reasons not yet known the code that is supposed to catch theses sorts of things in LlvmBindingsGenerator, isn't catching this case...) |
While the bindings for that LLVM function are indeed incorrect (Working on a fix for that) I'm confused on the scenario you are trying to accomplish here. You can use BitCodeModule.LoadFrom to load a memory buffer into a bitcode module, and you can use BitCodeModule.WriteToBuffer to write an existing module into a buffer. So I'm confused on what scenarios you'd have an arbitrary blob of memory (as a byte[]) for a bit code module that wasn't read from a file? Where would you get the byte[] from if not reading it from a file? |
Resolves UbiquityDotNET#196 --- * Added new constructor to Memory Buffer * Added new tests for the new MemoryBuffer constructor * Updated YamalArrayMarshalInfo.TransformType to convert simpler types to signed/unsigned bytes (and bools) based on marshaling attribute * Added debug messages for detection of char* without any marshaling information. (Most are fine with default treatment as string, however this allows finding others more easily then searching headers) * Added use of CommandLineParser library to bindings generator to provide standard usage help and allow for optional params (including new diagnostics level so it is an actual parameter now) * Added suppression of CS rule/suggestion to "simplify" and in statement to a multi level conditional expression. The result is anything but simpler. * Converted some checks in BitCodeModule to use conditional and throw expressions
Resolves #196 --- * Added new constructor to Memory Buffer * Added new tests for the new MemoryBuffer constructor * Updated YamalArrayMarshalInfo.TransformType to convert simpler types to signed/unsigned bytes (and bools) based on marshaling attribute * Added debug messages for detection of char* without any marshaling information. (Most are fine with default treatment as string, however this allows finding others more easily then searching headers) * Added use of CommandLineParser library to bindings generator to provide standard usage help and allow for optional params (including new diagnostics level so it is an actual parameter now) * Added suppression of CS rule/suggestion to "simplify" and in statement to a multi level conditional expression. The result is anything but simpler. * Converted some checks in BitCodeModule to use conditional and throw expressions
Is your feature request related to a problem? Please describe.
The only way to create a BitcodeModule from memory appears to be to write the memory to a file, create a MemoryBuffer from a file, and then load the BitcodeModule from the newly created MemoryBuffer. Ideally the memory could be fed directly to the MemoryBuffer.
Describe the solution you'd like
A new constructor added to MemoryBuffer that takes a byte array (
byte[]
) and a buffer name (string
) and internally callsLLVMCreateMemoryBufferWithMemoryRangeCopy
Describe alternatives you've considered
Writing data to a file and then loading from a file.
Additional context
The signature for LLVMCreateMemoryBufferWithMemoryRangeCopy doesn't seem right, I would have expected either a byte array or a pointer, not a string for raw data.
The text was updated successfully, but these errors were encountered: