From: <enl...@li...> - 2000-11-01 11:55:22
|
Enlightenment CVS committal Author : boris Project : misc Module : ferite Modified Files: Makefile.am bastard.fe main.c test.c test.fe Log Message: boris: This is a fricken huge commit, loads of changes basically: - more complete object support - no way near as complete as i want but hey nevermind that can be fixed - namespace clean ups in the compiler and parser - hashing routines - fast and usable - arrays work - modules work (see modules/Console and modules/File for example) - return variables have been fixed - there were issues - added ferite-config file (to eventually aid the building of modules) - libltdl is now a dependancy - added ferite_landuage_def.sdw as the start of thwe whitepaper/docs for ferite - loads fo bug fixes - there were some major issues regarding realloc() and malloc() in the memory manager - that has now been fixed - variaous code cleanups and fixes =================================================================== RCS file: /cvsroot/enlightenment/misc/ferite/test/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- Makefile.am 2000/09/14 22:42:49 1.3 +++ Makefile.am 2000/11/01 11:55:22 1.4 @@ -1,5 +1,5 @@ bin_PROGRAMS = ferite -ferite_SOURCES = main.c test.c +ferite_SOURCES = main.c test.c test.h ferite_DEPENDENCIES = $(top_builddir)/src/libferite.la ferite_LDFLAGS = -rpath $(libdir):$(pkglibdir) @@ -13,6 +13,6 @@ testscripts_DATA = bastard.fe test.fe -testscriptsdir = $(prefix)/share/ferite/test +testscriptsdir = $(prefix)/share/ferite/ EXTRA_DIST = $(testscripts_DATA) =================================================================== RCS file: /cvsroot/enlightenment/misc/ferite/test/bastard.fe,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- bastard.fe 2000/09/15 13:24:26 1.3 +++ bastard.fe 2000/11/01 11:55:22 1.4 @@ -3,40 +3,32 @@ /* empty function */ } -number main() +void main() { number i = 0, j, k, l, m, n, o, p; - object c = new Test(); - c.println( "Starting..." ); if( i < 5 ) { if( i < 2 ) i += 2; } - c.println( "Warming up" ); while( i < 10 ) i++; - c.println( "Going for gold" ); if (1 < 2) { - c.println( "k loop" ); while(k < 4) { k++; - c.println( "l loop" ); for (l = 0; l < 4; l++) { if (1 < 2) { - c.println( "i loop" ); for (i = 0; i < 4; i++) { j = 0; - c.println( "j loop" ); while(j < 4) { j++; @@ -44,21 +36,16 @@ { if(12 < 24) { - c.println( "m loop" ); for(m = 0; m < 4; m++ ) { - c.println( "o loop" ); for(o = 0; o < 4; o++) { - c.println( "p loop" ); while(p < 4) { p++; - c.println( "n loop" ); while(n < 4) { n++; - c.print( "." ); } } } =================================================================== RCS file: /cvsroot/enlightenment/misc/ferite/test/main.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- main.c 2000/09/18 09:57:38 1.16 +++ main.c 2000/11/01 11:55:22 1.17 @@ -1,11 +1,13 @@ #include <ferite.h> +#include "../config.h" +#include "../stamp-h" #include "test.h" struct { char *scriptname; int verbose; int showargs; -} mode; +} opt; void show_help() { @@ -23,15 +25,15 @@ int i; char *buf; - mode.verbose = 0; - mode.showargs = 0; + opt.verbose = 0; + opt.showargs = 0; for( i = 0; i < argc; i++ ) { if( strcmp( argv[i], "--verbose" ) == 0 || strcmp( argv[i], "-v" ) == 0 ) - mode.verbose = 1; + opt.verbose = 1; else if( strcmp( argv[i], "--showargs" ) == 0 || strcmp( argv[i], "-s" ) == 0 ) - mode.showargs = 1; + opt.showargs = 1; else if( strcmp( argv[i], "--help" ) == 0 || strcmp( argv[i], "-h" ) == 0 ) show_help(); else @@ -51,7 +53,7 @@ bzero( buf, 1024 ); strcpy( buf, argv[argc-1] ); } - mode.scriptname = buf; + opt.scriptname = buf; } } } @@ -64,7 +66,7 @@ FeriteObject *obj; int i = 0; - fprintf( stderr, "%s (v %d.%d.%d)\n", FERITE_NAME, FERITE_MAJOR, FERITE_MINOR, FERITE_RELEASE); + fprintf( stderr, "%s (v %s) (%s)\n", PACKAGE, VERSION, DATEREL ); if ( argc < 2 ) { printf( "\nUsage: ferite [OPTIONS] [FILE]\n\n" ); @@ -75,49 +77,48 @@ { parse_args( argc, argv ); - if( mode.showargs ) + if( opt.showargs ) { printf( "Argument Count: %d\n", argc ); for( i = 0; i < argc; i++ ) printf( "Argument #%d: %s\n", i+1, argv[i] ); } - if( mode.verbose ) + if( opt.verbose ) printf( "_initialising ferite___________________________________\n"); env = ferite_init( argc, argv ); - if( mode.verbose ) + if( opt.verbose ) printf( "_creating script object________________________________\n" ); classp = test_class_register( env ); /* in test.c */ - obj = test_object_register( env ); script = ferite_new_script( env ); - if( mode.verbose ) + if( opt.verbose ) { printf( "_loading script from file______________________________\n" ); - printf( " script file: %s\n", mode.scriptname ); + printf( " script file: %s\n", opt.scriptname ); } - ferite_script_load( script, mode.scriptname ); + ferite_script_load( script, opt.scriptname ); - free( mode.scriptname ); + free( opt.scriptname ); - if( mode.verbose ) + if( opt.verbose ) printf( "_compiling script______________________________________\n" ); ferite_script_parse( script ); - if( mode.verbose ) + if( opt.verbose ) printf( "_executing script______________________________________\n" ); - + ferite_script_execute( script ); - if( mode.verbose ) + if( opt.verbose ) printf( "_destroying script object______________________________\n" ); - ferite_script_delete( env, script ); + /* ferite_script_delete( env, script );*/ ferite_deinit( env ); return 0; =================================================================== RCS file: /cvsroot/enlightenment/misc/ferite/test/test.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- test.c 2000/09/18 14:23:20 1.4 +++ test.c 2000/11/01 11:55:22 1.5 @@ -6,28 +6,18 @@ * * obj = new Test; * * obj.print( 1, "fun", 0.1 ); */ -FeriteObject *test_object_register( FeriteEnviroment *env ) -{ - FeriteObject *obj; - obj = ferite_register_object( env, "Console", env->objects ); - ferite_register_object_function( obj, "print", test_print, "void(string)" ); - ferite_register_object_function( obj, "println", test_println, "void(string)" ); - ferite_register_object_function( obj, "printf", test_printf, "void(string,...)" ); - return obj; -} - FeriteClass *test_class_register( FeriteEnviroment *env ) { FeriteClass *classp; classp = ferite_register_class( env, "Test" ); - ferite_register_class_function( classp, "Test", test_cons, "void(string)" ); - ferite_register_class_function( classp, "print", test_print, "void(string)" ); - ferite_register_class_function( classp, "println", test_println, "void(string)" ); - ferite_register_class_int_number_variable( classp, "testint", 10 ); - ferite_register_class_float_number_variable( classp, "testfloat", 3.14 ); - ferite_register_class_string_variable( classp, "teststring", "j00 r0x" ); - ferite_register_class_object_variable( classp, "innerobj" ); + ferite_register_class_function( classp, "Test", test_cons, "v(s)" ); + ferite_register_class_function( classp, "print", test_print, "v(s)" ); + ferite_register_class_function( classp, "println", test_println, "v(s)" ); + ferite_register_class_int_number_variable( classp, "aint", 10 ); + ferite_register_class_float_number_variable( classp, "afloat", 3.14 ); + ferite_register_class_string_variable( classp, "astring", "j00 r0x" ); + ferite_register_class_object_variable( classp, "aobj" ); return classp; } @@ -35,30 +25,30 @@ { char *buf; - buf = MALLOC( 1024 ); + buf = fmalloc( 1024 ); bzero( buf, 1024 ); if( ferite_get_parameter_count( params ) != 1 ) ferite_error( "Test::print can only take one paremeter\n" ); else ferite_get_parameters( params, 1, buf ); printf( "%s", buf); - FREE( buf ); - FE_RETURN_INT( 1 ); + ffree( buf ); + FE_RETURN_VOID; } FE_CLASS_FUNCTION( test_println ) { char *buf; - buf = MALLOC( 1024 ); + buf = fmalloc( 1024 ); bzero( buf, 1024 ); if( ferite_get_parameter_count( params ) != 1 ) ferite_error( "Test::println can only take one paremeter\n" ); else ferite_get_parameters( params, 1, buf ); printf( "%s\n", buf); - FREE( buf ); - FE_RETURN_INT( 1 ); + ffree( buf ); + FE_RETURN_VOID; } FE_CLASS_FUNCTION( test_printf ) @@ -67,7 +57,7 @@ FeriteParameterList *ptr; int i; - buf = MALLOC( 1024 ); + buf = fmalloc( 1024 ); bzero( buf, 1024 ); ferite_get_parameters( params, 1, buf ); @@ -79,8 +69,8 @@ i++; if( ptr == NULL ) { - FREE( buf ); - FE_RETURN_INT( 0 ); + ffree( buf ); + FE_RETURN_VOID; } switch( buf[i] ) @@ -104,7 +94,7 @@ printf( "%s", VAS( ptr->var) ); break; case 'o': - printf( "Obj[%s]", VAO(ptr->var)->name ); + printf( "Object[%s::%p]", VAO(ptr->var)->name, VAO(ptr->var) ); break; } ptr = ptr->next; @@ -112,12 +102,11 @@ else printf( "%c", buf[i] ); } - FREE( buf ); - FE_RETURN_INT( 1 ); + ffree( buf ); + FE_RETURN_VOID; } FE_CLASS_FUNCTION( test_cons ) { - printf( "Constructor Called\n" ); - FE_RETURN_INT( 1 ); + FE_RETURN_VOID; } =================================================================== RCS file: /cvsroot/enlightenment/misc/ferite/test/test.fe,v retrieving revision 1.31 retrieving revision 1.32 diff -u -3 -r1.31 -r1.32 --- test.fe 2000/09/20 18:58:56 1.31 +++ test.fe 2000/11/01 11:55:22 1.32 @@ -1,81 +1,58 @@ #!/usr/local/bin/ferite -global { - object con; -} +uses Console, File, SQL; -number blim( string funky ) -{ - Console.printf( "I am in blim!!!!\nWE HAVE WORKING SCRIPT FUNCTIONS!\n" ); - Console.printf( "%s\n", funky ); - Console.println( con.teststring ); - Console.printf( "Leaving blim!!!\n" ); +global { + object con; } -number main( number argc, string argv ) +void main( number argc, string argv[] ) { - number i = 20, j = 5; - object bloop; + number i = 1, j = 20, k = 2; + object testarray[]; + string blam; + object testfile; - con = new Test(); - - Console.printf( "j equals: %n\ni equals: %n\n", j, i ); + testfile = new File(); - bloop = wikkid(); - Console.println( bloop.teststring ); - - i = 10; - for( ; --i; ) + testfile.open( "/etc/fstab" ); + while( ! testfile.eof() ) { - Console.printf( "%n\n", i ); + Console.print( testfile.read() ); } + testfile.close(); + + con = new Test(); - blim( "blim called" ); - Console.println( "Out of blim" ); + Console.printf( "%s, please enter you name> ", "Console Module" ); + blam = Console.readln(); - blam( 10 ); - Console.println( "" ); - Console.printf( "blom: %n\n", blom( 10 ) ); - Console.printf( "blom: %n\n", blom( 300 ) ); - Console.printf( "blom: %n\n", blom( 243 ) ); - Console.printf( "blom: %n\n", blom( 1 ) ); - - Console.println( teststr( "Yellow" ) ); + Console.printf( "you just entered %s", blam ); - Console.println( "fun and games" ); - con.teststring = "no j00 dont"; + if( i == 0 && i == 0 ) + Console.println( "AND works" ); - if( con.teststring == "no j00 dont" ) - Console.println( "the strings are the same" ); + if( (i == 0 && j == 1) || k = 2 ) + Console.println( "OR works" ); - Console.println( "Second line\nThird Line\t\tTabbed Output" ); - Console.printf( "Fifth Line %s%n %n\n" , "[wikkid]", 10 , 0.1 ); -} + if( i != 0 ) + Console.println( "i is here init." ); + if( i != 1 ) + Console.println( "i isn't here init." ); + + Console.println ( "Filling Array" ); -void blam( number val ) -{ - if( val > 1 ) - blam( val - 1 ); - Console.printf( "%n\t", val ); -} + Console.print( "Yesh Yesh it werks\n" ); -number blom( number value ) -{ - if( value > 200 ) - return value; - else - return value+1; - Console.println( "YOU SHOULD NOT SEE THIS" ); -} - -string teststr( string astr ) -{ - return "BLAM"+astr+"BLOM"; -} - -object wikkid() -{ - object test = new Test(); - test.teststring = "created in wikkid"; - return test; + for( i = 0; i < 10; i++ ) + { + testarray[i] = con; + } + + Console.println( "Printing Array" ); + + for( i = 0; i < 10; i++ ) + { + testarray[i]->println( ""+ i + " " ); + } } |