Favor using non-braced using statement.

This commit is contained in:
Peter Huene
2020-02-24 18:44:37 -08:00
parent a6ec8f85a6
commit 4e1d2a2fc1
10 changed files with 328 additions and 343 deletions

View File

@@ -52,14 +52,12 @@ namespace Wasmtime.Bindings
{
var parameters = Interop.ToValueTypeVec(Import.Parameters);
var results = Interop.ToValueTypeVec(Import.Results);
using (var funcType = Interop.wasm_functype_new(ref parameters, ref results))
{
var callback = CreateCallback(store, host);
var func = Interop.wasm_func_new(store.Handle, funcType, callback);
// Store the callback with the safe handle to keep the delegate GC reachable
func.Callback = callback;
return func;
}
using var funcType = Interop.wasm_functype_new(ref parameters, ref results);
var callback = CreateCallback(store, host);
var func = Interop.wasm_func_new(store.Handle, funcType, callback);
// Store the callback with the safe handle to keep the delegate GC reachable
func.Callback = callback;
return func;
}
}

View File

@@ -59,14 +59,14 @@ namespace Wasmtime.Bindings
var valueTypeHandle = valueType.DangerousGetHandle();
valueType.SetHandleAsInvalid();
using (var globalType = Interop.wasm_globaltype_new(
using var globalType = Interop.wasm_globaltype_new(
valueTypeHandle,
Import.IsMutable ? Interop.wasm_mutability_t.WASM_VAR : Interop.wasm_mutability_t.WASM_CONST))
{
var handle = Interop.wasm_global_new(store.Handle, globalType, &v);
global.Handle = handle;
return handle;
}
Import.IsMutable ? Interop.wasm_mutability_t.WASM_VAR : Interop.wasm_mutability_t.WASM_CONST
);
var handle = Interop.wasm_global_new(store.Handle, globalType, &v);
global.Handle = handle;
return handle;
}
}

View File

@@ -68,12 +68,11 @@ namespace Wasmtime.Bindings
Interop.wasm_limits_t limits = new Interop.wasm_limits_t();
limits.min = min;
limits.max = max;
using (var memoryType = Interop.wasm_memorytype_new(&limits))
{
var handle = Interop.wasm_memory_new(store.Handle, memoryType);
memory.Handle = handle;
return handle;
}
using var memoryType = Interop.wasm_memorytype_new(&limits);
var handle = Interop.wasm_memory_new(store.Handle, memoryType);
memory.Handle = handle;
return handle;
}
}