Changeset 306 for trunk

Show
Ignore:
Timestamp:
04/26/2008 01:08:10 (7 months ago)
Author:
slact
Message:

updated for Lua 5.1, cleaned up the Makefile, added make install

Location:
trunk/ext/lua
Files:
1 added
3 modified
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/ext/lua/Makefile

    r217 r306  
    11# change these to reflect your Lua installation 
    2 LUA=/usr/ 
    3 LUAINC= $(LUA)/include/lua50 
    4 LUALIB= $(LUA)/lib 
    5 LUABIN= $(LUA)/bin 
     2# Default installation prefix 
     3PREFIX=/home/leop/local 
     4 
     5# System's libraries directory (where binary libraries are installed) 
     6LUA_LIBDIR= $(PREFIX)/lib/lua/5.1 
     7 
     8# System's lua directory (where Lua libraries are installed) 
     9LUA_DIR= $(PREFIX)/share/lua/5.1 
     10 
     11LUAINC= $(PREFIX)/include 
     12LUALIB= $(PREFIX)/lib 
     13LUABIN= $(PREFIX)/bin 
    614 
    715CFLAGS= $(INCS) $(WARN) 
    816WARN= -Wall 
    917INCS= -I$(LUAINC) 
    10 LIBS=-lsyck 
     18LIBS=-lsyck -L$(LUALIB) 
    1119 
    12 MYNAME= syck 
    13 MYLIB= l$(MYNAME) 
     20MYNAME=syck 
     21OBJS= $(MYNAME).o 
     22T= $(MYNAME).so 
    1423 
    15 OBJS= $(MYLIB).o 
     24all:    $T test 
    1625 
    17 T= $(MYLIB).so 
     26install: 
     27        cp -f ./syck.so $(LUA_LIBDIR) 
     28        cp -f ./yaml.lua $(LUA_DIR) 
    1829 
    19 all:    $T 
    20  
    21 test:   $T 
     30uninstall: 
     31        rm -f $(LUA_DIR)/yaml.lua 
     32        rm -f $(LUA_LIBDIR)/syck.so  
     33         
     34test: $t 
    2235        $(LUABIN)/lua test.lua  
     36        @echo "built and tested successfully. run make install to install, or just move the libs manually" 
    2337 
    2438$T:     $(OBJS) 
     
    2640 
    2741clean: 
    28         rm -f $(OBJS) $T core core.* a.out 
     42        rm -f $(OBJS) $T core core.* a.out test.dump 
     43         
     44ready: 
  • trunk/ext/lua/test.lua

    r221 r306  
    88 
    99function testcase.test_load() 
    10         assert_error(function() syck.load() end) 
    11         assert_nil(syck.load("--- ")) 
    12         assert_true(syck.load("--- true")) 
    13         assert_false(syck.load("--- false")) 
    14         assert_equal(10, syck.load("--- 10")) 
    15         local t = syck.load("--- \n- 5\n- 10\n- 15") 
     10        assert_error(function() yaml.load() end) 
     11        assert_nil(yaml.load("--- ")) 
     12        assert_true(yaml.load("--- true")) 
     13        assert_false(yaml.load("--- false")) 
     14        assert_equal(10, yaml.load("--- 10")) 
     15        local t = yaml.load("--- \n- 5\n- 10\n- 15") 
    1616        assert_equal(5, t[1]) 
    1717        assert_equal(10, t[2]) 
    1818        assert_equal(15, t[3]) 
    19         local t = syck.load("--- \n- one\n- two\n- three") 
     19        local t = yaml.load("--- \n- one\n- two\n- three") 
    2020        assert_equal("one", t[1]) 
    2121        assert_equal("two", t[2]) 
    2222        assert_equal("three", t[3]) 
    23         local t = syck.load("--- \nthree: 15\ntwo: 10\none: 5") 
     23        local t = yaml.load("--- \nthree: 15\ntwo: 10\none: 5") 
    2424        assert_equal(5, t.one) 
    2525        assert_equal(10, t.two) 
    2626        assert_equal(15, t.three) 
    27         local t = syck.load("--- \nints: \n  - 1\n  - 2\n  - 3\nmaps: \n  three: 3\n  two: 2\n  one: 1\nstrings: \n  - one\n  - two\n  - three") 
     27        local t = yaml.load("--- \nints: \n  - 1\n  - 2\n  - 3\nmaps: \n  three: 3\n  two: 2\n  one: 1\nstrings: \n  - one\n  - two\n  - three") 
    2828        assert_equal(1, t.ints[1]) 
    2929        assert_equal(2, t.ints[2]) 
     
    3838 
    3939function testcase.test_dump() 
    40         assert_equal("--- \n", syck.dump(nil)) 
    41         assert_equal("--- hey\n", syck.dump("hey")) 
    42         assert_equal("--- 5\n", syck.dump(5)) 
    43         assert_equal("--- true\n", syck.dump(true)) 
    44         assert_equal("--- false\n", syck.dump(false)) 
    45         assert_equal("--- \n- 5\n- 6\n- 7\n", syck.dump({5, 6, 7})) 
     40        assert_equal("--- \n", yaml.dump(nil)) 
     41        assert_equal("--- hey\n", yaml.dump("hey")) 
     42        assert_equal("--- 5\n", yaml.dump(5)) 
     43        assert_equal("--- true\n", yaml.dump(true)) 
     44        assert_equal("--- false\n", yaml.dump(false)) 
     45        assert_equal("--- \n- 5\n- 6\n- 7\n", yaml.dump({5, 6, 7})) 
    4646 
    4747        local str = "--- \n- \n  - 1\n  - 2\n  - 3\n- \n  - 6\n  - 7\n  - 8\n" 
    48         assert_equal(str, syck.dump({{1, 2, 3}, {6, 7, 8}})) 
     48        assert_equal(str, yaml.dump({{1, 2, 3}, {6, 7, 8}})) 
    4949        local str = "--- \n- \n  - 1\n  - 2\n  - 3\n- \n  - one\n  - two\n  - three\n" 
    50         assert_equal(str, syck.dump({{1, 2, 3}, {"one", "two", "three"}})) 
     50        assert_equal(str, yaml.dump({{1, 2, 3}, {"one", "two", "three"}})) 
    5151 
    5252        local str = "--- \none: 1\nthree: 3\ntwo: 2\n" 
    53         assert_equal(str, syck.dump({one=1, two=2, three=3})) 
     53        assert_equal(str, yaml.dump({one=1, two=2, three=3})) 
    5454end 
    5555 
  • trunk/ext/lua/yaml.lua

    r221 r306  
    11-- borrow from lposix 
    22-- 
    3 local function so(x) 
    4         local SOPATH= os.getenv"LUA_SOPATH" or "./" 
    5         assert(loadlib(SOPATH.."l"..x..".so","luaopen_"..x))() 
    6 end 
    7  
    8 so"syck" 
     3require "syck" 
    94 
    105yaml = {}