|
Post by Pjot on Jul 27, 2014 15:25:39 GMT 1
Folks, Talking about hybrid language, instead of tediously declaring foreign functions all the time using PROTO, I thought it could come handy to let BaCon allow any non-BaCon functions it encounters. OPTION PARSE FALSE
This will save us from summing up everything in PROTO, however, it also allows any random string to get through the parser. So use with care. See this post for a demonstration. Regards Peter
|
|
|
Post by vovchik on Jul 27, 2014 17:53:09 GMT 1
Dear Peter, Thanks! It will certainly shorten some of my code. With kind regards, vovchik
|
|
|
Post by Pjot on Jul 28, 2014 15:14:59 GMT 1
Hi vovchik, Note that there are also downsides to this option. - Any random string of text will be accepted by the BaCon parser now. This may lead to very strange errors which only appear during compile time. Debugging can become very difficult.
- The PROTO statement does allow you to redefine the foreign function name to something more readable using ALIAS.
So I would not recommend changing your existing code, unless you really know what you're doing... using PROTO is more precise and secure, and enhances the quality of your code. But it's what you prefer, of course BR Peter
|
|
|
Post by vovchik on Jul 28, 2014 21:03:53 GMT 1
Dear Peter,
You are right, of course, but it's a nice feature once you have PROTO'd the code and know that it works. I tried it out for something that uses cairo, pango and X11 functions - plus some clib stuff - and it works nicely. After getting it all to work, I just commented out the PROTO statements and put OPTION PARSE FALSE at the top. Voila! I would also be careful, as you advise, but a nice feature....
With kind regards, vovchik
|
|
|
Post by alexfish on Jul 28, 2014 21:57:02 GMT 1
Hi Peter
Many thanks for the new Asset for BaCon . 'OPTION PARSE FALSE'
not sure about the implications of ALIAS , yet one can live with it by using USEC ..
BR Alex
REM Headless Chicken Code with BaCon OPTION PARSE FALSE
REM use USEC with #define for ALIAS
USEC
#define PRINTS puts // ALIAS puts #define LEN_OF_STR strlen // ALIAS strlen --- same as LEN
ENDUSEC
int lenof
' -------------------------------------- ' Main ' --------------------------------------
test_str$= "BaCon"
lenof =LEN_OF_STR(test_str$)
PRINT " Len on BaCon > ",lenof
PRINTS(test_str$)
PRINTS(" testing Bacon 'OPTION PARSE FALSE'\n This Works")
REM ---- END ALL THAT ------
|
|
|
Post by bigbass on Jul 29, 2014 14:45:59 GMT 1
Folks, I agree! now we don't have a keep everything on the bottom shelf idea when linking to the low level stuff We now raised all the low level functions up to the middle shelfwhere they can be easily used with much less extra syntax keeping things cleaner Yes, a hybrid for the low level stuff but without effecting the BASIC language syntax A win ,win Why dig down for the low level stuff when we can raise it up to be easily used less clutter too @hey Alex you can remove the USEC and compile with the bacon -j app.bac the -j option handles the #defines already Joe
|
|
|
Post by alexfish on Jul 29, 2014 16:08:05 GMT 1
Hi Joe
-j for bacon command line
on bacon gui that is
Invoke C Preprocessor [*]
in the options
OK if one Knows the actual CC options relative to BaCon :
BR
Alex
|
|
|
Post by alexfish on Jul 30, 2014 19:32:56 GMT 1
Hi Joe & Vovchik thought would put Latest BaCon through the Rasher Code , IE using BaCon at the lowest Level This is a follow up of the original concept , again here using bacon directly with C as in , This code compiles directly with c although I did a little Parser for a SYNTAX check , stops most of the Blow Outs ... Also been having a few of those with latest BaCon Hoping to have next Elementary update Complete sometime next week ," SETPROPERTY & GETPROPERTY " this one was not easy to get around since ELM has many different API's for each Widget , in Fact Mind Blowing , the basic's will be there as in ease of use , but also trying to leave the open for advanced user's , Easy task Not. In Mean Time BaCon RaSher (c) Code :: For those external to the BaCon Converter.org Forum Wishing to obtain a Free Copy of BaCon RaSher From Me. Please Send Donation To Peter , here can say a Compulsory Donation of at least Euro $499.99 , more than = Most Welcome = Free Delivery. Have Fun + BR Alex some of what the code Now looks like // Demo using BaCon / Rasher@Brasic (c) Alexfish @ BaCon Converter.org // Title " BACON CODE AT IT's Best " #include "Bacon_Rasher.h"
TYPE int i ,t,s TYPE char *lip TYPE char *loppy TYPE double sins
/*--- MAIN ----------------------------------------------------------------------------------*/ MAIN /*-------------------------------------------------------------------------------------------*/ t=FILELEN("/home/alexfish/Desktop/bacon/beta2/data.txt") PRINT(STR$(t)) t=FILEEXISTS("/home/alexfish/Desktop/bacon/beta2/data.txt") PRINT(STR$(t)) PRINTS("THIS----",t,30) PRINT(GETENVIRON("HOME")) PRINT("OK") PRINT(OS$()) //---------------------------------------------------------------------------------- PRINT(HEX$(23456)) //---------------------------------------------------------------------------------- loppy=MID$("This is a test",1,7) PRINT ("loppy=MID$('This is a test',1,7)") ; PRINT(loppy) //---------------------------------------------------------------------------------- PRINT(LEFT$("testing",5)) //---------------------------------------------------------------------------------- PRINT(UCASE$("It IT iT BaCon Is Best is BaCon IT it ")) //---------------------------------------------------------------------------------- FOR t = 1 TO 10 PRINT(STR$(t)) FOR s = 1 TO 5 PRINT(STR$(t)) NEXT ; NEXT //---------------------------------------------------------------------------------- PRINT(RIGHT$("ggggddhddh",6)) //---------------------------------------------------------------------------------- PRINTS( "Cos of 0.76 --> ", COS( 0.76 ) , 4 ) //---------------------------------------------------------------------------------- PRINTS("sins=HYPOT(3,4) --> ",sins=HYPOT(3,4),3) //---------------------------------------------------------------------------------- PRINTS("EQUAL('test','test') --> ",EQUAL("test","test"),1) //---------------------------------------------------------------------------------- PRINT(CHOP$(" BaCon Wins All Round ")) //---------------------------------------------------------------------------------- PRINT(CHOP$(" BaCon Wins All Round ")) //---------------------------------------------------------------------------------- IF EQUAL("HELLO", "HELLO") THEN PRINT ("Hello World") END IF //---------------------------------------------------------------------------------- loppy=EXEC$ ("/home/alexfish/Desktop/bacon/beta2/hack") PRINT (loppy) END MAIN
How good is BaCon , here is a valgrind test :: Results speak for them selves Same code in c // Title " BACON CODE AT IT's Best " #include "Bacon_Rasher.h"
int i, t, s; char *lip; char *loppy; double sins;
/*--- MAIN ----------------------------------------------------------------------------------*/ int main (int argc, char *argv[]) { /*-------------------------------------------------------------------------------------------*/ t = FILELEN ("/home/alexfish/Desktop/bacon/beta2/data.txt"); puts (STR$ (t)); t = FILEEXISTS ("/home/alexfish/Desktop/bacon/beta2/data.txt"); puts (STR$ (t)); PRINTS ("THIS----", t, 30); puts (GETENVIRON ("HOME")); puts ("OK"); puts (OS$ ()); puts (HEX$ (23456)); loppy = MID$ ("This is a test", 1, 7); puts ("loppy=MID$ ('This is a test',1,7)"); puts (loppy); puts (LEFT$ ("testing", 5)); puts (UCASE$ ("It IT iT BaCon Is Best is BaCon IT it ")); for (t = 1; t <= 10; t += 1) { puts (STR$ (t)); for (s = 1; s <= 5; s += 1) { puts (STR$ (t)); } } puts (RIGHT$ ("ggggddhddh", 6)); PRINTS ("Cos of 0.76 --> ", COS (0.76), 4); PRINTS ("sins=HYPOT (3,4) --> ", sins = HYPOT (3, 4), 3); PRINTS ("EQUAL ('test','test') --> ", EQUAL ("test", "test"), 1); puts (CHOP__b2c__string_var (" BaCon Wins All Round ")); puts (CHOP__b2c__string_var (" BaCon Wins All Round ")); if EQUAL ("HELLO", "HELLO") { puts ("Hello World"); } loppy = EXEC__b2c__string_var ("/home/alexfish/Desktop/bacon/beta2/hack"); puts (loppy);
return 0; }
|
|
|
Post by alexfish on Aug 3, 2014 1:08:57 GMT 1
Hi All. Any other day is Another BaCon day. The Rasher.h files almost complete as regards hooking up to Elementary. here using c + Bacon as in the libbacon , one can Achieve same with Latest BaCon 3.0.1 . using OPTION PARSE NONE.. Any way this is what BASIC(c) Syntax could Look like , take this one for real , see screen shot. C code next Post :: BR Alex The code : // Demo using BaCon / Rasher@Brasic (c) Alexfish @ BaCon Converter.org // Title "Rasher Elementary "
#include <Rasher_elm.h>
#define SHOW evas_object_show
TYPE int i,u,t,s TYPE char *lip TYPE char *loppy TYPE double sins TYPE char *file$
// Declares for elementary widgets TYPE Evas_Object *win
/* GUI code ------- * ----- Note the Functions -------* */
FUNCTION int INIT()
TYPE int init s=elm_init(0,0) GSET elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED) RETURN init
END FUNCT
REM Elementary Widgets + show style / code in BASIC & c style Note the Function
FUNCTION Evas_Object* WINDOW( char* title$, int width, int height)
TYPE Evas_Object *win // BASIC AND c win = elm_win_util_standard_add(title$, title$); elm_win_autodel_set(win, EINA_TRUE); GSET evas_object_resize(win, width, height) SHOW evas_object_show(win) return win END FUNCT
SUB DISPLAY() // Switch from BASIC to c without Commands elm_run(); elm_shutdown();
END SUB
/* End GUI bits --------------*/
/*--- MAIN ----------------------------------------------------------------------------------*/ MAIN /*-------------------------------------------------------------------------------------------*/
s=INIT(0,0) win=WINDOW ("BaCon(Rasher) Elementary",600,400) REM code in Rasher(c) + Code in (c) puts("OK"); puts(OS$); i=MOD(1,25) PRINTS("i=MOD(25,30) --> ",i,0) //loppy=CONCAT$("12","tyyyy") t=FILELEN("/home/alexfish/Desktop/bacon/beta2/data.txt") PRINT(STR$(t)) t=FILEEXISTS("/home/alexfish/Desktop/bacon/beta2/data.txt") PRINT(STR$(t)) PRINTS("THIS----",t,30) PRINT(GETENVIRON$("HOME")) PRINT("OK") PRINT(OS$) //---------------------------------------------------------------------------------- PRINT(HEX$(23456)) //---------------------------------------------------------------------------------- loppy=MID$("This is a test",1,7) PRINT ("loppy=MID$('This is a test',1,7)") ; PRINT(loppy) //---------------------------------------------------------------------------------- PRINT(LEFT$("testing",5)) //---------------------------------------------------------------------------------- PRINT(UCASE$("It IT iT BaCon Is Best is BaCon IT it ")) //---------------------------------------------------------------------------------- FOR t = 1 TO 10 PRINT(STR$(t)) FOR s = 1 TO 5 PRINT(STR$(t)) NEXT ; NEXT //---------------------------------------------------------------------------------- PRINT(RIGHT$("ggggddhddh",6)) //---------------------------------------------------------------------------------- PRINTS( "Cos of 0.76 --> ", COS( 0.76 ) , 4 ) //---------------------------------------------------------------------------------- PRINTS("sins=HYPOT(3,4) --> ",sins=HYPOT(3,4),3) //---------------------------------------------------------------------------------- PRINTS("EQUAL('test','test') --> ",EQUAL("test","test"),1) //---------------------------------------------------------------------------------- PRINT(CHOP$(" BaCon Wins All Round ")) //---------------------------------------------------------------------------------- IF EQUAL("HELLO", "HELLO") THEN PRINT ("Hello World") END IF //---------------------------------------------------------------------------------- t = FILETYPE("/home/alexfish/Desktop/bacon/beta2/data.txt") PRINTS("file type",t,0) file$="/home/alexfish/Desktop/bacon/beta2/data.txt"
PRINTS("file type --> ",FILETYPE(file$),0) REM ---NOW Show---------------------------------------------------------------------
DISPLAY() END MAIN
Attachments:
|
|
|
Post by alexfish on Aug 3, 2014 1:10:39 GMT 1
same again BR Alex
c code
// Title "Rasher Elementary "
#include <Rasher_elm.h>
#define SHOW evas_object_show;
int i, u, t, s; char *lip; char *loppy; double sins; char *file$;
Evas_Object *win;
/* GUI code ------- * ----- Note the Functions -------* */
int INIT () {
int init; s = elm_init (0, 0); elm_policy_set (ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); return init;
}
Evas_Object * WINDOW (char *title$, int width, int height) {
Evas_Object *win; win = elm_win_util_standard_add (title$, title$); elm_win_autodel_set (win, EINA_TRUE); evas_object_resize (win, width, height); SHOW evas_object_show (win);
return win; }
void DISPLAY () { elm_run (); elm_shutdown ();
}
/* End GUI bits --------------*/
/*--- MAIN ----------------------------------------------------------------------------------*/ int main (int argc, char *argv[]) { /*-------------------------------------------------------------------------------------------*/
s = INIT (0, 0); win = WINDOW ("BaCon (Rasher) Elementary", 600, 400);
puts ("OK"); puts (OS$);
i = MOD (1, 25); PRINTS ("i=MOD (25,30) --> ", i, 0);
t = FILELEN ("/home/alexfish/Desktop/bacon/beta2/data.txt"); puts (STR$ (t)); t = FILEEXISTS ("/home/alexfish/Desktop/bacon/beta2/data.txt"); puts (STR$ (t)); PRINTS ("THIS----", t, 30); puts (GETENVIRON$ ("HOME")); puts ("OK"); puts (OS$); puts (HEX$ (23456)); loppy = MID$ ("This is a test", 1, 7); puts ("loppy=MID$ ('This is a test',1,7)"); puts (loppy); puts (LEFT$ ("testing", 5)); puts (UCASE$ ("It IT iT BaCon Is Best is BaCon IT it ")); for (t = 1; t <= 10; t += 1) { puts (STR$ (t)); for (s = 1; s <= 5; s += 1) { puts (STR$ (t)); }; } puts (RIGHT$ ("ggggddhddh", 6)); PRINTS ("Cos of 0.76 --> ", COS (0.76), 4); PRINTS ("sins=HYPOT (3,4) --> ", sins = HYPOT (3, 4), 3); PRINTS ("EQUAL ('test','test') --> ", EQUAL ("test", "test"), 1); puts (CHOP$ (" BaCon Wins All Round ")); if EQUAL ("HELLO", "HELLO") { puts ("Hello World"); } t = FILETYPE ("/home/alexfish/Desktop/bacon/beta2/data.txt"); PRINTS ("file type", t, 0); file$ = "/home/alexfish/Desktop/bacon/beta2/data.txt";
PRINTS ("file type --> ", FILETYPE (file$), 0);
DISPLAY ();
return 0; }
|
|
|
Post by vovchik on Aug 3, 2014 12:54:59 GMT 1
Dear Alex, Rasher is getting tastier by the day. With kind regards, vovchik
|
|
|
Post by alexfish on Aug 6, 2014 4:37:54 GMT 1
Hi All & @ Vovchik
Still miles behind with SETPROPERTY
been on a hunt to fix this EDIT , do know that at least on some system the buffer will bust at some stage , does on mine
finally made a break through as regards a fix , think Vovchik can confirm this bug was found some few months ago think at least 4 or more .
fix will be in next update for testing.
also had to fix another , "\n" and BaCon NL$ also was not recognized by the buffer . fix now resolved
IE:: after the update this will show 3 lines of text, if try now then = 1 line
text$=CONCAT$("This \n is text",NL$,"Text") TEXT(edit,text$)
now looking to resolve MENU , this one will have a change to the API , this is necessary to comply will the lib at 'c' level
will update the lib in about 3/4 days , then only after testing for stability will SETPROPERTY and GETPROPERTY be 'fully' implemented , 'HUG style'.
Trawling around the ELM .h files is a mind blowing experience , but sometimes worth it when can fix such bugs as mentioned above
BR Alex
|
|
|
Post by vovchik on Aug 6, 2014 9:21:41 GMT 1
Dear Alex, I am certain, after all that tedious work, we will have something great, so hang in there. I know about the difficulty of SET/GETPROPERTY in enlightenemnt, since there is no unified way to do this in enlightenment itself, each widget having its own get and set procedures, and there being no "gobject" as in glib. In any case, we are all eagerly looking forward to palying with it... With kind regards, vovchik
|
|
|
Post by alexfish on Aug 7, 2014 17:20:04 GMT 1
Hi Peter either going to test against Hug elementary if can not resolve near to replicate.
all can say is the beta's up to the release work , possible last beta and stable differ.
BR Alex
demo code an results
'@ testit
REM ---* INCLUDES *------------------------------------------------------------
INCLUDE hug_elm.bac
REM ---* DECLARES *-----------------------------------------------------------
default$="<font=Serif:style=Italic><font_size=15><color=#FFF400><b>"
mk$="<font=Serif:style=Italic><font_size=18><color=#f0f7> \ This is a bit of marked-up text here that<br/> \ uses colours, attributes (e.g. <b>BOLD</>)<br/> \ for styling and special effects like this,<br/><color=#00ff> \ so:<br/><font=Sans:style=normal> \ <font_size=30><color=#f00e><outline_color=#0008><font_weight=extrablack> \ <align=50%><style=outline>HAVE FUN!" REM ---------------------------------------------------------------------- ' ----* SUBS & FUNCTIONS *----- REM ----------------------------------------------------------------------
SUB GET_MOUSE()
'@ first trigger the mouse GET(mouse) '@ now print the mouse x & y CLEAR PRINT "mouse x : " , MOUSE(0) PRINT "mouse y : " , MOUSE(1)
PRINT " Tracking mouse " PRINT "---------------------------" SETPROPERTY(timer_1,"timer_start",TRUE,TRUE,TRUE,TRUE)
END SUB
FUNCTION Test_timout1
'@ first trigger the mouse GET(mouse)
TEXT(mk,mk$ & "<br/><br/><br/><font_size=15><color=#00ff>" & "Mouse cord X : " & STR$(MOUSE(0)) & " Mouse cord Y : " & STR$(MOUSE(1))) RETURN TRUE
END FUNCTION
SUB TEST_CALLBACK() '@ first trigger the mouse GET(mouse) '@ now print the mouse x & y CLEAR
PRINT "mouse x : " , MOUSE(0) PRINT "mouse y : " , MOUSE(1)
END SUB
'@ Always Init INIT
'@ Always :the first widget Must be a "Window" no buts or if's else mouse will not work win=WINDOW("Elementary Tests",600,400) CALLBACK(win,TEST_CALLBACK)
mk=MARK(mk$,600,400) ATTACH(win,mk,0,0)
but=BUTTON("Get mouse",100,25) ATTACH(win,but,10,10) CALLBACK(but,GET_MOUSE)
timer_1=TIMEOUT(200,Test_timout1)
DISPLAY
Compile time
At moment where it happens is in GET , have not tested any others since can not get past this.
FUNCTION GET(NUMBER hug_widget)
LOCAL type$ LOCAL hug_value TYPE double
type$=properties[hug_widget].type$
SELECT type$
CASE "mouse" evas_pointer_canvas_xy_get(evas_object_evas_get(properties[1].sig_widget),&hug_gui_properties.mousex,& hug_gui_properties.mousey) CASE "window"
CASE "hslider" hug_value=elm_slider_value_get(properties[hug_widget].sig_widget)
CASE "vslider" hug_value=elm_slider_value_get(properties[hug_widget].sig_widget)
CASE "spin" hug_value=elm_spinner_value_get(properties[hug_widget].sig_widget)
CASE "button" hug_value=elm_button_autorepeat_get(properties[hug_widget].sig_widget)
CASE "stock"
CASE "toggle"
CASE "check" hug_value=elm_check_state_get(properties[hug_widget].sig_widget)
CASE "radio" hug_value=elm_radio_value_get(properties[hug_widget].sig_widget)
CASE "password"
CASE "list"
CASE "combo" CASE "edit"
END SELECT
RETURN hug_value
END FUNCTION
|
|
|
Post by alexfish on Aug 7, 2014 18:20:04 GMT 1
On a Brighter note
Now got Movie's as in a movie player .. just finished testing mp4 files.
BR Alex
|
|