Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
pub
frama-c
Commits
36159251
Commit
36159251
authored
4 years ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
[ivette] Rework doc for frama-c/states module.
parent
e1553a45
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ivette/src/frama-c/states.ts
+30
-36
30 additions, 36 deletions
ivette/src/frama-c/states.ts
with
30 additions
and
36 deletions
ivette/src/frama-c/states.ts
+
30
−
36
View file @
36159251
...
@@ -3,10 +3,9 @@
...
@@ -3,10 +3,9 @@
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
/**
@packageDocumentation
* Manage the current Frama-C project and projectified state values.
@module frama-c/states
* @packageDocumentation
@decsription
* @module frama-c/states
Manage the current Frama-C project and projectified state values.
*/
*/
import
React
from
'
react
'
;
import
React
from
'
react
'
;
...
@@ -59,7 +58,8 @@ Server.onShutdown(() => {
...
@@ -59,7 +58,8 @@ Server.onShutdown(() => {
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
/**
Current Project (Custom React Hook).
* Current Project (Custom React Hook).
* @return The current project.
*/
*/
export
function
useProject
()
{
export
function
useProject
()
{
Dome
.
useUpdate
(
PROJECT
);
Dome
.
useUpdate
(
PROJECT
);
...
@@ -67,10 +67,12 @@ export function useProject() {
...
@@ -67,10 +67,12 @@ export function useProject() {
}
}
/**
/**
Update Current Project.
* Update Current Project.
Make all states switching to their projectified value.
*
Emits `PROJECT`.
* Make all states switching to their projectified value.
@param project - the project identifier
*
* Emits `PROJECT`.
* @param project The project identifier.
*/
*/
export
async
function
setProject
(
project
:
string
)
{
export
async
function
setProject
(
project
:
string
)
{
if
(
Server
.
isRunning
())
{
if
(
Server
.
isRunning
())
{
...
@@ -101,12 +103,12 @@ export interface UseRequestOptions<A> {
...
@@ -101,12 +103,12 @@ export interface UseRequestOptions<A> {
}
}
/**
/**
Cached GET request (Custom React Hook).
*
Cached GET request (Custom React Hook).
*
Sends the specified GET request and returns its result.
*
Sends the specified GET request and returns its result.
The request is send
The request is send
asynchronously and cached until any change.
*
asynchronously and cached until any change.
*
Null values in options mean that the last obtained value is kept.
*
Null values in options mean that the last obtained value is kept.
*/
*/
export
function
useRequest
<
In
,
Out
>
(
export
function
useRequest
<
In
,
Out
>
(
rq
:
Server
.
GetRequest
<
In
,
Out
>
,
rq
:
Server
.
GetRequest
<
In
,
Out
>
,
...
@@ -251,7 +253,7 @@ class SyncState<A> {
...
@@ -251,7 +253,7 @@ class SyncState<A> {
Dome
.
emit
(
this
.
UPDATE
);
Dome
.
emit
(
this
.
UPDATE
);
}
catch
(
error
)
{
}
catch
(
error
)
{
PP
.
error
(
PP
.
error
(
`Fail to set value of
s
yncState '
${
this
.
handler
.
name
}
'.`
,
`Fail to set value of
S
yncState '
${
this
.
handler
.
name
}
'.`
,
`
${
error
.
toString
()}
`
,
`
${
error
.
toString
()}
`
,
);
);
}
}
...
@@ -265,7 +267,7 @@ class SyncState<A> {
...
@@ -265,7 +267,7 @@ class SyncState<A> {
Dome
.
emit
(
this
.
UPDATE
);
Dome
.
emit
(
this
.
UPDATE
);
}
catch
(
error
)
{
}
catch
(
error
)
{
PP
.
error
(
PP
.
error
(
`Fail to update
s
yncState '
${
this
.
handler
.
name
}
'.`
,
`Fail to update
S
yncState '
${
this
.
handler
.
name
}
'.`
,
`
${
error
.
toString
()}
`
,
`
${
error
.
toString
()}
`
,
);
);
}
}
...
@@ -294,9 +296,7 @@ Server.onShutdown(() => syncStates.clear());
...
@@ -294,9 +296,7 @@ Server.onShutdown(() => syncStates.clear());
// --- Synchronized State Hooks
// --- Synchronized State Hooks
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
/** Synchronization with a (projectified) server state. */
Synchronization with a (projectified) server state.
*/
export
function
useSyncState
<
A
>
(
export
function
useSyncState
<
A
>
(
st
:
State
<
A
>
,
st
:
State
<
A
>
,
):
[
A
|
undefined
,
(
value
:
A
)
=>
void
]
{
):
[
A
|
undefined
,
(
value
:
A
)
=>
void
]
{
...
@@ -306,9 +306,7 @@ export function useSyncState<A>(
...
@@ -306,9 +306,7 @@ export function useSyncState<A>(
return
[
s
.
getValue
(),
s
.
setValue
];
return
[
s
.
getValue
(),
s
.
setValue
];
}
}
/**
/** Synchronization with a (projectified) server value. */
Synchronization with a (projectified) server value.
*/
export
function
useSyncValue
<
A
>
(
va
:
Value
<
A
>
):
A
|
undefined
{
export
function
useSyncValue
<
A
>
(
va
:
Value
<
A
>
):
A
|
undefined
{
const
s
=
getSyncState
(
va
);
const
s
=
getSyncState
(
va
);
Dome
.
useUpdate
(
s
.
update
);
Dome
.
useUpdate
(
s
.
update
);
...
@@ -413,9 +411,7 @@ Server.onShutdown(() => syncArrays.clear());
...
@@ -413,9 +411,7 @@ Server.onShutdown(() => syncArrays.clear());
// --- Synchronized Array Hooks
// --- Synchronized Array Hooks
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
/** Force a Synchronized Array to reload. */
Force a Synchronized Array to Reload.
*/
export
function
reloadArray
<
K
,
A
>
(
arr
:
Array
<
K
,
A
>
)
{
export
function
reloadArray
<
K
,
A
>
(
arr
:
Array
<
K
,
A
>
)
{
getSyncArray
(
arr
).
reload
();
getSyncArray
(
arr
).
reload
();
}
}
...
@@ -423,11 +419,11 @@ export function reloadArray<K, A>(arr: Array<K, A>) {
...
@@ -423,11 +419,11 @@ export function reloadArray<K, A>(arr: Array<K, A>) {
/**
/**
Use Synchronized Array (Custom React Hook).
Use Synchronized Array (Custom React Hook).
Unless specified, the hook makes the component re-render
ing
on every
Unless specified, the hook makes the component re-render on every
update
s
. Disabling this automatic re-render
er
can be an option when
update. Disabling this automatic re-render
ing
can be an option when
you only use
the model to make a table view,
using
the model to make a table view,
which automatically synchronizes on
which automatically synchronizes on
model updates.
model updates.
@param sync
- w
hether the component re-render on updates (default is `true`)
@param sync
W
hether the component re-render
s
on updates (default is `true`)
.
*/
*/
export
function
useSyncArray
<
K
,
A
>
(
export
function
useSyncArray
<
K
,
A
>
(
arr
:
Array
<
K
,
A
>
,
arr
:
Array
<
K
,
A
>
,
...
@@ -475,7 +471,7 @@ export interface HistorySelection {
...
@@ -475,7 +471,7 @@ export interface HistorySelection {
* - `HISTORY_NEXT` jumps to next history location
* - `HISTORY_NEXT` jumps to next history location
* (first in [[nextSelections]]).
* (first in [[nextSelections]]).
*/
*/
type
HistorySelectActions
=
'
HISTORY_PREV
'
|
'
HISTORY_NEXT
'
;
export
type
HistorySelectActions
=
'
HISTORY_PREV
'
|
'
HISTORY_NEXT
'
;
/** A selection of multiple locations. */
/** A selection of multiple locations. */
export
interface
MultipleSelection
{
export
interface
MultipleSelection
{
...
@@ -502,7 +498,7 @@ export interface NthSelect {
...
@@ -502,7 +498,7 @@ export interface NthSelect {
* - `MULTIPLE_PREV` jumps to previous location of the multiple selections.
* - `MULTIPLE_PREV` jumps to previous location of the multiple selections.
* - `MULTIPLE_NEXT` jumps to next location of the multiple selections.
* - `MULTIPLE_NEXT` jumps to next location of the multiple selections.
*/
*/
type
MultipleSelectActions
=
export
type
MultipleSelectActions
=
MultipleSelect
|
NthSelect
MultipleSelect
|
NthSelect
|
'
MULTIPLE_PREV
'
|
'
MULTIPLE_NEXT
'
|
'
MULTIPLE_CLEAR
'
;
|
'
MULTIPLE_PREV
'
|
'
MULTIPLE_NEXT
'
|
'
MULTIPLE_CLEAR
'
;
...
@@ -683,9 +679,7 @@ const emptySelection = {
...
@@ -683,9 +679,7 @@ const emptySelection = {
const
GlobalSelection
=
new
GlobalStates
.
State
<
Selection
>
(
emptySelection
);
const
GlobalSelection
=
new
GlobalStates
.
State
<
Selection
>
(
emptySelection
);
Server
.
onShutdown
(()
=>
GlobalSelection
.
setValue
(
emptySelection
));
Server
.
onShutdown
(()
=>
GlobalSelection
.
setValue
(
emptySelection
));
/**
/** Current selection. */
Current selection.
*/
export
function
useSelection
():
[
Selection
,
(
a
:
SelectionActions
)
=>
void
]
{
export
function
useSelection
():
[
Selection
,
(
a
:
SelectionActions
)
=>
void
]
{
const
[
selection
,
setSelection
]
=
GlobalStates
.
useState
(
GlobalSelection
);
const
[
selection
,
setSelection
]
=
GlobalStates
.
useState
(
GlobalSelection
);
...
...
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