Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qjs-wrapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
qjs-wrapper
Commits
b13c2c85
Commit
b13c2c85
authored
Apr 25, 2024
by
Léo-Paul Géneau
👾
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keep memory of the last string in the queue
parent
75c4c3e1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
qjs_wrapper.c
qjs_wrapper.c
+12
-5
No files found.
qjs_wrapper.c
View file @
b13c2c85
...
@@ -265,7 +265,7 @@ static JSValue js_drone_init(JSContext *ctx, JSValueConst thisVal,
...
@@ -265,7 +265,7 @@ static JSValue js_drone_init(JSContext *ctx, JSValueConst thisVal,
return
JS_UNDEFINED
;
return
JS_UNDEFINED
;
}
}
static
JSValue
readDroneDataStr
(
JSContext
*
ctx
,
StrQueue
*
pQueue
)
static
JSValue
readDroneDataStr
(
JSContext
*
ctx
,
StrQueue
*
pQueue
,
bool
keepAtLeastAnElement
)
{
{
JSValue
res
;
JSValue
res
;
struct
strNode
*
current
;
struct
strNode
*
current
;
...
@@ -273,8 +273,15 @@ static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue)
...
@@ -273,8 +273,15 @@ static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue)
current
=
pQueue
->
head
;
current
=
pQueue
->
head
;
if
(
current
!=
NULL
)
{
if
(
current
!=
NULL
)
{
res
=
JS_NewString
(
ctx
,
current
->
str
);
res
=
JS_NewString
(
ctx
,
current
->
str
);
pQueue
->
head
=
current
->
next
==
NULL
?
(
pQueue
->
tail
=
NULL
)
:
current
->
next
;
if
(
current
->
next
!=
NULL
)
{
pQueue
->
head
=
current
->
next
;
delete_str_node
(
current
);
}
else
{
if
(
!
keepAtLeastAnElement
)
{
pQueue
->
head
=
(
pQueue
->
tail
=
NULL
);
delete_str_node
(
current
);
delete_str_node
(
current
);
}
}
}
else
{
}
else
{
res
=
JS_NewString
(
ctx
,
""
);
res
=
JS_NewString
(
ctx
,
""
);
}
}
...
@@ -304,9 +311,9 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic)
...
@@ -304,9 +311,9 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic)
case
7
:
case
7
:
return
JS_NewFloat64
(
ctx
,
s
->
climbRate
);
return
JS_NewFloat64
(
ctx
,
s
->
climbRate
);
case
8
:
case
8
:
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveMessageQueue
));
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveMessageQueue
)
,
true
);
case
9
:
case
9
:
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveLogQueue
));
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveLogQueue
)
,
false
);
case
10
:
case
10
:
return
JS_NewInt64
(
ctx
,
s
->
timestamp
);
return
JS_NewInt64
(
ctx
,
s
->
timestamp
);
default:
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment