Skip to content

Commit

Permalink
Merge branch 'main' into mypy-fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
BaseMax authored Jan 1, 2025
2 parents d1e3958 + 093feee commit 6b7bb0f
Show file tree
Hide file tree
Showing 29 changed files with 4,173 additions and 417 deletions.
12 changes: 8 additions & 4 deletions build-webassembly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ OUTPUT_BASE="salam-wa"
EDITOR_DIR="../Salam-Editor/"

MEMORY_FLAGS="-s ALLOW_MEMORY_GROWTH=1"
RUNTIME_FLAGS="-s EXIT_RUNTIME=0 -s NO_EXIT_RUNTIME=1"
COMMON_FLAGS="-s EXPORTED_RUNTIME_METHODS=['callMain'] -s TOTAL_STACK=8388608" # 8MB (8 * 1024 * 1024)
# RUNTIME_FLAGS="-s EXIT_RUNTIME=0 -s NO_EXIT_RUNTIME=1"
# RUNTIME_FLAGS="-s NO_EXIT_RUNTIME=1"
# RUNTIME_FLAGS="-s EXIT_RUNTIME=0"
RUNTIME_FLAGS="-s NO_EXIT_RUNTIME=1"
COMMON_FLAGS="-s EXPORTED_RUNTIME_METHODS=['callMain'] -s EXPORTED_FUNCTIONS=['_main'] -s TOTAL_STACK=8388608"

