dylan-hackers / mindy

Mindy - minimal compiler-interpreter for Dylan
Other
21 stars 9 forks source link

Initialize c-function's result_types to list of obj_ObjectClass. #78

Closed phongphan closed 8 years ago

phongphan commented 8 years ago

Hello,

I found this while trying to create a wrapper. Not sure it's valid. The result_types seems to expected a list. It crashes when calling convert_c_object.

snippet:

  load-object-file(list("test.dll"));
  let just_print = find-c-function("just_print");
  just_print();
  values();

test.c:

__declspec(dllexport)
void just_print()
{
    printf("print\n");
}

compiler: mingw64 on Windows 7

waywardmonkeys commented 8 years ago

This does indeed look correct to me. I think most of the time, there's another function that people call along with find-c-function that sets up types and perhaps that's why this wasn't noticed?

Thanks!

phongphan commented 8 years ago

Thanks!

Yes, calling constrain-c-function does fixed the issue too (at least this case). I think maybe they call it along with find-c-function all the time. Or maybe the binding generators did it for them.

waywardmonkeys commented 8 years ago

The binding generator does indeed do that!

kaveman- commented 8 years ago

aside: what is the binding generator that you are talking about? is there a working version of melange that generates mindy specific code ?

waywardmonkeys commented 8 years ago

The version of melange within this repository doesn't work. A lot of updates have happened since this ancient version to handle typical OS headers of today.

The working version of melange can be found in https://github.com/dylan-lang/melange/

It doesn't yet have full mindy support. I have a local patch that I had been working on that adds function bindings. I'm not sure why I didn't push it yet as it has been a while since I looked at it.