forked from rogchap/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.
add module and base of create isolate
- Loading branch information
Showing
6 changed files
with
94 additions
and
5 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,3 @@ | ||
module rogchap.com/v8go | ||
|
||
go 1.12 |
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,30 @@ | ||
package v8go | ||
|
||
// #include "v8go.h" | ||
import "C" | ||
|
||
import ( | ||
"runtime" | ||
"sync" | ||
) | ||
|
||
var v8once sync.Once | ||
|
||
type Isolate struct { | ||
ptr C.IsolatePtr | ||
} | ||
|
||
func (i *Isolate) release() { | ||
C.IsolateRelease(i.ptr) | ||
i.ptr = nil | ||
runtime.SetFinalizer(i, nil) | ||
} | ||
|
||
func NewIsolate() *Isolate { | ||
v8once.Do(func() { | ||
C.Init() | ||
}) | ||
iso := &Isolate{C.NewIsolate()} | ||
runtime.SetFinalizer(iso, (*Isolate).release) | ||
return iso | ||
} |
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,9 @@ | ||
|
||
#include "v8go.h" | ||
|
||
int main(int argc, char* argv[]) { | ||
|
||
NewIsolate(); | ||
Version(); | ||
return 0; | ||
} |
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 |
---|---|---|
|
@@ -7,5 +7,5 @@ package v8go | |
import "C" | ||
|
||
func Version() string { | ||
return C.GoString(C.version()) | ||
return C.GoString(C.Version()) | ||
} |
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