Commit c0a2debb authored by Chris Molozian's avatar Chris Molozian
Browse files

Update 'gopher-lua' dependency.

parent cb2d42da
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@
  version = "v1.1.3"

[[projects]]
  digest = "1:c5918689b7e187382cc1066bf0260de54ba9d1b323105f46ed2551d2fb4a17c7"
  digest = "1:87efccabe52f98f3dcefab803efba00d8b961cf942c1472a7db560eb64c125d5"
  name = "github.com/yuin/gopher-lua"
  packages = [
    ".",
@@ -406,7 +406,7 @@
    "pm",
  ]
  pruneopts = ""
  revision = "46796da1b0b4794e1e341883a399f12cc7574b55"
  revision = "db9ae37725ec65ae634769088627d2d118faf06a"

[[projects]]
  digest = "1:eb3da47361162f0ad991ddf391e6dc03e23889201d76046e2917687b84977aee"
+1 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@

[[constraint]]
  name = "github.com/yuin/gopher-lua"
  revision = "46796da1b0b4794e1e341883a399f12cc7574b55"
  revision = "db9ae37725ec65ae634769088627d2d118faf06a"

[[constraint]]
  name = "github.com/gorhill/cronexpr"
+5 −5
Original line number Diff line number Diff line
language: go

go:
  - "1.8"
  - "1.9"
  - "1.10"
  - "1.9.x"
  - "1.10.x"
  - "1.11.x"

before_install:
  - go get github.com/axw/gocov/gocov
  - go get github.com/yuin/goveralls
  - go get github.com/mattn/goveralls
  - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
install:
  - go get -u -v $(go list -f '{{join .Imports "\n"}}{{"\n"}}{{join .TestImports "\n"}}' ./... | sort | uniq | grep -v gopher-lua)
script:
  - $HOME/gopath/bin/goveralls -service=travis-ci -vetoff
  - $HOME/gopath/bin/goveralls -service=travis-ci
+56 −4
Original line number Diff line number Diff line

===============================================================================
GopherLua: VM and compiler for Lua in Go.
===============================================================================
@@ -55,7 +56,7 @@ Installation

   go get github.com/yuin/gopher-lua

GopherLua supports >= Go1.8.
GopherLua supports >= Go1.9.

----------------------------------------------------------------
Usage
@@ -524,6 +525,54 @@ With coroutines
    9227465
    0.01s user 0.01s system 0% cpu 5.306 total

+++++++++++++++++++++++++++++++++++++++++
Sharing Lua byte code between LStates
+++++++++++++++++++++++++++++++++++++++++
Calling ``DoFile`` will load a Lua script, compile it to byte code and run the byte code in a ``LState``.

If you have multiple ``LStates`` which are all required to run the same script, you can share the byte code between them,
which will save on memory.
Sharing byte code is safe as it is read only and cannot be altered by lua scripts.

.. code-block:: go

    // CompileLua reads the passed lua file from disk and compiles it.
    func CompileLua(filePath string) (*lua.FunctionProto, error) {
        file, err := os.Open(filePath)
        defer file.Close()
        if err != nil {
            return nil, err
        }
        reader := bufio.NewReader(file)
        chunk, err := parse.Parse(reader, filePath)
        if err != nil {
            return nil, err
        }
        proto, err := lua.Compile(chunk, filePath)
        if err != nil {
            return nil, err
        }
        return proto, nil
    }

    // DoCompiledFile takes a FunctionProto, as returned by CompileLua, and runs it in the LState. It is equivalent
    // to calling DoFile on the LState with the original source file.
    func DoCompiledFile(L *lua.LState, proto *lua.FunctionProto) error {
        lfunc := L.NewFunctionFromProto(proto)
        L.Push(lfunc)
        return L.PCall(0, lua.MultRet, nil)
    }

    // Example shows how to share the compiled byte code from a lua script between multiple VMs.
    func Example() {
        codeToShare := CompileLua("mylua.lua")
        a := lua.NewState()
        b := lua.NewState()
        c := lua.NewState()
        DoCompiledFile(a, codeToShare)
        DoCompiledFile(b, codeToShare)
        DoCompiledFile(c, codeToShare)
    }

+++++++++++++++++++++++++++++++++++++++++
Goroutines
@@ -772,7 +821,7 @@ See `Guidlines for contributors <https://github.com/yuin/gopher-lua/tree/master/
Libraries for GopherLua
----------------------------------------------------------------

- `gopher-luar <https://github.com/layeh/gopher-luar>`_ : Custom type reflection for gopher-lua
- `gopher-luar <https://github.com/layeh/gopher-luar>`_ : Simplifies data passing to and from gopher-lua
- `gluamapper <https://github.com/yuin/gluamapper>`_ : Mapping a Lua table to a Go struct
- `gluare <https://github.com/yuin/gluare>`_ : Regular expressions for gopher-lua
- `gluahttp <https://github.com/cjoudrey/gluahttp>`_ : HTTP request module for gopher-lua
@@ -786,7 +835,10 @@ Libraries for GopherLua
- `gluabit32 <https://github.com/BixData/gluabit32>`_ : A native Go implementation of bit32 for the GopherLua VM.
- `gmoonscript <https://github.com/rucuriousyet/gmoonscript>`_ : Moonscript Compiler for the Gopher Lua VM
- `loguago <https://github.com/rucuriousyet/loguago>`_ : Zerolog wrapper for Gopher-Lua

- `gluacrypto <https://github.com/tengattack/gluacrypto>`_ : A native Go implementation of crypto library for the GopherLua VM.
- `gluasql <https://github.com/tengattack/gluasql>`_ : A native Go implementation of SQL client for the GopherLua VM.
- `purr <https://github.com/leyafo/purr>`_ : A http mock testing tool.
- `vadv/gopher-lua-libs <https://github.com/vadv/gopher-lua-libs>`_ : Some usefull libraries for GopherLua VM.
----------------------------------------------------------------
Donation
----------------------------------------------------------------
+26 −0
Original line number Diff line number Diff line
@@ -189,3 +189,29 @@ local expected = 1
local result = math.random(1)

assert(result == expected)

-- issue 202
local t = {}
ok, res = pcall(table.remove, t)
if not ok or not res then
    table.insert(t, {})
else
    assert(false)
end
ok, res = pcall(table.remove, t)
ok, res = pcall(table.remove, t)
assert(not ok or not res)

-- issue 204
local ok, message = pcall(nil)
assert(not ok)
assert(message == "attempt to call a nil value")

local ok, message = pcall(1)
assert(not ok)
assert(message == "attempt to call a number value")

ok, message = pcall(function()
  pcall()
end)
assert(not ok and string.find(message, "bad argument #1 to pcall", 1, true))
Loading