Skip to content
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: Deffer call #11

Open
KES777 opened this issue Dec 24, 2020 · 2 comments
Open

Feature: Deffer call #11

KES777 opened this issue Dec 24, 2020 · 2 comments

Comments

@KES777
Copy link

KES777 commented Dec 24, 2020

@@ -30,6 +30,9 @@ sub ffi_custom_type_api_1
   foreach my $value (@values)
   {
     my $name;
+    if( ref $value eq 'CODE' ) {
+      $value =  $value->();
+    }
     if(is_plain_arrayref $value)
     {
       ($name,$index) = @$value;

Notice: this is for 0.03 version

I thought I already ask this, but probably not.

In case of SDL there situation when values are circular definition. And we need deffer

SDL_PIXELFORMAT_RGBA8888

https://github.com/KES777/sdl/blob/master/lib/SDL2/Pixels.pm#L501

@jjatria
Copy link
Contributor

jjatria commented Jun 23, 2021

An alternative solution would be to be able to extend an enum type. This would allow you to make the initial definitions in one BEGIN block, and any that used the earlier ones in a separate one, where those constants would already exist (incidentally, this is pretty much what constant recommends).

I use a similar solution in my own library: https://github.com/jjatria/perl-sdl2-raw/blob/master/lib/SDL2/Raw.pm#L1022, although in that case I'm defining the enums myself in part because of this limitation.

@plicease
Copy link
Member

plicease commented Jun 23, 2021

This was discussed in #4 and #6.

sanko added a commit to sanko/FFI-Platypus-Type-Enum that referenced this issue Aug 24, 2021
 Issues:
 - Cannot cast value back to name (for return values from C, etc.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants