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
Hide 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,
return
JS_UNDEFINED
;
}
static
JSValue
readDroneDataStr
(
JSContext
*
ctx
,
StrQueue
*
pQueue
)
static
JSValue
readDroneDataStr
(
JSContext
*
ctx
,
StrQueue
*
pQueue
,
bool
keepAtLeastAnElement
)
{
JSValue
res
;
struct
strNode
*
current
;
...
...
@@ -273,8 +273,15 @@ static JSValue readDroneDataStr(JSContext *ctx, StrQueue *pQueue)
current
=
pQueue
->
head
;
if
(
current
!=
NULL
)
{
res
=
JS_NewString
(
ctx
,
current
->
str
);
pQueue
->
head
=
current
->
next
==
NULL
?
(
pQueue
->
tail
=
NULL
)
:
current
->
next
;
delete_str_node
(
current
);
if
(
current
->
next
!=
NULL
)
{
pQueue
->
head
=
current
->
next
;
delete_str_node
(
current
);
}
else
{
if
(
!
keepAtLeastAnElement
)
{
pQueue
->
head
=
(
pQueue
->
tail
=
NULL
);
delete_str_node
(
current
);
}
}
}
else
{
res
=
JS_NewString
(
ctx
,
""
);
}
...
...
@@ -304,9 +311,9 @@ static JSValue js_drone_get(JSContext *ctx, JSValueConst thisVal, int magic)
case
7
:
return
JS_NewFloat64
(
ctx
,
s
->
climbRate
);
case
8
:
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveMessageQueue
));
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveMessageQueue
)
,
true
);
case
9
:
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveLogQueue
));
return
readDroneDataStr
(
ctx
,
&
(
s
->
receiveLogQueue
)
,
false
);
case
10
:
return
JS_NewInt64
(
ctx
,
s
->
timestamp
);
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