fbfrog header translator

User projects written in or related to FreeBASIC.
speedfixer
Posts: 413
Joined: Nov 28, 2012 1:27
Location: California

Re: fbfrog header translator

Postby speedfixer » Apr 07, 2019 7:04

Did the second branch get far enough along to be useful? (60 commits ahead/4 commits behind master - philosophical shift?)
Were there features that would/should be rolled into the master?

An immediate project of mine is using the Raspberry PI for several modest tasks in a much larger network and I want to write more directly to the core of the system in places. FB so far has been excellent for this, but there are so many base libraries to address.

I'm still learning fbfrog (so I can avoid learning more C). Zero interest in Python.

david
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Postby dkl » Apr 09, 2019 18:37

No, it's unfinished, so not really useful. It's a mix of two ideas -
1) using libclang in fbfrog instead of a custom parser. Good, except it can't parse #define bodies, so it still needs some custom parsing for that.
2) making a "just-in-time bindgen" (for 1 target only instead of all targets). There is some better code at https://github.com/dkl/fbc/compare/master...dkl:bindgen for this approach. See also viewtopic.php?f=8&t=26175
paul doe
Posts: 1269
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: fbfrog header translator

Postby paul doe » Apr 09, 2019 20:14

dkl wrote:No, it's unfinished, so not really useful. It's a mix of two ideas - ...

Mmm? I beg to differ. The amount of work it can save me is substantial and, very frequently, it only leaves me with trivial stuff to deal with. Makes porting some stuff a breeze. Thank you so much for this little 'useless' tool ;)
speedfixer
Posts: 413
Joined: Nov 28, 2012 1:27
Location: California

Re: fbfrog header translator

Postby speedfixer » Apr 17, 2019 8:00

Is there a provision to comment a line in the '*.fbfrog' or '*.options' file?

This would be helpful.
One favorite option file can be copied across many translates with 'touchups' for specific files without having to search down that one single file that had the exception you need again.

david
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Postby dkl » Apr 18, 2019 18:56

Yea it allows # comments. The *.fbfrog files can also include others recursively, which can be useful to extract and reuse common parts.
speedfixer
Posts: 413
Joined: Nov 28, 2012 1:27
Location: California

Re: fbfrog header translator

Postby speedfixer » Apr 18, 2019 19:08

Thanks.

Are you pretty much done with this?

I'm working on rPI stuff right now.
Translates aren't too hard; I get them to work without that much difficulty.

I would have sets of questions and more if you were to be active on this.

If not, it certainly works well enough to save so much time. (With fbc so fast, trial and error makes everything so simple.)
Thank you for this program!


One question:
How should one deal with an FB reserved keyword defined in another library?

At the moment, the word is shell.


david
dkl
Site Admin
Posts: 3212
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Postby dkl » Apr 18, 2019 19:49

Yea go ahead, if I can help out a bit that's fine for me. I got no plans to make any big improvements though.

For symbol naming conflicts usually the solution is to do something like declare function shell_ alias "shell" .... There is an fbfrog option for that, -rename_ shell, or -renameproc shell foo if you prefer another name than shell_.
speedfixer
Posts: 413
Joined: Nov 28, 2012 1:27
Location: California

Re: fbfrog header translator

Postby speedfixer » Apr 18, 2019 22:02

Thank you.

No more for now.
Iczer
Posts: 60
Joined: Jul 04, 2017 18:09

Re: fbfrog header translator

Postby Iczer » Aug 20, 2020 13:11

I'm trying to make zstd.bi - new compression algorithm for curl - but translated header gives error:
...\FreeBASIC-1.07.1-win64\inc\zstd.bi(39) error 14: Expected identifier, found '(' in 'declare function ZSTD_compressBound(byval srcSize as uinteger) as uinteger'

Code: Select all

/*======  Helper functions  ======*/
#define ZSTD_COMPRESSBOUND(srcSize)   ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0))  /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */
ZSTDLIB_API size_t      ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */
ZSTDLIB_API unsigned    ZSTD_isError(size_t code);          /*!< tells if a `size_t` function result is an error code */
ZSTDLIB_API const char* ZSTD_getErrorName(size_t code);     /*!< provides readable string from an error code */
ZSTDLIB_API int         ZSTD_minCLevel(void);               /*!< minimum negative compression level allowed */
ZSTDLIB_API int         ZSTD_maxCLevel(void);               /*!< maximum compression level available */

translates to:

Code: Select all

#define ZSTD_COMPRESSBOUND(srcSize) (((srcSize) + ((srcSize) shr 8)) + iif((srcSize) < (128 shl 10), ((128 shl 10) - (srcSize)) shr 11, 0))
declare function ZSTD_compressBound(byval srcSize as uinteger) as uinteger
declare function ZSTD_isError(byval code as uinteger) as ulong
declare function ZSTD_getErrorName(byval code as uinteger) as const zstring ptr
declare function ZSTD_minCLevel() as long
declare function ZSTD_maxCLevel() as long


so - what right way to do it?
fxm
Posts: 9947
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: fbfrog header translator

Postby fxm » Aug 20, 2020 13:25

FreeBASIC language is non case sensitive, so 'ZSTD_COMPRESSBOUND' and 'ZSTD_compressBound' are the same symbol for it.
srvaldez
Posts: 2513
Joined: Sep 25, 2005 21:54

Re: fbfrog header translator

Postby srvaldez » Aug 20, 2020 13:51

just rename #define ZSTD_COMPRESSBOUND(srcSize) to something like #define ZSTD_COMPRESSBOUND_(srcSize)
Iczer
Posts: 60
Joined: Jul 04, 2017 18:09

Re: fbfrog header translator

Postby Iczer » Aug 20, 2020 14:06

Thanks!

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 4 guests