Title: Win32API Callbacks (Progress, but still need Inline Stack Macro help)

The C side of the following code now works. (I'm learning)

How to use the Inline stack macros in order to have the C callback function call into Perl land does not. I.e., uncommenting the commented code under Enum_Child_Proc, results in the attached out.make.

Could someone please take a look at this and comment on it?  Even comments like RTFM would be an improvement over howling into the void...

Garrett


use Inline C => DATA => LIBS => '-luser32';

sub foo { print "Perl main::foo called from C-land with qw(@_)\n" }

set_callback("main::foo");
call_callback();

Enum_Child_Windows();

__END__
__C__

#include <stdio.h>
#include <windows.h>

static char* callback;
void set_callback(char* name) {
    callback = name;
}

void call_callback() {
    Inline_Stack_Vars;
    I32 flags = 0;

    printf("Hello from C-land\n");

    Inline_Stack_Reset;
    Inline_Stack_Push(newSVpvf("Apple"));
    Inline_Stack_Push(newSVpvf("Orange"));
    Inline_Stack_Push(newSVpvf("Neil"));
    Inline_Stack_Done;

    perl_call_method(callback, flags);
    Inline_Stack_Void;
}

BOOL FAR PASCAL Enum_Child_Proc (HWND hWnd, LPARAM Param) {
  printf("Enum_Child_Proc(hWnd: %d, Param: %d)\n", hWnd, Param);

/*
  Inline_Stack_Vars;
  I32 flags = 0;
  Inline_Stack_Reset;
  Inline_Stack_Push(newSViv(hWnd));
  Inline_Stack_Push(newSViv(Param));
  Inline_Stack_Done;
  perl_call_method(callback, flags);
*/

  return 1;
}


int Enum_Child_Windows() {
  return EnumChildWindows(NULL, *Enum_Child_Proc, 1);
}

 

out.make

Reply via email to