Skip to content

Commit

Permalink
Merge branch 'develop' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
gentee committed Nov 12, 2020
2 parents ca4930c + 551489f commit 3d2290b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 41 deletions.
41 changes: 21 additions & 20 deletions assets.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.15
require (
github.com/alecthomas/chroma v0.8.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/gentee/gentee v1.16.0
github.com/gentee/gentee v1.17.0
github.com/gorilla/websocket v1.4.2
github.com/kataras/golog v0.1.5
github.com/labstack/echo/v4 v4.1.17
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ github.com/gentee/gentee v1.15.1 h1:S9p7S9ZM/1cUxtvfar8olPz6ZoL0/CEbbqPCy8M4G8E=
github.com/gentee/gentee v1.15.1/go.mod h1:XeyqrgfEuwpfJM/YO2A1uUKbnqUFKnc0qcq6NOX1ggk=
github.com/gentee/gentee v1.16.0 h1:qhif/bGyJrOaAqeGaP8e8969otOmgfXSYZ3msw+Fmqs=
github.com/gentee/gentee v1.16.0/go.mod h1:XeyqrgfEuwpfJM/YO2A1uUKbnqUFKnc0qcq6NOX1ggk=
github.com/gentee/gentee v1.17.0 h1:NLTouUGQM2Rs1eeDHCl9m+GHjUbYMfje3WcKY+lvhKA=
github.com/gentee/gentee v1.17.0/go.mod h1:XeyqrgfEuwpfJM/YO2A1uUKbnqUFKnc0qcq6NOX1ggk=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
Expand Down
11 changes: 7 additions & 4 deletions script/embedded.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ var (
{Prototype: `Condition(str,str) bool`, Object: Condition},
{Prototype: `File(str) str`, Object: FileLoad},
{Prototype: `Form(str)`, Object: Form},
{Prototype: `IsVarObj(str) bool`, Object: IsVarObj},
{Prototype: `IsVar(str) bool`, Object: IsVar},
{Prototype: `LogOutput(int,str)`, Object: LogOutput},
{Prototype: `Macro(str) str`, Object: Macro},
Expand All @@ -137,7 +138,6 @@ var (
{Prototype: `GetVarObj(str) obj`, Object: GetVarObj},
// For gentee
{Prototype: `YamlToMap(str) map`, Object: YamlToMap},
{Prototype: `FindFirstRegExp(str,str) arr.str`, Object: FindFirstRegExpºStrStr},
}
)

Expand Down Expand Up @@ -273,7 +273,7 @@ func FileLoad(rt *vm.Runtime, fname string) (ret string, err error) {
}

func GetVar(name string) (ret string, err error) {
if IsVar(name) {
if IsVar(name) != 0 {
id := len(dataScript.Vars) - 1
ret, err = Macro(dataScript.Vars[id][name])
}
Expand Down Expand Up @@ -330,11 +330,14 @@ func InitCmd(name string, pars ...interface{}) bool {
return true
}

func IsVar(key string) bool {
func IsVar(key string) int64 {
dataScript.Mutex.Lock()
defer dataScript.Mutex.Unlock()
_, ret := dataScript.Vars[len(dataScript.Vars)-1][key]
return ret
if ret {
return 1
}
return 0
}

func loadForm(data string, form *[]map[string]interface{}) error {
Expand Down
16 changes: 0 additions & 16 deletions script/gentee.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package script

import (
"regexp"

"github.com/gentee/gentee"
"github.com/gentee/gentee/core"
"gopkg.in/yaml.v2"
Expand All @@ -27,17 +25,3 @@ func YamlToMap(in string) (*core.Map, error) {
}
return ret.(*core.Map), nil
}

// FindFirstRegExpºStrStr returns an array of the first successive matches of the expression
func FindFirstRegExpºStrStr(src, rePattern string) (*core.Array, error) {
re, err := regexp.Compile(rePattern)
if err != nil {
return nil, err
}
list := re.FindStringSubmatch(src)
out := core.NewArray()
for _, sub := range list {
out.Data = append(out.Data, sub)
}
return out, nil
}
8 changes: 8 additions & 0 deletions script/varobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ func GetVarObj(name string) (*core.Obj, error) {
return val.(*core.Obj), nil
}

func IsVarObj(name string) int64 {
_, ok := dataScript.ObjVars[len(dataScript.ObjVars)-1].Load(name)
if ok {
return 1
}
return 0
}

func setRawVarObj(shift int, name string, value *core.Obj) error {
off := len(dataScript.ObjVars) - 1 - shift
if off < 0 {
Expand Down

0 comments on commit 3d2290b

Please sign in to comment.