sources=(
"src/log.c"
Expand Down Expand Up @@ -49,14 +52,15 @@ else
echo "Debug mode not enabled."
fi

echo "${sources[@]} -o ${OUTPUT_BASE}.html ${MEMORY_FLAGS} ${RUNTIME_FLAGS} ${COMMON_FLAGS} ${DEBUG_FLAGS}"

echo "Compiling C files to WebAssembly..."
emcc "${sources[@]}" -o ${OUTPUT_BASE}.html \
${MEMORY_FLAGS} \
${RUNTIME_FLAGS} \
${COMMON_FLAGS} \
${DEBUG_FLAGS} \
# -s EXPORTED_FUNCTIONS="['_main']"
# -v\
# -v

if [ $? -eq 0 ]; then
echo "Compilation successful. Output files:"
Expand Down
2 changes: 1 addition & 1 deletion config/json/layout/attribute/type.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
{
"generate_name": "src",
"generate_value_function": "font_url",
"value_handler": "value_handler_font_url",
"id": "AST_LAYOUT_ATTRIBUTE_TYPE_FONT_SRC",
"reserved_values": "",
"type": "AST_LAYOUT_ATTRIBUTE_FILTER_STRING_ANY",
Expand Down
2 changes: 1 addition & 1 deletion config/layout/attribute/type.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ items:
fa:
- محتوا
- generate_name: src
generate_value_function: font_url
value_handler: value_handler_font_url
id: AST_LAYOUT_ATTRIBUTE_TYPE_FONT_SRC
reserved_values: ''
type: AST_LAYOUT_ATTRIBUTE_FILTER_STRING_ANY
Expand Down
37 changes: 28 additions & 9 deletions config/module/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def command_layout_type(item: Dict[str, Any], prefix: str, value: str) -> str:
)


def command_layout_style_type(item: Dict[str, Any], prefix: str, value: str) -> str:
def command_layout_style_type(item: Dict[str, Any], prefix: str, value: str, extra: str = 'none') -> str:
"""
Generates a formatted command string based on the item and value provided.
:param item: Dictionary containing item data.
Expand All @@ -75,14 +75,33 @@ def command_layout_style_type(item: Dict[str, Any], prefix: str, value: str) ->
else "NULL"
)

return (
f"({itemid}, "
f'"{idtext}", '
f'"{idtextlower}", '
f'"{value}", '
f'"{generate_name}", '
f"{type}, {reserved_values}, NULL)"
)
if extra == 'none':
return (
f"({itemid}, "
f'"{idtext}", '
f'"{idtextlower}", '
f'"{value}", '
f'"{generate_name}", '
f"{type}, {reserved_values}, NULL)"
)
elif extra == '':
return (
f"({itemid}, "
f'"{idtext}", '
f'"{idtextlower}", '
f'"{value}", '
f'"{generate_name}", '
f"{type}, {reserved_values}, NULL, value_handler_simple)"
)
else:
return (
f"({itemid}, "
f'"{idtext}", '
f'"{idtextlower}", '
f'"{value}", '
f'"{generate_name}", '
f"{type}, {reserved_values}, NULL, {extra})"
)


# Sample usage:
Expand Down
21 changes: 12 additions & 9 deletions config/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def prettify_layout_attribute_type(item: Dict[str, Any], group: Dict[str, Any])
global SELECTED_LANGUAGE

values = item.get("text", {}).get(SELECTED_LANGUAGE, "")
value_handler = item.get("value_handler", "")

key_normal = "ADD_LAYOUT_ATTRIBUTE_TYPE"
key_repeat = "ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT"
Expand All @@ -79,23 +80,23 @@ def prettify_layout_attribute_type(item: Dict[str, Any], group: Dict[str, Any])
result += (
key_normal
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_TYPE_", value, value_handler
)
+ "\n"
)
else:
result += (
key_repeat
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_TYPE_", value, value_handler
)
+ "\n"
)
return result
else:
return (
key_normal
+ command_layout_style_type(item, "AST_LAYOUT_ATTRIBUTE_TYPE_", values)
+ command_layout_style_type(item, "AST_LAYOUT_ATTRIBUTE_TYPE_", values, value_handler)
+ "\n"
)

Expand Down Expand Up @@ -145,6 +146,8 @@ def prettify_layout_attribute_style_type(
global SELECTED_LANGUAGE

values = item.get("text", {}).get(SELECTED_LANGUAGE, "")
value_handler = item.get("value_handler", "")

key_main = "ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE"
key_hide = "ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE"
key_repeat = "ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_REPEAT"
Expand All @@ -154,7 +157,7 @@ def prettify_layout_attribute_style_type(
return (
key_hide
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", values
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", values, value_handler
)
+ "\n"
)
Expand All @@ -165,15 +168,15 @@ def prettify_layout_attribute_style_type(
result += (
key_hide
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value, value_handler
)
+ "\n"
)
else:
result += (
key_repeat
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value, value_handler
)
+ "\n"
)
Expand All @@ -183,7 +186,7 @@ def prettify_layout_attribute_style_type(
return (
key_main
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", values
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", values, value_handler
)
+ "\n"
)
Expand All @@ -194,15 +197,15 @@ def prettify_layout_attribute_style_type(
result += (
key_main
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value, value_handler
)
+ "\n"
)
else:
result += (
key_repeat
+ command_layout_style_type(
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value
item, "AST_LAYOUT_ATTRIBUTE_STYLE_TYPE_", value, value_handler
)
+ "\n"
)
Expand Down
46 changes: 23 additions & 23 deletions src/ast_layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,14 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {

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

#define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (strcmp(name, NAME_LOWER) == 0) { \
return TYPE; \
}
Expand All @@ -599,13 +599,13 @@ ast_layout_attribute_type_t name_to_ast_layout_attribute_type(char *name) {

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (strcmp(name, NAME_LOWER) == 0) { \
return TYPE; \
}
#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE(TYPE, NAME, NAME_LOWER, \
ENDUSER_NAME, GENERATED_NAME, \
FILTER, ALLOWED_VALUES, SUBTAGS) \
FILTER, ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (strcmp(name, NAME_LOWER) == 0) { \
return TYPE; \
}
Expand Down Expand Up @@ -692,23 +692,23 @@ ast_layout_attribute_type_t enduser_name_to_ast_layout_attribute_type_in_node(

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

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

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

#include "generated-config/ast_layout_attribute_style_type.h"
}
Expand Down Expand Up @@ -736,14 +736,14 @@ char *ast_layout_attribute_type_to_enduser_name(

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

#define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (TYPE == type) { \
return ENDUSER_NAME; \
}
Expand All @@ -756,21 +756,21 @@ char *ast_layout_attribute_type_to_enduser_name(

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
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) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (TYPE == type) { \
return ENDUSER_NAME; \
}

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

#include "generated-config/ast_layout_attribute_style_type.h"

Expand Down Expand Up @@ -798,15 +798,15 @@ ast_layout_attribute_type_t enduser_name_to_ast_layout_attribute_type(

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

#define ADD_LAYOUT_ATTRIBUTE_TYPE_REPEAT(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
else if (strcmp(name, ENDUSER_NAME) == 0) { \
type = TYPE; \
return type; \
Expand All @@ -820,21 +820,21 @@ ast_layout_attribute_type_t enduser_name_to_ast_layout_attribute_type(

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

#include "generated-config/ast_layout_attribute_style_type.h"

Expand Down Expand Up @@ -886,17 +886,17 @@ char *ast_layout_attribute_type_to_name(ast_layout_attribute_type_t type) {

#define ADD_LAYOUT_ATTRIBUTE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, ALLOWED_VALUES, \
SUBTAGS) \
SUBTAGS, VALUE_HANDLER) \
case TYPE: \
return NAME_LOWER;

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

#define ADD_LAYOUT_ATTRIBUTE_TYPE_HIDE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, ALLOWED_VALUES, \
SUBTAGS) \
SUBTAGS, VALUE_HANDLER) \
case TYPE: \
return NAME_LOWER;

Expand All @@ -908,17 +908,17 @@ char *ast_layout_attribute_type_to_name(ast_layout_attribute_type_t type) {

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE(TYPE, NAME, NAME_LOWER, ENDUSER_NAME, \
GENERATED_NAME, FILTER, \
ALLOWED_VALUES, SUBTAGS) \
ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
case TYPE: \
return NAME_LOWER;

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

#define ADD_LAYOUT_ATTRIBUTE_STYLE_TYPE_HIDE(TYPE, NAME, NAME_LOWER, \
ENDUSER_NAME, GENERATED_NAME, \
FILTER, ALLOWED_VALUES, SUBTAGS) \
FILTER, ALLOWED_VALUES, SUBTAGS, VALUE_HANDLER) \
case TYPE: \
return NAME_LOWER;

Expand Down
Loading

0 comments on commit 6b7bb0f

Please sign in to comment.