Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Pascal Bindings - c struct return issues  (Read 1564 times)

0 Members and 1 Guest are viewing this topic.

tinyBigGAMES

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • tinyBig GAMES - Play.BIG
    • Email
Pascal Bindings - c struct return issues
« on: July 05, 2014, 05:49:10 pm »
I'm currently working on bindings for Pascal. I have it workings somewhat. The one remaining issue (hopfully) is with the way Delphi handles struct function results. I noticed routines that directly returned a c struct would not work on the Delphi side. After struggling with this for a good day, I came across this article:

http://rvelthuis.de/articles/articles-convert.html (go down to the return type section)

That works, but at least in the latest delphi versions (I'm using XE6) it will not let me typecast the Int64 type... to any structure other than one that just so happens to be the same size as an Int64. So using the method described, I am able to get results from sfVectorXXX routines for example. But any other structure when I typecast I get an invalid type cast error.

Does anyone have an idea of to solve this? The only thing that I know to do is the change the function signatures to not return a struct type, but be able to pass a pointer to the struct and that get updated. This will allow great compatibility with other languages.
Jarrod Davis
Owner/Technical Director @ tinyBig GAMES
FaceBook | Twitter | YouTube

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Pascal Bindings - c struct return issues
« Reply #1 on: July 05, 2014, 06:20:11 pm »
Quote
Does anyone have an idea of to solve this?

It would be way better for you to ask on a forum dedicated to Pascal as this is an issue related to that language and not to SFML.

Quote
The only thing that I know to do is the change the function signatures to not return a struct type, but be able to pass a pointer to the struct and that get updated.

And that would defeat the entire purpose of using a struct in the first place.

Quote
This will allow great compatibility with other languages.

And break compatibility with all existing bindings...
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

tinyBigGAMES

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • tinyBig GAMES - Play.BIG
    • Email
Re: Pascal Bindings - c struct return issues
« Reply #2 on: July 05, 2014, 06:47:28 pm »
Hi,

Yes, I have asked in the Pascal related forum. Just covering all bases. I made a build of csfml already for this project. I was just checking to make sure there was no other way. All I was suggesting was that if you add a pointer to the end of the param ref then for those languages that have issues such as Delphi it should then be able to work:

sfContextSettings sfWindow_getSettings(const sfWindow* window);delphi

vs.

sfContextSettings sfWindow_getSettings(const sfWindow* window, sfContextSettings *settings_);

The 2nd should work and not break compatibility. Is all I am saying.

I am just trying to get this to work in Delphi. There are no binding that I know of, so trying to make some and these are the issues I am running into.

Jarrod Davis
Owner/Technical Director @ tinyBig GAMES
FaceBook | Twitter | YouTube

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Pascal Bindings - c struct return issues
« Reply #3 on: July 05, 2014, 06:55:40 pm »
If all you need is a CSFML that doesn't use structs, then you could take a look at the modifications Jebbs has made to CSFML for the D binding. Basically it uses pointers like you want without requiring the use of structs.

https://github.com/Jebbs/DSFML-C
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

tinyBigGAMES

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • tinyBig GAMES - Play.BIG
    • Email
Re: Pascal Bindings - c struct return issues
« Reply #4 on: July 05, 2014, 07:01:41 pm »
Ahhh.... sweet. Thanks bro.  8)
Jarrod Davis
Owner/Technical Director @ tinyBig GAMES
FaceBook | Twitter | YouTube