Skip to content

Commit

Permalink
Add org.xresloader.field_list_strict_size
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed Jul 26, 2024
1 parent 10f5616 commit 2cb9ee2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 27 deletions.
9 changes: 5 additions & 4 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
1. 增加插件 `org.xresloader.field_list_strip_option=LIST_STRIP_DEFAULT|LIST_STRIP_NOTHING|LIST_STRIP_TAIL|LIST_STRIP_ALL` 用于给单个字段设置数组裁剪。
2. 增加插件 `org.xresloader.field_list_min_size="<N>|枚举名"` 用于给单个字段数组最小长度要求。
3. 增加插件 `org.xresloader.field_list_max_size="<N>|枚举名"` 用于给单个字段数组最大长度要求。
4. 增加选项 `--disable-alias-mapping` 用于关闭字段映射时使用别名。
5. 修复使用别名时,message结构未被正确映射的问题。
6. 修复对Excel对大数字自动附加的 `,` 的适配。
7. 修复对非裁剪模式下的数组数据自动补全问题。
4. 增加插件 `org.xresloader.field_list_strict_size=<true|false>` 用于设置单个字段数组的严格长度要求,即不自动补全最小长度,而是报错。
5. 增加选项 `--disable-alias-mapping` 用于关闭字段映射时使用别名。
6. 修复使用别名时,message结构未被正确映射的问题。
7. 修复对Excel对大数字自动附加的 `,` 的适配。
8. 修复对非裁剪模式下的数组数据自动补全问题。

### BREAKCHANGES

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ validator:
| | + `LIST_STRIP_ALL`: 裁剪全部空值,相当于 `--list-strip-all-empty` |
| org.xresloader.field_list_min_size | 给单个字段设置数组最小长度,输入字符串:`"<N>\|枚举名"`(版本 2.18.0 版本开始支持) |
| org.xresloader.field_list_max_size | 给单个字段设置数组最大长度,输入字符串:`"<N>\|枚举名"`(版本 2.18.0 版本开始支持) |
| org.xresloader.field_list_strict_size | 设置单个字段设置数组严格长度要求,即不自动补全最小长度,而是报错。:`false\|true`(默认值: `false` ,版本 2.18.0 版本开始支持) |
| org.xresloader.ue.key_tag | 生成UE代码时,如果需要支持多个Key组合成一个Name,用这个字段指定系数(必须大于0) |
| org.xresloader.ue.ue_type_name | 生成UE代码时,如果指定了这个字段,那么生成的字段类型将是 `TSoftObjectPtr<ue_type_name>` , 并且支持蓝图中直接引用 |
| org.xresloader.ue.ue_type_is_class | 生成UE代码时,如果指定了这个字段,那么生成的字段类型将是 `TSoftClassPtr<ue_type_name>` , 并且支持蓝图中直接引用 |
Expand Down
56 changes: 37 additions & 19 deletions header/org/xresloader/Xresloader.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/org/xresloader/core/data/dst/DataDstJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private Object getDefault(DataDstWriterNode.DataDstTypeDescriptor container,
throws ConvException {
Object val = null;
if (field.isList() && listIndex >= 0 && field.getListExtension() != null
&& field.getListExtension().minSize >= listIndex + 1) {
&& field.getListExtension().strictSize && field.getListExtension().minSize >= listIndex + 1) {
if (container != null) {
this.logErrorMessage(
"Field \"%s\" in \"%s\" has set field_list_min_size %d, which is not allowed to be auto filled with default value.",
Expand Down Expand Up @@ -318,6 +318,7 @@ private Object getDefault(DataDstWriterNode.DataDstTypeDescriptor container,
dumpDefault(sub_msg, field
.getTypeDescriptor(), sub_item.getValue(), 0);
} else if (sub_item.getValue().isList() && sub_item.getValue().getListExtension() != null
&& sub_item.getValue().getListExtension().strictSize
&& sub_item.getValue().getListExtension().minSize > 0) {
this.logErrorMessage(
"Field \"%s\" in \"%s\" has set field_list_min_size %d, which is not allowed to be auto filled with default value.",
Expand Down
8 changes: 6 additions & 2 deletions src/org/xresloader/core/data/dst/DataDstPb.java
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,10 @@ static private boolean setup_extension(DataDstTypeDescriptor parent_message, Dat
}
}
}
if (fd.getOptions().hasExtension(Xresloader.fieldListStrictSize)) {
child_field.mutableExtension()
.mutableList().strictSize = fd.getOptions().getExtension(Xresloader.fieldListStrictSize);
}
}

if (gen == null) {
Expand Down Expand Up @@ -1954,7 +1958,7 @@ private Object getDefault(DynamicMessage.Builder builder, DataDstFieldDescriptor
Descriptors.FieldDescriptor fd = (Descriptors.FieldDescriptor) field.getRawDescriptor();
Object val = null;
if (field.isList() && field.getListExtension() != null
&& field.getListExtension().minSize >= listIndex + 1) {
&& field.getListExtension().strictSize && field.getListExtension().minSize >= listIndex + 1) {
this.logErrorMessage(
"Field \"%s\" in \"%s\" has set field_list_min_size %d, which is not allowed to be auto filled with default value.",
field.getName(), fd.getContainingType().getFullName(),
Expand Down Expand Up @@ -2003,7 +2007,7 @@ private Object getDefault(DynamicMessage.Builder builder, DataDstFieldDescriptor
if (subField.isRequired()) {
dumpDefault(subnode, subField, 0);
} else if (subField.isList() && subField.getListExtension() != null
&& subField.getListExtension().minSize > 0) {
&& subField.getListExtension().strictSize && subField.getListExtension().minSize > 0) {
this.logErrorMessage(
"Field \"%s\" in \"%s\" has set field_list_min_size %d, which is not allowed to be auto filled with default value.",
subField.getName(), fd.getFullName(),
Expand Down
1 change: 1 addition & 0 deletions src/org/xresloader/core/data/dst/DataDstWriterNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ static public class DataDstFieldExtList {
public ListStripRule stripOption = ListStripRule.DEFAULT;
public int minSize = 0;
public int maxSize = 0;
public boolean strictSize = false;
}

static public class DataDstFieldExt {
Expand Down
2 changes: 1 addition & 1 deletion third_party/xresloader-protocol
Binary file modified tools/extensions.pb
Binary file not shown.

0 comments on commit 2cb9ee2

Please sign in to comment.