fbfrog header translator

User projects written in or related to FreeBASIC.
speedfixer
Posts: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: fbfrog header translator

Post by speedfixer »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Post by dkl »

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
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: fbfrog header translator

Post by paul doe »

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: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: fbfrog header translator

Post by speedfixer »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Post by dkl »

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

Re: fbfrog header translator

Post by speedfixer »

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: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Post by dkl »

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: 606
Joined: Nov 28, 2012 1:27
Location: CA, USA moving to WA, USA
Contact:

Re: fbfrog header translator

Post by speedfixer »

Thank you.

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

Re: fbfrog header translator

Post by Iczer »

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
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: fbfrog header translator

Post by fxm »

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

Re: fbfrog header translator

Post by srvaldez »

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

Re: fbfrog header translator

Post by Iczer »

Thanks!
demosthenesk
Posts: 237
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: fbfrog header translator

Post by demosthenesk »

does fbfrog translate C++ headers ?
can i use it to translate Qt6 ?
dkl
Site Admin
Posts: 3235
Joined: Jul 28, 2005 14:45
Location: Germany

Re: fbfrog header translator

Post by dkl »

Probably not, unfortunately. fbfrog has almost no C++ support. I'm not even sure whether FB itself has enough C++ support to be compatible to Qt or even the C++ standard library (lack of templates and multiple inheritance...).
demosthenesk
Posts: 237
Joined: Jul 15, 2021 7:23
Location: Greece
Contact:

Re: fbfrog header translator

Post by demosthenesk »

dkl wrote: Aug 16, 2023 21:57 Probably not, unfortunately. fbfrog has almost no C++ support. I'm not even sure whether FB itself has enough C++ support to be compatible to Qt or even the C++ standard library (lack of templates and multiple inheritance...).
Thanks dkl for your reply...
Post Reply