-
Notifications
You must be signed in to change notification settings - Fork 39
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
[UNIFEX] Allow addition to the make_env sandbox imports #907
Comments
Hello @FatigueDev ! |
In this hypothetical, being able to include The only thing that is of great importance is the ability to include predefined types; I understand the worry in regards to stamping everything out of a module definition, however it is up to the user to define what is included. They can omit it, if they so choose; or create a module that returns a function to automatically generate module tags, or types, or perform some sort of file IO skimming to spit out new spec.exs files based on text in a given header file. That's all hypothetical, but the idea is there. Breaking it down into it's components, there's a couple of things that could be done to prevent the need for a DefaultSpec situation. There could be a MIX environment variable to match on if we should always require a defined callback. The behaviour being it makes sure to add it to the generated output and if it's not defined, it'll error at compile-time which is a good indicator you're missing the function definition. I think that state_type, at least in my (again) extremely specific use case is a stand in for the lack of support for void* in specs. Perhaps it could require an elixir I'm rambling on, which I love to do, but one last thing I would enjoy is simply being able to append my own module to the sandbox. It could let me, depending on compile-time flags, enable or disable the exposure of functions based on the target platform. I can probably actually already do that, but it'd be neat if I could wrap it up in a nice module I can just hand to a |
Hello! I got your point, thanks for describing. I'm not sure when our team will have the capacity to address that issue, as we are currently focused on some other priorities. |
I'll fork and give it a squizz, if I come up with anything of note I'll stop back in to comment. Because I've noticed that when you use the
module(MyTypes)
interface([NIF, CNode])
type image :: %SomeModule.Image{x: int, y: int}
# No specs
module(MyMainProject)
# This will default to using `image` as a default instead of `struct`.
spec do_thing(my_image :: image) :: :ok I think it may be a case of just adding another type called 'implicit' which just stamps a # Just pretend image exists for the spec.
type image :: implicit
# image is defined, but not initialized; that's handled elsewhere :)
spec get_image() :: image The only thing that is stamped in is the struct definition which would be fine if we were using it in this spec, but we don't plan to. Of course, Project1 has it's own bundlex config just to spit it out. When we hand it to Project2 using the Unifex preprocessor, it may consider deps and it redefines core functions like |
Thanks, that would be great! Concerning the types redefinition, your proposed solution with |
The blocker I ran into here specifically is that each Fixing this would require a spec-time function call which would I think there just has to be more control in the exclude_generation_for([
:main,
:type_definitions,
:function_definitions,
:unifex,
:shmex,
:state_functions,
:all_the_other_stuff_i_forgot
]) Where during the Common, NIF and CNode Generators it just has a simple if excludes_generation?(from_exclude_generation_for_list), do: # what was already there #
Makes me wish there was a return function in a lot of ways, but overall I think it's just.. Nah. I can't get it to compile and I spent two days on just this one problem with a lot of different ways. A |
In Unifex, when you create a spec.exs file you are unable to load compiled modules. While in normal use-cases this is fine, because you're building the module yourself with only a couple of type definitions or function specs. However, when you start writing a NIF with a lot of requirements / type definitions, you run into the issue of extreme bloat and workarounds.
Take for example Raylib. It has a litany of required structs which are required to define function specs, so the best way to go about it would be to create a "Raylib.Types.ex" file which imports Unifex.Specs.DSL and calling
Raylib.Types.get_types(__unifex_config)
which just adds a metric tonne of type definitions, or common function specs.exVector2, exVector3, exMatrix, exAudio, exAudioThing1, exAudioThing2- About a hundred.
Currently this is not allowed and you need to
However it would be a lot better if we could do something akin to the following instead
exray.shared.defaultspec.ex
exray.shared.defaulttypes.ex
shared.spec.exs
What would be even better than simply having a 'stamp' function is that if modules that import a certain Unifex.Specs.Shared module are actually compiled separately and are
#include
'd into files generated by the specfile, because as it stands now using this method to import the types based off of a Code.require_file call actually flags the code generator to not define the types in the C++, or give us any option to enable it. This leads to being forced to stamp in the same types over and over, repeating ourselves and doing our best to guard our headers when we are nest-requiring different modules with different levels of "I need Vector", then "I need Image, which has Vector" then in the worst case, Fonts which have glyphs which have rects, vectors, colors and images- Which in turn have textures which holdstate
.So in essence, if there can be a way to create Shared file of some kind, or lacking that being able to easily stamp from compiled .EX files I'd be very grateful; because right now I need to download Raylib for each compartmentalized module, define every type and at it leaves the load time extremely lackluster due to the amount that needs to be compiled, when it should be compiled once and included in existing specs.
You can refer to Exray for my implementation; the structure of c_src should make a lot of sense when you realize that every sub-directory is actually just a 'piece' of the Raylib.h file, cut apart for a good dev experience.
https://github.com/FatigueDev/exray
The text was updated successfully, but these errors were encountered: