Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
134 user(s) are online (99 user(s) are browsing Forums)

Members: 0
Guests: 134

more...

Support us!

Headlines

 
  Register To Post  

« 1 (2) 3 »
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@abalaban

XML might be the right format for idltool, I neither know nor care as long as I'm not running the unnecessarily complex parsing routines for it.

For what I was proposing, we only really need the C function table with args in a simple file. Something like the old FD or SFD would probably be fine, and facilitates copy'n'paste from the C headers.

Of course fdtrans means you can do this and get the XML file out the other end, so we're halfway there...

idltool doesn't quite do what we want, so the extra effort of creating XML files is time wasted - it's actually quicker to manually modify an already-working library with the new functions, than it is to jiggle the functions into XML, run idltool and then have to manually patch everything up again.

The stub library is a tedious process, and idltool doesn't help there at all (but having the functions in C format rather than XML certainly does)

Go to top
Re: Creating an AmigaOS4 library
Quite a regular
Quite a regular


See User information
@Chris

I don't understand why you are saying that IDLTool is not doing what we are wanting (BTW what do you want ? Personally it *is* doing what I want) or why you are saying it doesn't help for stub (what are you calling stub ? the glue code needed to access a 68k library from a PPC program ? the stub functions required to have a 68k vector table in a PPC library ? some some of wrapper to a .a of .so library ? something else ? ) ?

Back to a quiet home... At last
Go to top
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@abalaban

We're talking at cross purposes I think, so I'll leave it here.

idltool is perfectly fine for creating OS4 libraries, just to clear up that bit of confusion.

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
Hi

Waking up a long dormant thread! I've just finished a piece of software that builds an amiga library/interface from a set of pre-existing header and source files so you don't have to worry about generating teh XML file and filling in the stub routines and so forth. It should be on os4depot shortly and any feedback would be gratefully received.

Cheers

Billy

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information

Go to top
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@billyfish

This would have saved me so much time a few years back....

