BaCon - Bash-based Basic-to-C converter/compiler

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: signals and callbacks

#31 Post by mechanic »

vovchik wrote:Dear Doyle,

Please have a look at the attached archive. Peter put together a glade.bac file that is used as an include. It has all the necessary and useful imports and libs defined. I'll re-read your message and hope to post something sensible soon regarding signals.

With thanks and kind regards,
vovchik
Thanks but I have a copy of the glade.bac file here. I may need to add all of the IMPORTs in there but for now, it seems I have all needed.

Here is the latest source that I have. I am still working on automatically adding the close signal and connecting it correctly so that is not finished yet.

I am not adding the signals *IF* the user doesn't add them to the glade file in the Glade GUI designer. I don't want to second guess the user. They might not want the callbacks generated (can't see why but if they want them, they'll have to add them in the designer.)

Please share your thoughts on the code. What else is needed? What would be good to have added?
Attachments
mkglade.tar.gz
(3.62 KiB) Downloaded 978 times
regards,
mechanic

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Latest glade converter for BaCON

#32 Post by mechanic »

Hi all, I completely rewrote the code making it simpler. Please test and let me know of any bugs. Seems to work on all of my test code here.
Attachments
mkglade-1.tar.gz
(2.85 KiB) Downloaded 986 times
regards,
mechanic

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#33 Post by vovchik »

Dear Doyle,

GREAT work. I would do as you suggest - if no signal connect, just load the Glade file and add them. mkglade now picks up and makes the SUBs for my glade widgets. The only think that might be added as "standard" is a gtk_exit SUB by default.

I am now testing with various Glade files and will report back.

Thanks.

With kind regards,
vovchik

PS. I think
IMPORT "gtk_exit(int)" FROM "libgtk-x11-2.0.so" TYPE void
and the callback for closing a prog
' ---------------
SUB exit_prog()
' ---------------
gtk_exit(0)
END SUB

might be useful in nearly all cases.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

nice compile

#34 Post by vovchik »

Dear Doyle,

Try compiling the attached. Works nicely.

With kind regards,
vovchik
Attachments
egdesigner.glade.tar.gz
(5.86 KiB) Downloaded 1011 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

parsing error

#35 Post by vovchik »

Dear Doyle,

The attached glade file gives a parsing error when compiling the binary. I think mkglade is missing something or getting confused. Have a look at the generated source. Bacon will point you to the line numbers.

With kind regards,
vovchik
Attachments
PupWebTV.glade.tar.gz
(941 Bytes) Downloaded 963 times

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: parsing error

#36 Post by mechanic »

vovchik wrote:Dear Doyle,

The attached glade file gives a parsing error when compiling the binary. I think mkglade is missing something or getting confused. Have a look at the generated source. Bacon will point you to the line numbers.
Ok, multiple signals defined in this glade file. None of the examples that I have here are like that. I hope I have it fixed. Please test and let me know.

This little program is looking good to me! :-D

EDIT: The egdesigner glade file won't compile as is. I had to increase the array limits in mkglade to the following and recompile mkglade.bac:

Code: Select all


RECORD glade[1000]
    LOCAL class$    TYPE STRING
    LOCAL id$          TYPE STRING
    LOCAL signal$[100]    TYPE STRING
    LOCAL handler$[100] TYPE STRING
    LOCAL wtype     TYPE NUMBER
END RECORD

I also added your suggested code:

Code: Select all


IMPORT "gtk_exit(int)" FROM "libgtk-x11-2.0.so" TYPE void

' ---------------
SUB exit_prog()
' ---------------
gtk_exit(0)
END SUB 

Attachments
mkglade-3.tar.gz
(3.01 KiB) Downloaded 965 times
Last edited by mechanic on Mon 06 Sep 2010, 17:11, edited 1 time in total.
regards,
mechanic

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

weird ascii codes and mixup in sub sames

#37 Post by vovchik »

Dear Doyle,

Just tested mkglade2 and have weird sub names and other either low ascii (ACK, BS) or high ascii char appearing in sub names and bvits and pieces of the glade file (e.g. <widget>).

Please see attached file.

With kind regards,
vovchik
Attachments
glade2bac-src.tar.gz
(4.2 KiB) Downloaded 975 times

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: weird ascii codes and mixup in sub sames

#38 Post by mechanic »

vovchik wrote:Dear Doyle,

Just tested mkglade2 and have weird sub names and other either low ascii (ACK, BS) or high ascii char appearing in sub names and bvits and pieces of the glade file (e.g. <widget>).

Please see attached file.
Weird! I looked at the *.bac file and it was messed up. I then ran mkglade3 on it and it did fine. I *think* some of the test files are not created correctly by whoever did the designing. For instance, if the glade file has a "delete_event" instead of a "destroy" the app won't close correctly. I don't know enough about he glade file format to know if this is right or not.

BTW, a LOT of problems in the glade file can be fixed by opening the file in Glade 3.6.7, checking version and deprecations and resaving it.

Let me know if mkglade3 is ok for you.
regards,
mechanic

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

glade version

#39 Post by vovchik »

Dear Doyle,

I can't really run glade 3.6.7 on my usual development machine,because I still have puppy 3.01 and it uses gtk 2.10. Glade 3.6.7 requires gtk 2.14. I had been using glade 3.0.0 but just compiled 3.2.2 using Barry's ./configure line, which worked fine. I am still getting confused SUBs (bits and pieces of the glade file being used for the SUB name - i.e. weird stuff in the generated *.bac file - and the subsequently compilation bombing). I don't know what is causing that, but I will now look at the code in mkglade-3 to see whether I can figure it out. I am intrigued, because it looks like a processing or parsing error and not necessarily glade. Old mkglade (I think from 1 am last night) works fine with those glade files.

