Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make plugin more easier to maintain #83

Merged
merged 33 commits into from
Mar 11, 2024

Conversation

bytemain
Copy link
Member

@bytemain bytemain commented Mar 6, 2024

here I create a new module called: luai(lua interface)

we can define many thing with the lua world in this module.

the thing I first made is a transformer, which can transform golang struct to lua table(most cases, but you still can use it transform golang int to lua number)

this bring another benifit, the data structure now is defined in golang, so we even can change our plugin engine to javascript(even simpler is, just encode to json)

and I try made a new struct called LuaVM, which will simplify our opreations when interact with the lua world

@bytemain
Copy link
Member Author

bytemain commented Mar 6, 2024

though the encode and decode file is so complex, but we can add many test cases to ensure its correctness, and we can contribute this encode module into gopher-lua community.

@bytemain
Copy link
Member Author

bytemain commented Mar 6, 2024

some code in decode.go is copied from go source

https://cs.opensource.google/go/go/+/master:src/encoding/json/decode.go;l=612;drc=5e387b2feee87b7d8d5cc81e7cb08603b3e9cd6a;bpv=0;bpt=1

later I will see should we add some license for that or I will remove most of them and write by my own

@aooohan
Copy link
Member

aooohan commented Mar 6, 2024

Amazing, I will start reviewing this change tomorrow, what a big change. Hahaha

@bytemain bytemain force-pushed the refactor/make-plugin-easy-to-maintain branch from a695f47 to 4dc97fe Compare March 6, 2024 10:47
@bytemain bytemain marked this pull request as ready for review March 7, 2024 06:01
@bytemain bytemain force-pushed the refactor/make-plugin-easy-to-maintain branch from 31598e9 to 92e7071 Compare March 7, 2024 06:12
@@ -66,6 +68,19 @@ func newCmd() *cmd {
_, _ = fmt.Fprintln(ctx.App.Writer, command.Name)
}
}

debugFlags := &cli.BoolFlag{
Name: "debug",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only worked when this flag before any subcommand,

related: #88

@bytemain bytemain force-pushed the refactor/make-plugin-easy-to-maintain branch from dc5a407 to 7061f28 Compare March 8, 2024 09:38
internal/plugin.go Outdated Show resolved Hide resolved
Copy link
Member

@aooohan aooohan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bytemain I think this refactoring has been very complete for plugin.

However, the solution to #26 is not complete enough, and there is too little log information. Therefore, this change is not considered to be initiated to solve #26, It is simply a refactoring of the plug-in.

In addition, we also need to add to the documentation the usage of the --debug parameter.

@aooohan aooohan merged commit 982ef93 into main Mar 11, 2024
1 check passed
@bytemain
Copy link
Member Author

Yes, I know that, this pr just add a basic logger, in order to see the debug info when I write the encoding code.

@aooohan aooohan deleted the refactor/make-plugin-easy-to-maintain branch March 11, 2024 03:33
ShizheChang pushed a commit to ShizheChang/vfox that referenced this pull request Mar 14, 2024
* refactor: add lua vm struct

* feat: support struct marshal

* feat: add more ctx

* fix: encoding tag map error

* feat: add logger

* feat: add debug flag

* fix: fix decode in mixed struct

* fix: unmarshal to interface is not work

* feat: ctx use marshal

* feat: unmarshal hook result

* ci: update test cases

* test: streamline encoding unit test

* chore: remove print

* test: add more testcases

* chore: revert hook name enum

* chore: add license

* chore: update log message

* refactor: add plugin module

* refactor: add a vm file

* chore: update logger

* chore: add license

* feat: support marshal nil

* fix: preinstall should work

* fix: lua checksum

* chore: update code

* refactor: unmarshal plugin info

* chore: some modifications

* mod: remove debug log in encoding func

* mod: Optimize function calls

* bugfix

* mod

---------

Co-authored-by: lihan <lihan@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants