Skip to content

Commit

Permalink
fix bug of lang attr in layout node
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Dec 28, 2024
1 parent bc7a519 commit 0b57c6c
Show file tree
Hide file tree
Showing 18 changed files with 224 additions and 2 deletions.
31 changes: 31 additions & 0 deletions config/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,32 @@ def prettify_layout_type_attributes_all(
return ""


def prettify_layout_type_attributes_values_extern(
item: Dict[str, Any], group: Dict[str, Any]
) -> str:
"""
TODO
"""

attributes = item.get("attributes", [])
if attributes is None:
attributes = []

if "generate_name" in item:
itemid = item["id"]
itemid_lower = itemid.replace("AST_LAYOUT_TYPE_", "").lower()

var_attrs = f"valid_attributes_{itemid_lower}"
var_attrs_length = f"valid_attributes_{itemid_lower}_length"

result = f"extern ast_layout_attribute_type_t {var_attrs}[];\n"
result += f"extern const size_t {var_attrs_length};\n"

return result
else:
return ""


def prettify_layout_type_attributes_values(
item: Dict[str, Any], group: Dict[str, Any]
) -> str:
Expand Down Expand Up @@ -547,6 +573,11 @@ def prettify_layout_type(item: Dict[str, Any], group: Dict[str, Any]) -> str:
"output": "ast_layout_type_attributes_values.h",
"prettify": prettify_layout_type_attributes_values,
},
{
"input": "layout/type.yaml",
"output": "ast_layout_type_attributes_values_extern.h",
"prettify": prettify_layout_type_attributes_values_extern,
},
{
"input": "layout/type.yaml",
"output": "ast_layout_type_attributes_all.h",
Expand Down
2 changes: 1 addition & 1 deletion src/ast_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ ast_layout_attribute_type_t ast_layout_attribute_enduser_name_in_node_to_type(ch
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 = ast_layout_node_type_to_enduser_name(argument_type);
char *enduser_name = ast_layout_attribute_type_to_enduser_name(argument_type);

if (strcmp(name, enduser_name) == 0) {
return argument_type;
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 @@ -28,3 +28,5 @@ ADD_BLOCK_TYPE(AST_BLOCK_TYPE_ERROR, "ERROR", "error")





1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_style_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_GLOBAL_VALUE(unset, "حذف شده")




Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_STATE_TYPE(AST_LAYOUT_ATTRIBUTE_STYLE_STATE_TYPE_EMPT




1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_style_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,3 +586,4 @@ ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE(AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_ERROR, "ERR




1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_style_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1490,3 +1490,4 @@ const ast_layout_attribute_pair_t ast_layout_allowed_style_list_zoom[] = {




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




1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,4 @@ ADD_LAYOUT_ATTRIBUTE_TYPE(AST_LAYOUT_ATTRIBUTE_TYPE_RESPONSIVE_MIN_HEIGHT, "RESP




1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ const ast_layout_attribute_pair_t ast_layout_allowed_lang[] = {




1 change: 1 addition & 0 deletions src/generated-config/ast_layout_attribute_value_extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ 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 @@ -145,3 +145,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 @@ -155,3 +155,5 @@ else if (attribute->parent_node_type == AST_LAYOUT_TYPE_MEDIA) {





1 change: 1 addition & 0 deletions src/generated-config/ast_layout_type_attributes_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ layout_map_entry_t layout_map[] = {
const size_t map_size = sizeof(layout_map) / sizeof(layout_map[0]);

#endif

2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_type_attributes_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ const size_t valid_attributes_media_length = 0;
// ----------- END AUTO GENERATED ----------- //

#endif


172 changes: 172 additions & 0 deletions src/generated-config/ast_layout_type_attributes_values_extern.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#ifndef _AST_LAYOUT_TYPE_ATTRIBUTES_VALUES_EXTERN_H_
#define _AST_LAYOUT_TYPE_ATTRIBUTES_VALUES_EXTERN_H_

// ----------- BEGIN AUTO GENERATED ----------- //
extern ast_layout_attribute_type_t valid_attributes_include[];
extern const size_t valid_attributes_include_length;

extern ast_layout_attribute_type_t valid_attributes_error[];
extern const size_t valid_attributes_error_length;

extern ast_layout_attribute_type_t valid_attributes_layout[];
extern const size_t valid_attributes_layout_length;

extern ast_layout_attribute_type_t valid_attributes_div[];
extern const size_t valid_attributes_div_length;

extern ast_layout_attribute_type_t valid_attributes_paragraph[];
extern const size_t valid_attributes_paragraph_length;

extern ast_layout_attribute_type_t valid_attributes_button[];
extern const size_t valid_attributes_button_length;

extern ast_layout_attribute_type_t valid_attributes_textarea[];
extern const size_t valid_attributes_textarea_length;

extern ast_layout_attribute_type_t valid_attributes_label[];
extern const size_t valid_attributes_label_length;

extern ast_layout_attribute_type_t valid_attributes_select[];
extern const size_t valid_attributes_select_length;

extern ast_layout_attribute_type_t valid_attributes_fieldset[];
extern const size_t valid_attributes_fieldset_length;

extern ast_layout_attribute_type_t valid_attributes_legend[];
extern const size_t valid_attributes_legend_length;

extern ast_layout_attribute_type_t valid_attributes_form[];
extern const size_t valid_attributes_form_length;

extern ast_layout_attribute_type_t valid_attributes_optgroup[];
extern const size_t valid_attributes_optgroup_length;

extern ast_layout_attribute_type_t valid_attributes_datalist[];
extern const size_t valid_attributes_datalist_length;

extern ast_layout_attribute_type_t valid_attributes_span[];
extern const size_t valid_attributes_span_length;

extern ast_layout_attribute_type_t valid_attributes_strong[];
extern const size_t valid_attributes_strong_length;

extern ast_layout_attribute_type_t valid_attributes_em[];
extern const size_t valid_attributes_em_length;

extern ast_layout_attribute_type_t valid_attributes_italic[];
extern const size_t valid_attributes_italic_length;

extern ast_layout_attribute_type_t valid_attributes_bold[];
extern const size_t valid_attributes_bold_length;

extern ast_layout_attribute_type_t valid_attributes_underline[];
extern const size_t valid_attributes_underline_length;

extern ast_layout_attribute_type_t valid_attributes_sub[];
extern const size_t valid_attributes_sub_length;

extern ast_layout_attribute_type_t valid_attributes_sup[];
extern const size_t valid_attributes_sup_length;

extern ast_layout_attribute_type_t valid_attributes_s[];
extern const size_t valid_attributes_s_length;

extern ast_layout_attribute_type_t valid_attributes_header[];
extern const size_t valid_attributes_header_length;

extern ast_layout_attribute_type_t valid_attributes_footer[];
extern const size_t valid_attributes_footer_length;

extern ast_layout_attribute_type_t valid_attributes_nav[];
extern const size_t valid_attributes_nav_length;

extern ast_layout_attribute_type_t valid_attributes_section[];
extern const size_t valid_attributes_section_length;

extern ast_layout_attribute_type_t valid_attributes_article[];
extern const size_t valid_attributes_article_length;

extern ast_layout_attribute_type_t valid_attributes_aside[];
extern const size_t valid_attributes_aside_length;

extern ast_layout_attribute_type_t valid_attributes_main[];
extern const size_t valid_attributes_main_length;

extern ast_layout_attribute_type_t valid_attributes_figure[];
extern const size_t valid_attributes_figure_length;

extern ast_layout_attribute_type_t valid_attributes_figcaption[];
extern const size_t valid_attributes_figcaption_length;

extern ast_layout_attribute_type_t valid_attributes_video[];
extern const size_t valid_attributes_video_length;

extern ast_layout_attribute_type_t valid_attributes_audio[];
extern const size_t valid_attributes_audio_length;

extern ast_layout_attribute_type_t valid_attributes_iframe[];
extern const size_t valid_attributes_iframe_length;

extern ast_layout_attribute_type_t valid_attributes_canvas[];
extern const size_t valid_attributes_canvas_length;

extern ast_layout_attribute_type_t valid_attributes_ul[];
extern const size_t valid_attributes_ul_length;

extern ast_layout_attribute_type_t valid_attributes_link[];
extern const size_t valid_attributes_link_length;

extern ast_layout_attribute_type_t valid_attributes_ol[];
extern const size_t valid_attributes_ol_length;

extern ast_layout_attribute_type_t valid_attributes_option[];
extern const size_t valid_attributes_option_length;

extern ast_layout_attribute_type_t valid_attributes_li[];
extern const size_t valid_attributes_li_length;

extern ast_layout_attribute_type_t valid_attributes_table[];
extern const size_t valid_attributes_table_length;

extern ast_layout_attribute_type_t valid_attributes_table_header[];
extern const size_t valid_attributes_table_header_length;

extern ast_layout_attribute_type_t valid_attributes_table_footer[];
extern const size_t valid_attributes_table_footer_length;

extern ast_layout_attribute_type_t valid_attributes_table_tr[];
extern const size_t valid_attributes_table_tr_length;

extern ast_layout_attribute_type_t valid_attributes_table_td[];
extern const size_t valid_attributes_table_td_length;

extern ast_layout_attribute_type_t valid_attributes_table_th[];
extern const size_t valid_attributes_table_th_length;

extern ast_layout_attribute_type_t valid_attributes_caption[];
extern const size_t valid_attributes_caption_length;

extern ast_layout_attribute_type_t valid_attributes_col[];
extern const size_t valid_attributes_col_length;

extern ast_layout_attribute_type_t valid_attributes_br[];
extern const size_t valid_attributes_br_length;

extern ast_layout_attribute_type_t valid_attributes_hr[];
extern const size_t valid_attributes_hr_length;

extern ast_layout_attribute_type_t valid_attributes_input[];
extern const size_t valid_attributes_input_length;

extern ast_layout_attribute_type_t valid_attributes_img[];
extern const size_t valid_attributes_img_length;

extern ast_layout_attribute_type_t valid_attributes_font[];
extern const size_t valid_attributes_font_length;

extern ast_layout_attribute_type_t valid_attributes_media[];
extern const size_t valid_attributes_media_length;

// ----------- 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 @@ -36,3 +36,5 @@ ADD_TYPE(AST_TYPE_ERROR, "ERROR", "error")





2 changes: 1 addition & 1 deletion src/validator.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "generated-config/ast_layout_attribute_style_value_extern.h"
#include "generated-config/ast_layout_attribute_value.h"
#include "generated-config/ast_layout_type_attributes_values.h"
#include "generated-config/ast_layout_type_attributes_values_extern.h"

/**
*
Expand Down

0 comments on commit 0b57c6c

Please sign in to comment.