With thanks and kind regards,
vovchik

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: glade version

#40 Post by mechanic »

vovchik wrote:Dear Doyle,

I can't really run glade 3.6.7 on my usual development machine,because I still have puppy 3.01 and it uses gtk 2.10. Glade 3.6.7 requires gtk 2.14. I had been using glade 3.0.0 but just compiled 3.2.2 using Barry's ./configure line, which worked fine. I am still getting confused SUBs (bits and pieces of the glade file being used for the SUB name - i.e. weird stuff in the generated *.bac file - and the subsequently compilation bombing). I don't know what is causing that, but I will now look at the code in mkglade-3 to see whether I can figure it out. I am intrigued, because it looks like a processing or parsing error and not necessarily glade. Old mkglade (I think from 1 am last night) works fine with those glade files.
Sorry, I didn't think about that. I'm running lucid puppy 5.01 (5.1?). I started with version 4, got all of the dev stuff on it and then when lupu came out I set it up for my bacon/bcx programming envirionment.

I want to create a *.SFS file with all of my programming stuff in it so I don't have to manually add it when upgrading puppy. So far I've not had the time to figure that all out. I'm thinking of making something along those lines using bacon.

What version of Bacon are you using? Bash? I think Bash ver. >= 4.0 is required for the latest bacon version I have.

If you want, you can send me the glade files that don't work and I'll try them here. The last one in the attachment (PupWebTV) worked fine with mkglade3 here.

All of the other, smaller glade files seem to be ok too.


Send to:

mekanixx at gmail dot com
regards,
mechanic

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Bash and Bacon versions

#41 Post by vovchik »

Dear Doyle,

I am using the latest BaCon - released last night BaCon (version 1.0 build 18 beta). It is in the /beta dir on Peter's site. My bash is 3.2.29(2)-release (i486-slackware-linux-gnu). It is a version that is recent enough to work with BaCon (and still in the 3.x series). So bash and BaCon aren't causing the problem. I usually update BaCon every few days. So I am still scratching my head.

With kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

I fixed it!

#42 Post by vovchik »

Dear Doyle,

I finally found out what was wrong. When assigning values to a RECORD element, you have to use the "WITH/END WITH" construction. My fix is attached. No more garbage SUBs.:)

With kind regards,
vovchik
Attachments
mkglade-4c.tar.gz
(18.37 KiB) Downloaded 949 times

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: I fixed it!

#43 Post by mechanic »

vovchik wrote:Dear Doyle,

I finally found out what was wrong. When assigning values to a RECORD element, you have to use the "WITH/END WITH" construction. My fix is attached. No more garbage SUBs.:)

With kind regards,
vovchik
Great! Now I can concentrate on some other buggy items. I need to figure out how to ignore some of the widget classes that don't use signals - like "GtkVBox", etc. Right now the parser grabs all of the classes.

Now if only I had a handy list... :)
regards,
mechanic

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: I fixed it!

#44 Post by mechanic »

mechanic wrote: Now if only I had a handy list... :)
Well, I hate to quote myself but I made a list of the available widgets which use signals and added it to the source in the form of DATA statements. Now mkglade don't add the widget class unless it is one that uses signals. This should make it a little faster parsing a glade file.

I hope that I didn't miss any widgets, if so please let me know.
Attachments
mkglade-4d.tar.gz
(3.66 KiB) Downloaded 1011 times
regards,
mechanic

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#45 Post by Lobster »

Some new Bacon 1 build 19 was released on 31 October.
http://www.basic-converter.org/

I need a tutorial - starting with 'Hello world'

I have the devx running
It compiles c code - then I think I get stuck
trying to compile it . . .

is that right?

Code: Select all

gcc -c t.bac.c
gosh I should know this . . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
smokey01
Posts: 2813
Joined: Sat 30 Dec 2006, 23:15
Location: South Australia :-(
Contact:

#46 Post by smokey01 »

Lobster, would the space between the dot and the c be the problem?

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

BaCon 101

#47 Post by mechanic »

BaCon 101

Download the source:

http://www.basic-converter.org/bacon.bac

If you don't have a compiled bacon executable, also download this:

http://www.basic-converter.org/bacon.bash

Open a terminal in the download folder and type:

Code: Select all


./bacon.bash bacon.bac

When it finishes you will have a bacon executable, place in the /usr/bin/ or /usr/local/bin/ folder.

Now to translate/compile a *.bac file just do:

Code: Select all


bacon yourfile.bac

See the docs here:

http://www.basic-converter.org/documentation.html

You should be good to go!

Anytime you download a new version, you'll have to do recompile the bacon source using the old bacon executable. Unless Peter adds something new that breaks the old version this will work. Otherwise you'll need to get the bacon.bash version and compile the new bacon executable with it. Peter always releases new versions of both at the same time so this should always work.

HTH
regards,
mechanic

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#48 Post by Lobster »

Thanks guys. You may have saved my bacon.

Oink Oink
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#49 Post by amigo »

Be sure and bring some of that bacon home.

User avatar
Mobeus
Posts: 94
Joined: Thu 26 Aug 2010, 15:49

#50 Post by Mobeus »

Hi guys,

bacon-bash needs bash 4. Here is the bacon-1.19 binary that I use in lupu if anyone needs it. It goes in /usr/bin and does not need bash 4.
Attachments
bacon-1.19.tar.gz
(90.78 KiB) Downloaded 494 times
/root for the home team

Post Reply