Skip to content

Conversation

cwc
Copy link
Contributor

@cwc cwc commented Feb 12, 2013

Refs: #8, #9

cwc added 2 commits February 11, 2013 20:22
Also execute `go install` after building
Previously arguments being passed to Go via an AddFunc callback were
marshalled to JSON first. This is still the case for values other than
regular expressions or functions.

Regexes are now wrapped in a Go *RegExp, while functions are wrapped in
a custom V8Function object, which supports calling the function in the
originating V8 context with the supplied arguments.
@mattn
Copy link
Owner

mattn commented Feb 13, 2013

Awesome. Thank you.

mattn added a commit that referenced this pull request Feb 13, 2013
Support passing of regex and functions to Go
@mattn mattn merged commit 3bf67f6 into mattn:master Feb 13, 2013
@mattn
Copy link
Owner

mattn commented Feb 13, 2013

It seems that can't compile on windows.

@cwc
Copy link
Contributor Author

cwc commented Feb 13, 2013

Ah, and I don't have a Go environment set up on Windows at the moment. :/

Also I forgot to run the tests. They'll probably be failing as well... 😢

@mattn
Copy link
Owner

mattn commented Feb 13, 2013

Fixed it just now. :)

@mattn
Copy link
Owner

mattn commented Feb 13, 2013

I want to change V8Function.Call accept native go variables, can you change this?

@mattn
Copy link
Owner

mattn commented Feb 13, 2013

    v8ctx.AddFunc("func_call", func(args ...interface{}) interface{} {
        ret, _ := args[0].(v8.V8Function).Call("\"Golang\"")
        return ret
    })

    fmt.Println(v8ctx.MustEval(`
    func_call(function() {
        return "hello " + arguments[0];
    })
    `).(string))

I want to fix:

    v8ctx.AddFunc("func_call", func(args ...interface{}) interface{} {
        ret, _ := args[0].(v8.V8Function).Call("Golang", 1, 2 3)
        return ret
    })

    fmt.Println(v8ctx.MustEval(`
    func_call(function() {
        return "hello " + arguments[0] + (arguments[1] + arguments[2] + arguments[3]);
    })
    `).(string))

@cwc
Copy link
Contributor Author

cwc commented Feb 13, 2013

Sure, I should be able to look at it tomorrow.

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.

2 participants