Remove mutability

Update bindgen
This commit is contained in:
zarik5 2021-04-06 13:52:24 +02:00
parent 97204dafd9
commit 8e0d08e8e8
13 changed files with 61 additions and 65 deletions

22
Cargo.lock generated
View File

@ -91,7 +91,7 @@ dependencies = [
"alvr_common",
"android_logger",
"bincode",
"bindgen 0.57.0",
"bindgen 0.58.1",
"bytes",
"cc",
"cpal",
@ -116,7 +116,7 @@ version = "15.1.1"
dependencies = [
"backtrace",
"bincode",
"bindgen 0.57.0",
"bindgen 0.58.1",
"bytes",
"cc",
"cpal",
@ -173,7 +173,7 @@ dependencies = [
"alcro",
"alvr_common",
"bincode",
"bindgen 0.57.0",
"bindgen 0.58.1",
"bytes",
"cc",
"chrono",
@ -400,14 +400,14 @@ dependencies = [
"quote",
"regex",
"rustc-hash",
"shlex",
"shlex 0.1.1",
]
[[package]]
name = "bindgen"
version = "0.57.0"
version = "0.58.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d"
checksum = "0f8523b410d7187a43085e7e064416ea32ded16bd0a4e6fc025e21616d01258f"
dependencies = [
"bitflags",
"cexpr",
@ -422,7 +422,7 @@ dependencies = [
"quote",
"regex",
"rustc-hash",
"shlex",
"shlex 1.0.0",
"which",
]
@ -2729,7 +2729,7 @@ dependencies = [
name = "openvr-driver-sys"
version = "0.1.0+1.16.8"
dependencies = [
"bindgen 0.57.0",
"bindgen 0.58.1",
"cc",
"regex",
]
@ -3556,6 +3556,12 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "shlex"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42a568c8f2cd051a4d283bd6eb0343ac214c1b0f1ac19f93e1175b2dee38c73d"
[[package]]
name = "signal-hook-registry"
version = "1.3.0"

View File

@ -37,6 +37,6 @@ android_logger = "0.10"
oboe = "0.4" # Note: cannot use feature "java-interface" to query audio info
[build-dependencies]
bindgen = "0.57"
bindgen = "0.58"
cc = { version = "1", features = ["parallel"] }
walkdir = "2"

View File

@ -70,5 +70,5 @@ wio = "0.2"
gfx-backend-vulkan = "=0.6.5"
[build-dependencies]
bindgen = "0.57"
bindgen = "0.58"
cc = { version = "1", features = ["parallel"] }

View File

@ -163,9 +163,7 @@ export function Dashboard({ settingsSchema }: { settingsSchema: SettingsSchema }
let language = extraSettings["language"] as string
function changeLanguage(modalCloseHandle: () => void) {
extraSettings["language"] = language
applySessionSettings(session.session_settings)
applySessionSettings({ extra: { language } })
modalCloseHandle()
}

View File

@ -44,9 +44,7 @@ export function Settings({ schema }: { schema: SettingsSchema }): JSX.Element {
const { session_settings } = useSession()
function setTabContent(tabName: string, content: SessionSettingsSection) {
session_settings[tabName] = content
applySessionSettings(session_settings)
applySessionSettings({ [tabName]: content })
}
return (

View File

@ -9,9 +9,10 @@ export function Array(props: {
setSession: (session: SessionSettingsNode[]) => void
}): JSX.Element {
function setContent(index: number, content: SessionSettingsNode) {
props.session[index] = content
props.setSession(props.session)
// branches at other indices must be imported, because otherwise the server cannot correctly
// work with the resulting session object
const newSession = props.session.map((branch, idx) => (idx === index ? content : branch))
props.setSession(newSession)
}
return (

View File

@ -19,13 +19,11 @@ export function ChoiceControl(props: {
)?.[1]
function setContent(content: SessionSettingsNode) {
props.session[props.session.variant] = content
props.setSession(props.session)
props.setSession({ [props.session.variant]: content, variant: props.session.variant })
}
function setVariant(variantName: string) {
props.session.variant = variantName
props.setSession(props.session)
props.setSession({ variant: variantName })
}
return (
@ -81,8 +79,7 @@ export function ChoiceContainer(props: {
)?.[1]
function setContent(content: SessionSettingsNode) {
props.session[props.session.variant] = content
props.setSession(props.session)
props.setSession({ [props.session.variant]: content } as SessionSettingsChoice)
}
if (maybeContentSchema && (!maybeContentSchema.advanced || showAdvanced)) {

View File

@ -78,12 +78,6 @@ export function HighOrderSetting({ schema }: { schema: SchemaHOS }): JSX.Element
}
}
function setSession(value?: string | boolean) {
apply(session_settings, value)
applySessionSettings(session_settings)
}
function isMatching(value?: string | boolean): boolean {
const currentSettingsJson = JSON.stringify(session_settings)
@ -96,6 +90,12 @@ export function HighOrderSetting({ schema }: { schema: SchemaHOS }): JSX.Element
return JSON.stringify(settings) === currentSettingsJson
}
function setSession(value?: string | boolean) {
const session = JSON.parse(JSON.stringify(session_settings)) as SessionSettingsRoot
apply(session, value)
applySessionSettings(session)
}
switch (schema.data_type.type) {
case "Choice":
return <ChoiceHOS schema={schema.data_type.content} {...{ isMatching, setSession }} />

View File

@ -95,8 +95,7 @@ export function Section(props: {
setSession: (session: SessionSettingsSection) => void
}): JSX.Element {
function setFieldContent(fieldName: string, content: SessionSettingsNode) {
props.session[fieldName] = content
props.setSession(props.session)
props.setSession({ [fieldName]: content })
if (fieldName === "theme") {
window.location.reload()

View File

@ -15,13 +15,11 @@ export function SwitchControl(props: {
const { t } = useTranslation()
function setContent(content: SessionSettingsNode) {
props.session.content = content
props.setSession(props.session)
props.setSession({ enabled: props.session.enabled, content })
}
function setEnabled(enabled: boolean) {
props.session.enabled = enabled
props.setSession(props.session)
props.setSession({ enabled, content: props.session.content })
}
return (
@ -55,8 +53,7 @@ export function SwitchContainer(props: {
const showAdvanced = useContext(AdvancedContext)
function setContent(content: SessionSettingsNode) {
props.session.content = content
props.setSession(props.session)
props.setSession({ enabled: props.session.enabled, content })
}
if (props.session.enabled && (!props.schema.content_advanced || showAdvanced)) {

View File

@ -6,6 +6,6 @@ license = "MIT"
edition = "2018"
[build-dependencies]
bindgen = "0.57.0"
bindgen = "0.58.0"
cc = "1.0.67"
regex = "1.4.5"

View File

@ -37,32 +37,32 @@ fn main() {
// .rustified_enum("vr::EVRSettingsError")
// .rustified_enum("vr::EIOBufferError")
.generate_inline_functions(true)
.blacklist_function("vr::.*")
.blacklist_type("vr::IVRSettings")
.blacklist_type("vr::CVRSettingHelper")
.blacklist_type("vr::ITrackedDeviceServerDriver")
.blacklist_type("vr::IVRDisplayComponent")
.blacklist_type("vr::IVRDriverDirectModeComponent")
.blocklist_function("vr::.*")
.blocklist_type("vr::IVRSettings")
.blocklist_type("vr::CVRSettingHelper")
.blocklist_type("vr::ITrackedDeviceServerDriver")
.blocklist_type("vr::IVRDisplayComponent")
.blocklist_type("vr::IVRDriverDirectModeComponent")
.opaque_type("vr::ICameraVideoSinkCallback")
.blacklist_type("vr::IVRCameraComponent")
.blocklist_type("vr::IVRCameraComponent")
.opaque_type("vr::IVRDriverContext")
.blacklist_type("vr::IServerTrackedDeviceProvider")
.blacklist_type("vr::IVRWatchdogProvider")
.blacklist_type("vr::IVRCompositorPluginProvider")
.blacklist_type("vr::IVRProperties")
.blacklist_type("vr::CVRPropertyHelpers")
.blacklist_type("vr::IVRDriverInput")
.blacklist_type("vr::IVRDriverLog")
.blacklist_type("vr::IVRServerDriverHost")
.blacklist_type("vr::IVRCompositorDriverHost")
.blacklist_type("vr::CVRHiddenAreaHelpers")
.blacklist_type("vr::IVRWatchdogHost")
.blacklist_type("vr::IVRVirtualDisplay")
.blacklist_type("vr::IVRResources")
.blacklist_type("vr::IVRIOBuffer")
.blacklist_type("vr::IVRDriverManager")
.blacklist_type("vr::IVRDriverSpatialAnchors")
.blacklist_type("vr::COpenVRDriverContext")
.blocklist_type("vr::IServerTrackedDeviceProvider")
.blocklist_type("vr::IVRWatchdogProvider")
.blocklist_type("vr::IVRCompositorPluginProvider")
.blocklist_type("vr::IVRProperties")
.blocklist_type("vr::CVRPropertyHelpers")
.blocklist_type("vr::IVRDriverInput")
.blocklist_type("vr::IVRDriverLog")
.blocklist_type("vr::IVRServerDriverHost")
.blocklist_type("vr::IVRCompositorDriverHost")
.blocklist_type("vr::CVRHiddenAreaHelpers")
.blocklist_type("vr::IVRWatchdogHost")
.blocklist_type("vr::IVRVirtualDisplay")
.blocklist_type("vr::IVRResources")
.blocklist_type("vr::IVRIOBuffer")
.blocklist_type("vr::IVRDriverManager")
.blocklist_type("vr::IVRDriverSpatialAnchors")
.blocklist_type("vr::COpenVRDriverContext")
.generate()
.expect("bindings")
.write_to_file(out_path.join("bindings.rs"))

View File

@ -52,6 +52,6 @@ nalgebra = "0.25"
openvr-driver-sys = { path = "../openvr-driver-sys" }
[build-dependencies]
bindgen = "0.57"
bindgen = "0.58"
cc = { version = "1", features = ["parallel"] }
walkdir = "2"