From 8f5ebc5f3c310f81e4071c6f8811e086b5e98048 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Thu, 29 Sep 2016 11:30:17 -0300 Subject: [PATCH] Fix FFI usage of appendable_data_filter_type C/FFI interface for C's `enum` is `int`, not a JS object. Update code to receive such `int` and convert to a proper `Enum` within JS environment. We use the `String` extracted from `EnumItem` instead the `EnumItem` itself because the rest of the code is expecting a string which will be sent over the wire. --- app/ffi/api/appendable_data.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/ffi/api/appendable_data.js b/app/ffi/api/appendable_data.js index a906e3a6..adc79906 100644 --- a/app/ffi/api/appendable_data.js +++ b/app/ffi/api/appendable_data.js @@ -8,6 +8,7 @@ import { FILTER_TYPE } from '../model/enum'; import log from '../../logger/log'; const int32 = ref.types.int32; +const Int = ref.types.int; const u8 = ref.types.uint8; const u64 = ref.types.uint64; const Void = ref.types.void; @@ -23,8 +24,6 @@ const boolPointer = ref.refType(bool); const size_tPointer = ref.refType(size_t); const Ffi_FilterType = new Enum({ BlackList: 0, WhiteList: 1 }); - -const filterTypePointer = ref.refType(Ffi_FilterType); /* eslint-enable camelcase */ class AppendableData extends FfiApi { @@ -57,7 +56,7 @@ class AppendableData extends FfiApi { appendable_data_clear_deleted_data: [int32, [u64]], appendable_data_remove_nth_deleted_data: [int32, [u64, size_t]], appendable_data_remove_from_filter: [int32, [u64, u64]], - appendable_data_filter_type: [int32, [u64, filterTypePointer]], + appendable_data_filter_type: [int32, [u64, ref.refType(Int)]], appendable_data_num_of_filter_keys: [int32, [u64, size_tPointer]], appendable_data_nth_filter_key: [int32, [u64, size_t, u64Pointer]] // 'appendable_data_delete': [int32, [AppHandle, u64]]