Skip to content

Commit

Permalink
fix problem of content attr
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax committed Dec 28, 2024
1 parent 0b57c6c commit 11904d1
Show file tree
Hide file tree
Showing 21 changed files with 81 additions and 14 deletions.
2 changes: 1 addition & 1 deletion config/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

<h2 id="div">دستور <code>جعبه</code></h2>

این دستور فرزند است.
این دستور مادر است و می تواند حامی دستوراتی به عنوان فرزند باشد.

نام این دستور معادل دستور `div` می‌باشد.

Expand Down
6 changes: 3 additions & 3 deletions config/json/layout/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@
"examples": "",
"generate_name": "div",
"id": "AST_LAYOUT_TYPE_DIV",
"is_mother": false,
"attributes": null,
"is_mother": true,
"text": {
"en": [
"box"
],
"fa": [
"جعبه"
]
},
"attributes": null
}
},
{
"descriptions": "",
Expand Down
3 changes: 2 additions & 1 deletion config/layout/type.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ items:
examples: ''
generate_name: div
id: AST_LAYOUT_TYPE_DIV
is_mother: false
attributes:
is_mother: true
text:
en:
- box
Expand Down
15 changes: 7 additions & 8 deletions example/input.salam
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
صفحه:
زبان = «فارسی»



جهت = «راست به چپ»
// جهت = «چپ به راست»

رنگ پس زمینه = «سبز»


جعبه:
رنگ پس زمینه = «قرمز»
رنگ = «سفید»
Expand All @@ -14,19 +17,15 @@
گردی = ۹
تمام

///*
بارگیری:
تکرار = ۳۰
فضا بالا = ۲۰
منبع = «example/card.salam»
تمام
//*/

/*
جعبه:
رنگ پس زمینه = «بنفش»
رنگ = «سفید»
محتوا = «سلام چطوری؟»
گردی = ۹
فضا بالا = ۹
تمام

*/

تمام
34 changes: 34 additions & 0 deletions src/ast_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,32 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {
return type;
}

// TODO
bool ast_layout_node_type_is_mother(ast_layout_node_type_t type) {
switch (type) {
#undef ADD_LAYOUT_TYPE
#undef ADD_LAYOUT_TYPE_HIDE
#undef ADD_LAYOUT_TYPE_REPEAT

#define ADD_LAYOUT_TYPE(TYPE, NAME, NAME_LOWER, GENERATED_NAME, ENDUSER_NAME, \
IS_MOTHER) \
case TYPE: \
return IS_MOTHER;

#define ADD_LAYOUT_TYPE_HIDE(TYPE, NAME, NAME_LOWER, GENERATED_NAME, \
ENDUSER_NAME, IS_MOTHER) \
case TYPE: \
return IS_MOTHER;

#define ADD_LAYOUT_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, GENERATED_NAME, \
ENDUSER_NAME, IS_MOTHER)

#include "generated-config/ast_layout_type.h"
}

return false;
}

ast_layout_attribute_type_t ast_layout_attribute_enduser_name_in_node_to_type(char *name, ast_layout_node_type_t parent_node_type)
{
for (int i = 0; i < map_size; i++) {
Expand All @@ -628,6 +654,14 @@ ast_layout_attribute_type_t ast_layout_attribute_enduser_name_in_node_to_type(ch
}
}

if (ast_layout_node_type_is_mother(parent_node_type)) {
char *enduser_name = ast_layout_attribute_type_to_enduser_name(AST_LAYOUT_ATTRIBUTE_TYPE_CONTENT);

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

return AST_LAYOUT_ATTRIBUTE_TYPE_ERROR;
}

Expand Down
3 changes: 3 additions & 0 deletions src/ast_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,7 @@ bool ast_layout_attribute_has_any_sub_value(ast_layout_attribute_t *value);
char *ast_layout_attribute_type_to_enduser_name(
ast_layout_attribute_type_t type);

// TODO
bool ast_layout_node_type_is_mother(ast_layout_node_type_t type);

#endif
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,5 +28,7 @@ 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 @@ -28,3 +28,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 @@ -88,3 +88,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 @@ -587,3 +587,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 @@ -1491,3 +1491,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 @@ -378,3 +378,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 @@ -88,3 +88,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 @@ -58,3 +58,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 @@ -33,3 +33,5 @@ extern const ast_layout_attribute_pair_t ast_layout_allowed_lang[];





4 changes: 3 additions & 1 deletion src/generated-config/ast_layout_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_ERROR, "ERROR", "error", "", "خطا", false)

ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_LAYOUT, "LAYOUT", "layout", "", "صفحه", false)

ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_DIV, "DIV", "div", "div", "جعبه", false)
ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_DIV, "DIV", "div", "div", "جعبه", true)

ADD_LAYOUT_TYPE(AST_LAYOUT_TYPE_PARAGRAPH, "PARAGRAPH", "paragraph", "p", "پاراگراف", false)

Expand Down Expand Up @@ -145,5 +145,7 @@ 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,5 +155,7 @@ else if (attribute->parent_node_type == AST_LAYOUT_TYPE_MEDIA) {







2 changes: 2 additions & 0 deletions src/generated-config/ast_layout_type_attributes_all.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,5 @@ 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 @@ -210,3 +210,5 @@ const size_t valid_attributes_media_length = 0;
#endif




Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,5 @@ 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,5 +36,7 @@ ADD_TYPE(AST_TYPE_ERROR, "ERROR", "error")







0 comments on commit 11904d1

Please sign in to comment.