Skip to content

Commit

Permalink
Get rid of empty derive macros inside of bitflags enums
Browse files Browse the repository at this point in the history
  • Loading branch information
locka99 committed Aug 5, 2021
1 parent 7f3d08a commit b86495e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
11 changes: 2 additions & 9 deletions tools/schema/gen_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,10 @@ pub use self::impls::*;
util.write_to_file(file_path, contents);
}

function generate_bitfield(enum_type, derivations){
function generate_bitfield(enum_type) {
contents = `
bitflags!{
#[derive(${derivations})]
pub struct ${enum_type.name}: ${enum_type.type} {`;

_.each(enum_type.values, (value) => {
contents += `
const ${value.name} = ${value.value};`;
Expand Down Expand Up @@ -325,12 +323,7 @@ use bitflags;


if (enum_type.option){
// Copy Clone PartialEq are inplemented in bitfield macro
let derivations = ""
if (_.includes(serde_supported_types, enum_type.name)) {
derivations += ", Serialize";
}
contents += generate_bitfield(enum_type, derivations);
contents += generate_bitfield(enum_type);
} else {
let derivations = "Debug, Copy, Clone, PartialEq"
if (_.includes(serde_supported_types, enum_type.name)) {
Expand Down
12 changes: 0 additions & 12 deletions types/src/service_types/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ impl BinaryEncoder<PubSubState> for PubSubState {


bitflags!{
#[derive()]
pub struct DataSetFieldFlags: i16 {
const None = 0;
const PromotedField = 1;
Expand All @@ -246,7 +245,6 @@ impl BinaryEncoder<DataSetFieldFlags> for DataSetFieldFlags {


bitflags!{
#[derive()]
pub struct DataSetFieldContentMask: i32 {
const None = 0;
const StatusCode = 1;
Expand Down Expand Up @@ -336,7 +334,6 @@ impl BinaryEncoder<DataSetOrderingType> for DataSetOrderingType {


bitflags!{
#[derive()]
pub struct UadpNetworkMessageContentMask: i32 {
const None = 0;
const PublisherId = 1;
Expand Down Expand Up @@ -369,7 +366,6 @@ impl BinaryEncoder<UadpNetworkMessageContentMask> for UadpNetworkMessageContentM


bitflags!{
#[derive()]
pub struct UadpDataSetMessageContentMask: i32 {
const None = 0;
const Timestamp = 1;
Expand Down Expand Up @@ -397,7 +393,6 @@ impl BinaryEncoder<UadpDataSetMessageContentMask> for UadpDataSetMessageContentM


bitflags!{
#[derive()]
pub struct JsonNetworkMessageContentMask: i32 {
const None = 0;
const NetworkMessageHeader = 1;
Expand Down Expand Up @@ -425,7 +420,6 @@ impl BinaryEncoder<JsonNetworkMessageContentMask> for JsonNetworkMessageContentM


bitflags!{
#[derive()]
pub struct JsonDataSetMessageContentMask: i32 {
const None = 0;
const DataSetWriterId = 1;
Expand Down Expand Up @@ -627,7 +621,6 @@ impl BinaryEncoder<NodeClass> for NodeClass {


bitflags!{
#[derive()]
pub struct PermissionType: i32 {
const None = 0;
const Browse = 1;
Expand Down Expand Up @@ -666,7 +659,6 @@ impl BinaryEncoder<PermissionType> for PermissionType {


bitflags!{
#[derive()]
pub struct AccessLevelType: u8 {
const None = 0;
const CurrentRead = 1;
Expand Down Expand Up @@ -695,7 +687,6 @@ impl BinaryEncoder<AccessLevelType> for AccessLevelType {


bitflags!{
#[derive()]
pub struct AccessLevelExType: i32 {
const None = 0;
const CurrentRead = 1;
Expand Down Expand Up @@ -728,7 +719,6 @@ impl BinaryEncoder<AccessLevelExType> for AccessLevelExType {


bitflags!{
#[derive()]
pub struct EventNotifierType: u8 {
const None = 0;
const SubscribeToEvents = 1;
Expand All @@ -753,7 +743,6 @@ impl BinaryEncoder<EventNotifierType> for EventNotifierType {


bitflags!{
#[derive()]
pub struct AccessRestrictionType: i16 {
const None = 0;
const SigningRequired = 1;
Expand Down Expand Up @@ -1033,7 +1022,6 @@ impl BinaryEncoder<NodeAttributesMask> for NodeAttributesMask {


bitflags!{
#[derive()]
pub struct AttributeWriteMask: i32 {
const None = 0;
const AccessLevel = 1;
Expand Down

0 comments on commit b86495e

Please sign in to comment.