good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
670bae4c
Commit
670bae4c
authored
6 years ago
by
kiel barry
Committed by
Péter Szilágyi
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
internal: golint updates for this or self warning (#16634)
parent
4a8d5d2b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
internal/jsre/jsre.go
+27
-27
27 additions, 27 deletions
internal/jsre/jsre.go
with
27 additions
and
27 deletions
internal/jsre/jsre.go
+
27
−
27
View file @
670bae4c
...
...
@@ -102,8 +102,8 @@ func randomSource() *rand.Rand {
// call the functions of the otto vm directly to circumvent the queue. These
// functions should be used if and only if running a routine that was already
// called from JS through an RPC call.
func
(
self
*
JSRE
)
runEventLoop
()
{
defer
close
(
self
.
closed
)
func
(
re
*
JSRE
)
runEventLoop
()
{
defer
close
(
re
.
closed
)
vm
:=
otto
.
New
()
r
:=
randomSource
()
...
...
@@ -202,14 +202,14 @@ loop:
break
loop
}
}
case
req
:=
<-
self
.
evalQueue
:
case
req
:=
<-
re
.
evalQueue
:
// run the code, send the result back
req
.
fn
(
vm
)
close
(
req
.
done
)
if
waitForCallbacks
&&
(
len
(
registry
)
==
0
)
{
break
loop
}
case
waitForCallbacks
=
<-
self
.
stopEventLoop
:
case
waitForCallbacks
=
<-
re
.
stopEventLoop
:
if
!
waitForCallbacks
||
(
len
(
registry
)
==
0
)
{
break
loop
}
...
...
@@ -223,31 +223,31 @@ loop:
}
// Do executes the given function on the JS event loop.
func
(
self
*
JSRE
)
Do
(
fn
func
(
*
otto
.
Otto
))
{
func
(
re
*
JSRE
)
Do
(
fn
func
(
*
otto
.
Otto
))
{
done
:=
make
(
chan
bool
)
req
:=
&
evalReq
{
fn
,
done
}
self
.
evalQueue
<-
req
re
.
evalQueue
<-
req
<-
done
}
// stops the event loop before exit, optionally waits for all timers to expire
func
(
self
*
JSRE
)
Stop
(
waitForCallbacks
bool
)
{
func
(
re
*
JSRE
)
Stop
(
waitForCallbacks
bool
)
{
select
{
case
<-
self
.
closed
:
case
self
.
stopEventLoop
<-
waitForCallbacks
:
<-
self
.
closed
case
<-
re
.
closed
:
case
re
.
stopEventLoop
<-
waitForCallbacks
:
<-
re
.
closed
}
}
// Exec(file) loads and runs the contents of a file
// if a relative path is given, the jsre's assetPath is used
func
(
self
*
JSRE
)
Exec
(
file
string
)
error
{
code
,
err
:=
ioutil
.
ReadFile
(
common
.
AbsolutePath
(
self
.
assetPath
,
file
))
func
(
re
*
JSRE
)
Exec
(
file
string
)
error
{
code
,
err
:=
ioutil
.
ReadFile
(
common
.
AbsolutePath
(
re
.
assetPath
,
file
))
if
err
!=
nil
{
return
err
}
var
script
*
otto
.
Script
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
script
,
err
=
vm
.
Compile
(
file
,
code
)
if
err
!=
nil
{
return
...
...
@@ -259,36 +259,36 @@ func (self *JSRE) Exec(file string) error {
// Bind assigns value v to a variable in the JS environment
// This method is deprecated, use Set.
func
(
self
*
JSRE
)
Bind
(
name
string
,
v
interface
{})
error
{
return
self
.
Set
(
name
,
v
)
func
(
re
*
JSRE
)
Bind
(
name
string
,
v
interface
{})
error
{
return
re
.
Set
(
name
,
v
)
}
// Run runs a piece of JS code.
func
(
self
*
JSRE
)
Run
(
code
string
)
(
v
otto
.
Value
,
err
error
)
{
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Run
(
code
)
})
func
(
re
*
JSRE
)
Run
(
code
string
)
(
v
otto
.
Value
,
err
error
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Run
(
code
)
})
return
v
,
err
}
// Get returns the value of a variable in the JS environment.
func
(
self
*
JSRE
)
Get
(
ns
string
)
(
v
otto
.
Value
,
err
error
)
{
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Get
(
ns
)
})
func
(
re
*
JSRE
)
Get
(
ns
string
)
(
v
otto
.
Value
,
err
error
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
v
,
err
=
vm
.
Get
(
ns
)
})
return
v
,
err
}
// Set assigns value v to a variable in the JS environment.
func
(
self
*
JSRE
)
Set
(
ns
string
,
v
interface
{})
(
err
error
)
{
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
err
=
vm
.
Set
(
ns
,
v
)
})
func
(
re
*
JSRE
)
Set
(
ns
string
,
v
interface
{})
(
err
error
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
err
=
vm
.
Set
(
ns
,
v
)
})
return
err
}
// loadScript executes a JS script from inside the currently executing JS code.
func
(
self
*
JSRE
)
loadScript
(
call
otto
.
FunctionCall
)
otto
.
Value
{
func
(
re
*
JSRE
)
loadScript
(
call
otto
.
FunctionCall
)
otto
.
Value
{
file
,
err
:=
call
.
Argument
(
0
)
.
ToString
()
if
err
!=
nil
{
// TODO: throw exception
return
otto
.
FalseValue
()
}
file
=
common
.
AbsolutePath
(
self
.
assetPath
,
file
)
file
=
common
.
AbsolutePath
(
re
.
assetPath
,
file
)
source
,
err
:=
ioutil
.
ReadFile
(
file
)
if
err
!=
nil
{
// TODO: throw exception
...
...
@@ -305,10 +305,10 @@ func (self *JSRE) loadScript(call otto.FunctionCall) otto.Value {
// Evaluate executes code and pretty prints the result to the specified output
// stream.
func
(
self
*
JSRE
)
Evaluate
(
code
string
,
w
io
.
Writer
)
error
{
func
(
re
*
JSRE
)
Evaluate
(
code
string
,
w
io
.
Writer
)
error
{
var
fail
error
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
val
,
err
:=
vm
.
Run
(
code
)
if
err
!=
nil
{
prettyError
(
vm
,
err
,
w
)
...
...
@@ -321,8 +321,8 @@ func (self *JSRE) Evaluate(code string, w io.Writer) error {
}
// Compile compiles and then runs a piece of JS code.
func
(
self
*
JSRE
)
Compile
(
filename
string
,
src
interface
{})
(
err
error
)
{
self
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
compileAndRun
(
vm
,
filename
,
src
)
})
func
(
re
*
JSRE
)
Compile
(
filename
string
,
src
interface
{})
(
err
error
)
{
re
.
Do
(
func
(
vm
*
otto
.
Otto
)
{
_
,
err
=
compileAndRun
(
vm
,
filename
,
src
)
})
return
err
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment