forked from YaoApp/v8go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup of context and run script apis
- Loading branch information
Showing
8 changed files
with
127 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
def Settings( **kwargs ): | ||
return { | ||
'flags': [ '-fno-rtti', '-fpic', '-std=c++11', '-Ideps/include', '-pthread', '-lv8', '-Ldeps/darwin-x86_64' ], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package v8go | ||
|
||
// #import "v8go.h" | ||
import "C" | ||
import "runtime" | ||
|
||
type Context struct { | ||
ptr C.ContextPtr | ||
} | ||
|
||
func NewContext(iso *Isolate) *Context { | ||
ctx := &Context{C.NewContext(iso.ptr)} | ||
runtime.SetFinalizer(ctx, (*Context).release) | ||
return ctx | ||
} | ||
|
||
func (c *Context) RunScript() { | ||
C.RunScript(c.ptr, C.CString("source"), C.CString("origin")) | ||
} | ||
|
||
func (c *Context) release() { | ||
//TODO dispose of object in C++A | ||
c.ptr = nil | ||
runtime.SetFinalizer(c, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
package v8go | ||
package v8go_test | ||
|
||
import "testing" | ||
import ( | ||
"regexp" | ||
"testing" | ||
|
||
"rogchap.com/v8go" | ||
) | ||
|
||
func TestVersion(t *testing.T) { | ||
print(Version()) | ||
t.Fatal("error") | ||
t.Parallel() | ||
rgx := regexp.MustCompile(`^\d+\.\d+\.\d+\.\d+-v8go$`) | ||
v := v8go.Version() | ||
if !rgx.MatchString(v) { | ||
t.Errorf("version string is in the incorrect format: %s", v) | ||
} | ||
} | ||
|
||
func TestRunScript(t *testing.T) { | ||
t.Parallel() | ||
iso := v8go.NewIsolate() | ||
ctx := v8go.NewContext(iso) | ||
ctx.RunScript() | ||
t.Error("See output") | ||
} |