code icon indicating copy to clipboard operation
code copied to clipboard

FEAT: libRed Red/System binding

Open Oldes opened this issue 6 years ago • 8 comments

Made this just as a curiosity although I think it may be quite useful... currently I have 2 issues:

  1. once redOpen is called, the output from print functions from hosting R/S app stops.
  2. it is not possible to define redRoutine from R/S function

Oldes avatar Sep 07 '17 21:09 Oldes

  1. That's expected, because they share the same underlying R/S runtime code.
  2. Try using a [cdecl] in the R/S function passed to redRoutine.

dockimbel avatar Sep 08 '17 07:09 dockimbel

  1. it is not good... it would make difficult to use libRed loaded in app made in Red/System... isn't there some workaround? I would prefer to have print from the host then the lib, if I could choose.

  2. there is more problems... first... it is not allowed to cast function into int-ptr!, but I used intermediate casting which seems to make compiler satisfied. Unfortunately, although the routine is called now, there are strange values coming into it, so the result is wrong... what may be a reason?

Oldes avatar Sep 08 '17 09:09 Oldes

Btw... I have libRed.dll made with rc "build libred" - The stdcall version is completely wrong. With cdecl only the routine input is strange.

Oldes avatar Sep 08 '17 09:09 Oldes

@dockimbel the redRoutine is working now as expected with the fix: https://github.com/red/red/commit/67cebfc50f30ab2caad3e057a51b96203ac864e2

Oldes avatar Oct 10 '17 14:10 Oldes

Can someone confirm that this works? If so, I'll get it merged.

greggirwin avatar Jan 04 '19 20:01 greggirwin

@9214 or @hiiamboris, can you confirm this PR is OK to merge?

greggirwin avatar Apr 26 '20 18:04 greggirwin

@Oldes nice experiment! My 2 cents:

  • Personally I would remove enums, since they are not used in the code and at least RedType! is outdated; the other way around is to update it, but then it needs to stay in sync with other eventual changes.
  • I like all the #defines and how they convey the intention, but IMO they should use - rather than _, to follow the naming conventions. That shouldn't cause any name clashing AFAIK, though I can be wrong.
  • Unfortunately I can't help you with the testing on macOS and GTK, perhaps someone else can spin up VMs and do some quick checking?

9214 avatar Dec 06 '20 13:12 9214

works (except for printf) on all platforms

hiiamboris avatar Dec 06 '20 14:12 hiiamboris