Skip to content

Commit

Permalink
Merge pull request #1610 from xushiwei/q
Browse files Browse the repository at this point in the history
newGmx bugfix: use classNameAndExt
  • Loading branch information
xushiwei committed Jan 7, 2024
2 parents 1365ace + b73f6c8 commit 51de96d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 9 additions & 0 deletions cl/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ func TestGmxSettings(t *testing.T) {
if e := err.Error(); e != `github.com/goplus/gop/cl/internal/libc.Game not found` {
t.Fatal("newGmx:", e)
}

defer func() {
if e := recover(); e == nil {
t.Fatal("TestGmxSettings failed: no error?")
}
}()
newGmx(nil, pkg, "main.abcx", &ast.File{IsProj: true}, &Config{
LookupClass: lookupClass,
})
}

func TestSpxLookup(t *testing.T) {
Expand Down
12 changes: 4 additions & 8 deletions cl/classfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,20 +70,16 @@ func classNameAndExt(file string) (name, ext string) {
}

func newGmx(ctx *pkgCtx, pkg *gox.Package, file string, f *ast.File, conf *Config) *gmxSettings {
fname := filepath.Base(file)
ext := modfile.ClassExt(fname)
tname, ext := classNameAndExt(file)
gt, ok := conf.LookupClass(ext)
if !ok {
panic("TODO: class not found")
}
var name string
if f.IsProj {
_, name = filepath.Split(file)
if idx := strings.Index(name, "."); idx > 0 {
name = name[:idx]
if name == "main" {
name = gt.Class
}
name = tname
if name == "main" {
name = gt.Class
}
}
pkgPaths := gt.PkgPaths
Expand Down

0 comments on commit 51de96d

Please sign in to comment.