Move mockdata/HAL_Value.h to hal/Value.h

Also prefix the MakeBoolean et al functions with HAL_ to avoid namespace
pollution.
This commit is contained in:
Peter Johnson
2019-09-23 23:28:49 -07:00
parent 1b266717a8
commit e8d6f8a2c1
37 changed files with 185 additions and 179 deletions

View File

@@ -7,9 +7,9 @@
#pragma once
#include "HAL_Value.h"
#include "NotifyListener.h"
#include "hal/Types.h"
#include "hal/Value.h"
typedef void (*HAL_CAN_SendMessageCallback)(const char* name, void* param,
uint32_t messageID,

View File

@@ -1,67 +0,0 @@
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
#pragma once
#include "hal/Types.h"
/** HAL data types. */
enum HAL_Type {
HAL_UNASSIGNED = 0,
HAL_BOOLEAN = 0x01,
HAL_DOUBLE = 0x02,
HAL_ENUM = 0x16,
HAL_INT = 0x32,
HAL_LONG = 0x64,
};
/** HAL Entry Value. Note this is a typed union. */
struct HAL_Value {
union {
HAL_Bool v_boolean;
int32_t v_enum;
int32_t v_int;
int64_t v_long;
double v_double;
} data;
enum HAL_Type type;
};
inline HAL_Value MakeBoolean(HAL_Bool v) {
HAL_Value value;
value.type = HAL_BOOLEAN;
value.data.v_boolean = v;
return value;
}
inline HAL_Value MakeEnum(int v) {
HAL_Value value;
value.type = HAL_ENUM;
value.data.v_enum = v;
return value;
}
inline HAL_Value MakeInt(int v) {
HAL_Value value;
value.type = HAL_INT;
value.data.v_int = v;
return value;
}
inline HAL_Value MakeLong(int64_t v) {
HAL_Value value;
value.type = HAL_LONG;
value.data.v_long = v;
return value;
}
inline HAL_Value MakeDouble(double v) {
HAL_Value value;
value.type = HAL_DOUBLE;
value.data.v_double = v;
return value;
}

View File

@@ -7,7 +7,7 @@
#pragma once
#include "HAL_Value.h"
#include "hal/Value.h"
typedef void (*HAL_NotifyCallback)(const char* name, void* param,
const struct HAL_Value* value);