Anyway, I just tested it with libnsbmp which is very simple and in need of an update (well, my datatype that uses it is, it doesn't really need to be an external library but the current version is). It looks promising, but I get a lot of errors:

Scanning libnsbmp
 with pattern 
#?.h
Scanning libnsbmp/src
 with pattern 
#?.h
Scanning libnsbmp/src/utils
 with pattern 
#?.h
Scanning libnsbmp/include
 
with pattern #?.h
Found 2 header files
Parsing 
"libnsbmp/src/utils/log.h"
Parsing "libnsbmp/include/libnsbmp.h"
Failed to tokenize "typedef enum {         BMP_OK = 0,         BMP_INSUFFICIENT_MEMORY = 1,         BMP_INSUFFICIENT_DATA = 2,         BMP_DATA_ERROR = 3 } bmp_result;"
Failed to tokenize "typedef enum {         BMP_ENCODING_RGB = 0,         BMP_ENCODING_RLE8 = 1,         BMP_ENCODING_RLE4 = 2,         BMP_ENCODING_BITFIELDS = 3 } bmp_encoding;"
Failed to extract parameter from "*bmp_bitmap_cb_create)(int width, int height, unsigned int state);"
Failed to tokenize "typedef void* (*bmp_bitmap_cb_create)(int width, int height, unsigned int state);"
Failed to extract parameter from "*bmp_bitmap_cb_destroy)(void *bitmap);"
Failed to tokenize "typedef void (*bmp_bitmap_cb_destroy)(void *bitmap);"
Failed to extract parameter from "*bmp_bitmap_cb_get_buffer)(void *bitmap);"
Failed to tokenize "typedef unsigned char* (*bmp_bitmap_cb_get_buffer)(void *bitmap);"
Failed to extract parameter from "*bmp_bitmap_cb_get_bpp)(void *bitmap);"
Failed to tokenize "typedef size_t (*bmp_bitmap_cb_get_bpp)(void *bitmap);"
Failed to tokenize "typedef struct bmp_bitmap_callback_vt_s {                  bmp_bitmap_cb_create bitmap_create;"
Failed to tokenize "bmp_bitmap_cb_destroy bitmap_destroy;"
Failed to tokenize "bmp_bitmap_cb_get_buffer bitmap_get_buffer;"
Failed to tokenize "bmp_bitmap_cb_get_bpp bitmap_get_bpp;"
Failed to tokenize "} bmp_bitmap_callback_vt;"
Failed to tokenize "typedef struct bmp_image {                  bmp_bitmap_callback_vt bitmap_callbacks;"
Failed to tokenize "uint8_t *bmp_data;"
Failed to tokenize "uint32_t width;"
Failed to tokenize "uint32_t height;"
Failed to tokenize "bool decoded;"
Failed to tokenize "void *bitmap;"
Failed to tokenize "uint32_t buffer_size;"
Failed to tokenize "bmp_encoding encoding;"
Failed to tokenize "uint32_t bitmap_offset;"
Failed to tokenize "uint16_t bpp;"
Failed to tokenize "uint32_t colours;"
Failed to tokenize "uint32_t *colour_table;"
Failed to tokenize "bool limited_trans;"
Failed to tokenize "uint32_t trans_colour;"
Failed to tokenize "bool reversed;"
Failed to tokenize "bool ico;"
Failed to tokenize "bool opaque;"
Failed to tokenize "uint32_t mask[4];"
Failed to tokenize "int32_t shift[4];"
Failed to tokenize "uint32_t transparent_index;"
Failed to tokenize "} bmp_image;"
Failed to tokenize "typedef struct ico_image {         bmp_image bmp;"
Failed to tokenize "struct ico_image *next;"
Failed to tokenize "} ico_image;"
Failed to tokenize "typedef struct ico_collection {                  bmp_bitmap_callback_vt bitmap_callbacks;"
Failed to tokenize "uint16_t width;"
Failed to tokenize "uint16_t height;"
Failed to tokenize "uint8_t *ico_data;"
Failed to tokenize "uint32_t buffer_size;"
Failed to tokenize "ico_image *first;"
Failed to tokenize "} ico_collection;"
Scanning libnsbmp
 with pattern 
#?.c
Scanning libnsbmp/src
 with pattern 
#?.c
Scanning libnsbmp/src/utils
 with pattern 
#?.c
Scanning libnsbmp/include
 
with pattern #?.c
9 headers
Successfully wrote header definitions to nsbmp
.xml
Generating source succeeded
Generating headers succeeded
Generating vectors succeeded
Failed to generate init
.c


It does appear to have generated all the code, including init.c.

It hasn't copied libnsbmp.h over so I had to do that manually.

Building the library then gave a few errors. These look related to the defined structures, so I don't know whether it's the earlier complaints causing these not to be defined, or whether it needs to include libnsbmp.h (either approach should work, but I don't know what your parser is trying to do)

7.RAM Disk:> make -f nsbmp.makefile
gcc  
-Wall -O3  -Insbmp_source/include -Insbmp_source -I.   --o nsbmp_source/init.o nsbmp_source/init.c
In file included from nsbmp_source
/include/proto/nsbmp.h:32,
                 
from nsbmp_source/init.h:10,
                 
from nsbmp_source/init.c:8:
nsbmp_source/include/interfaces/nsbmp.h:42errorexpected ';'',' or ')' before '*' token
nsbmp_source
/include/interfaces/nsbmp.h:43errorexpected ';' before 'bmp_result'
In file included from nsbmp_source/vectors.h:10,
                 
from nsbmp_source/init.c:10:
nsbmp_source/nsbmp_libnsbmp.h:17errorexpected ';'',' or ')' before '*' token
nsbmp_source
/nsbmp_libnsbmp.h:23errorexpected ';'',' or ')' before '*' token
nsbmp_source
/nsbmp_libnsbmp.h:25errorexpected ';'',' or ')' before '*' token
In file included from nsbmp_source
/init.c:10:
nsbmp_source/vectors.h:24error'_nsbmp_bmp_decode' undeclared here (not in a function)
nsbmp_source/vectors.h:27error'_nsbmp_bmp_finalise' undeclared here (not in a function)
nsbmp_source/vectors.h:28error'_nsbmp_ico_finalise' undeclared here (not in a function)


Source is here: http://git.netsurf-browser.org/libnsbmp.git

Simple to fix-up afterwards, but the point of this is that we shouldn't need to, right?

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
@Kamelito

Yup. The main differences are that with idltool you have to write the xml file , then fill in the skeleton interface code to all the actual code that does the wrk. With this tool you point at the actual code and it generates the full interface code for you.

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
@Chris

Thanks for this, yup my whole reason for starting this was I had a project with about 600 functions that I wanted to port and the idea of generating the xml files for them just made me reach for some beers! That netsurf code will give me some really useful food for thought for the parser part, which is definitely the most "ugh!" part of the program! Trying to replicate YACC or similar is not fun. It looks like it's not able to parse the callback functions properly and that I should get it to understand structures and enums instead of trying to parse them as function declarations.

I noticed that the output said failed "failed to generate init.c" which should I suspect actually say "failed to generate lib_init.c" (first bugfix done, hurrah!), is there a lib_init.c in the folder? It should be a straight copy of "data/lib_manager.c.template", which should be in the archive with libgen.

And yup, the whole point of this is not to have fix stuff up afterwards, I'll download that bmp decoder code and set about getting the parser to cope with it.

Thanks for the feedback, it's definitely appreciated.

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
Perhaps my own experience is not as broad as some others, but I found IDLTool a VERY helpful program.
I was maintaining camd.library, which was based on code from AROS. While debugging and adding a few missing features, I kept the source AROS buildable so that all improvements could be fed back to them. After all the bugs were worked out and we had enjoyed enough time to consider it "stable", I decided to finally make it OS4 native.
IDLTool was exactly what I needed to create the skeleton, properly formatted and with all the various header files included. Once I had a handle on it the port almost wrote itself. As a result camd.library lost a bit more than 35% of it's file size. Probably a bit more efficient as well, though I made no benchmarks to test it.

I am now writing a new library from scratch, and again IDLTool gave me a solid start, handling all the "ugly stuff" and letting me get right into writing library functions.

I guess it depends on what you expect. IDLTool is not a GUI. But it IS very good at weaving the web of various headers and libinit stuff into a tested foundation for new libraries (or devices, for that matter).

Just my own opinion, which might be worth nothing. :)

Go to top
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@billyfish

Quote:
is there a lib_init.c in the folder?


I don't know, I put everything in RAM: and have switched off now I don't remember seeing one. But then, I don't remember a lot of things.

Quote:
I'll download that bmp decoder code and set about getting the parser to cope with it.


It's quite a nice little test library, as it's only one file and one header. There are some other little libraries like that in the project, but if you get that one working the others should too. The bigger ones might be more of an issue, as they use functions from other libraries. I'm guessing that won't be handled (yet?).

Go to top
Re: Creating an AmigaOS4 library
Not too shy to talk
Not too shy to talk


See User information
see also this:

http://www.amiga-ng.org/viewtopic.php?topic=1975&forum=14

Especially the way of using an .sfd file to generate all including the .xml

Alain Thellier

Go to top
Re: Creating an AmigaOS4 library
Home away from home
Home away from home


See User information
@thellier
I can't read French, but this Google translation to English looks surprisingly good:
https://translate.google.co.uk/transla ... 5%26forum%3D14&edit-text=

Author of the PortablE programming language.
Go to top
Re: Creating an AmigaOS4 library
Just can't stay away
Just can't stay away


See User information
@ChrisH

Wow, I can confirm. The result is almost perfect. Their translation service improved since the last time I tried it.

Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
Hi all

I agree IDLTool and fdtrans are great at what they do, the issue is that you still need to write the xml or sfd file and synchroize it with the function definitions. The goal of libgen is to do that all for you so it will generate the xml or sfd file for you automatically from the source. As well as this it replicates what idltool does in terms of generating the library init code, header files, etc. It also wraps the called code into the library.

For instance, say you've told it to build "foo.libray" and it finds a defintion such in "foobar.h" like

int foobar (int aint b);


it will generate the appropriate library files with a source file containing:

....

#include "foobar.h"

...

int _foo_foobar (struct FooIFace *IFooint aint b)
{
  return 
foobar (ab);
}


and the corresponding header file as well as a makefile to build it all.


The main goal was for my cross-platform projects whera I can generate a
shared library on windows or linux just by having a makefile pointing at the source files and I wanted the same on my amiga. I don't have to worry about keeping sfd or xml files in sync with the directory tree containing the source files, I simply point libgen at the directory and tell it to generate all of the amiga-specific files for me. The idea of writing the sfd or xml file by hand for projects containing hundreds of functions didn't
filll me with joy!

So rather than generating the skeleton code, it goes further and tries to generate the working code along with, as best as it can, a ready-to-go makefile without me having to fill in any other code.

Hope this makes vague sense!


Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
@Chris


Yup it's a good test, I found a bug that the code generation for functions with a single input parameter wasn't getting generated properly and that's fixed for the next version.

Probably my sleep-deprived brain but what issue are you thinking of when you say libraries using functions from other libraries?

cheers

billy

Go to top
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@billyfish

Quote:
Probably my sleep-deprived brain but what issue are you thinking of when you say libraries using functions from other libraries?


I mean if mylibrary uses, say, libbz2 for some decompression routines, libgen won't recognise that. I suppose it only needs the -lbz2 in the makefile, but if you take it further and libbz2 was generated with libgen, then mylibrary won't recognise that it needs to open libbz2.library (or whatever) in order to work.

Hope that makes sense.

Go to top
Re: Creating an AmigaOS4 library
Home away from home
Home away from home


See User information
@Elwood
I believe Google recently started using neural nets for the most common languages, thanks to some breakthrough. (Say hello to our robot masters...)

Author of the PortablE programming language.
Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
@Chris

Ah I get it now!

I've fixed it so now it parses and compiles libnsbmp seamlessly now along with a load of other bug fixes and features such as an option to automatically open and close newlib. I'll upload it to os4depot in the next couple of days.


cheers

billy

Go to top
Re: Creating an AmigaOS4 library
Amigans Defender
Amigans Defender


See User information
@billyfish

Cool! Rearranging the function order in the interface might be handy too (so as not to break compatibility on updates). I'm not sure how you'd implement it though - maybe it could scan an existing interface header?

Go to top
Re: Creating an AmigaOS4 library
Just popping in
Just popping in


See User information
@Chris

Yup that and adding the auto init code are the two outstanding bits of functionality that I can think of. And of course there will be no doubt be guys that will need squashing.

Go to top

  Register To Post
« 1 (2) 3 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project