Skip to content

Commit

Permalink
Adding #ifndef #define #endif
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Dec 28, 2024
1 parent 040fb4a commit bc7a519
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 69 deletions.
61 changes: 7 additions & 54 deletions src/ast_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,14 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {
GENERATED_NAME, FILTER, ALLOWED_VALUES, \
SUBTAGS) \
else if (strcmp(name, NAME_LOWER) == 0) { \
type = TYPE; \
return type; \
return TYPE; \
}

#define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
else if (strcmp(name, NAME_LOWER) == 0) { \
type = TYPE; \
return type; \
return TYPE; \
}

#include "generated-config/ast_layout_attribute_type.h"
Expand All @@ -601,15 +599,13 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
else if (strcmp(name, NAME_LOWER) == 0) { \
type = TYPE; \
return type; \
return TYPE; \
}
#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE(TYPE, NAME, NAME_LOWER, \
ENDUSER_NAME, GENERATED_NAME, \
FILTER, ALLOWED_VALUES, SUBTAGS) \
else if (strcmp(name, NAME_LOWER) == 0) { \
type = TYPE; \
return type; \
return TYPE; \
}

#include "generated-config/ast_layout_attribute_style_type.h"
Expand All @@ -619,43 +615,18 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {

ast_layout_attribute_type_t ast_layout_attribute_enduser_name_in_node_to_type(char *name, ast_layout_node_type_t parent_node_type)
{
if (false) {}

for (int i = 0; i < map_size; i++) {
if (layout_map[i].type == parent_node_type) {
for (int j = 0 ; j < layout_map[i].count_allowed_arguments; j++) {
ast_layout_attribute_type_t argument_type = layout_map[i].allowed_arguments[j];
char *enduser_name = (argument_type);
char *enduser_name = ast_layout_node_type_to_enduser_name(argument_type);

if (strcmp(name, enduser_name) == 0) {
return argument_type;
}
}
}
}


#define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS)

#include "generated-config/ast_layout_attribute_type.h"

#undef ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE
#undef ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_REPEAT

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, ALLOWED_VALUES, \
SUBTAGS) \
else if (TYPE == type) { \
return ENDUSER_NAME; \
}

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS)

#include "generated-config/ast_layout_attribute_style_type.h"

return AST_LAYOUT_ATTRIBUTE_TYPE_ERROR;
}
Expand All @@ -676,26 +647,8 @@ ast_layout_attribute_type_t enduser_name_to_ast_layout_attribute_type_in_node(
ast_layout_attribute_type_t type = ast_layout_attribute_enduser_name_in_node_to_type(name, parent_node_type);

if (type == AST_LAYOUT_ATTRIBUTE_TYPE_ERROR ) {
// #undef ADD_LAYOUT_ATTRIBUTE_TYPE
// #undef ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT

// #define ADD_LAYOUT_ATTRIBUTE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
// GENERATED_NAME, FILTER, ALLOWED_VALUES, \
// SUBTAGS) \
// if (strcmp(name, ENDUSER_NAME) == 0) { \
// type = TYPE; \
// count++; \
// }

// #define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
// GENERATED_NAME, FILTER, \
// ALLOWED_VALUES, SUBTAGS) \
// if (strcmp(name, ENDUSER_NAME) == 0) { \
// type = TYPE; \
// count++; \
// }

// #include "generated-config/ast_layout_attribute_type.h"

if (false) {}

#undef ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE
#undef ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_REPEAT
Expand Down
2 changes: 2 additions & 0 deletions src/generated-config/ast_block_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ ADD_BLOCK_TYPE(AST_BLOCK_TYPE_ERROR, "ERROR", "error")





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_style_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_GLOBAL_VALUE(unset, "حذف شده")





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_style_state_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_STATE_TYPE(AST_LAYOUT_ATTRIBUTE_STYLE_STATE_TYPE_EMPT





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_style_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,5 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE(AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_ERROR, "ERR





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_style_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1488,3 +1488,5 @@ const ast_layout_attribute_pair_t ast_layout_allowed_style_list_zoom[] = {





Original file line number Diff line number Diff line change
Expand Up @@ -375,3 +375,5 @@ extern const ast_layout_attribute_pair_t ast_layout_allowed_style_list_zoom[];





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,5 @@ ADD_LAYOUT_ATTRIBUTE_TYPE(AST_LAYOUT_ATTRIBUTE_TYPE_RESPONSIVE_MIN_HEIGHT, "RESP





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,5 @@ const ast_layout_attribute_pair_t ast_layout_allowed_lang[] = {





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_attribute_value_extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ extern const ast_layout_attribute_pair_t ast_layout_allowed_lang[];





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,5 @@ ADD_LAYOUT_TYPE_REPEAT(AST_LAYOUT_TYPE_MEDIA, "MEDIA", "media", "@media", "وا





2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_type_attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ else if (attribute->parent_node_type == AST_LAYOUT_TYPE_MEDIA) {





5 changes: 5 additions & 0 deletions src/generated-config/ast_layout_type_attributes_all.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _AST_LAYOUT_TYPE_ATTRIBUTES_ALL_H_
#define _AST_LAYOUT_TYPE_ATTRIBUTES_ALL_H_

layout_map_entry_t layout_map[] = {
// ----------- BEGIN AUTO GENERATED ----------- //
{ AST_LAYOUT_TYPE_INCLUDE, valid_attributes_include, valid_attributes_include_length },
Expand Down Expand Up @@ -114,3 +117,5 @@ layout_map_entry_t layout_map[] = {
};

const size_t map_size = sizeof(layout_map) / sizeof(layout_map[0]);

#endif
19 changes: 4 additions & 15 deletions src/generated-config/ast_layout_type_attributes_values.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef _AST_LAYOUT_TYPE_ATTRIBUTES_VALUES_H_
#define _AST_LAYOUT_TYPE_ATTRIBUTES_VALUES_H_

// ----------- BEGIN AUTO GENERATED ----------- //
ast_layout_attribute_type_t valid_attributes_include[] = {
AST_LAYOUT_ATTRIBUTE_TYPE_SRC,
Expand Down Expand Up @@ -204,18 +207,4 @@ const size_t valid_attributes_media_length = 0;

// ----------- END AUTO GENERATED ----------- //
















#endif
2 changes: 2 additions & 0 deletions src/generated-config/ast_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ ADD_TYPE(AST_TYPE_ERROR, "ERROR", "error")





0 comments on commit bc7a519

Please sign in to comment.