Skip to content

Commit

Permalink
Add ue_origin_type_name and ue_origin_type_default_value
Browse files Browse the repository at this point in the history
Signed-off-by: owent <[email protected]>
  • Loading branch information
owent committed May 19, 2023
1 parent 11c2a77 commit 6688104
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 34 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unrelease

1. 增加 `org.xresloader.ue.ue_origin_type_name` 来设置输出UE代码的原始类型
2. 增加 `org.xresloader.ue.ue_origin_type_default_value` 来设置输出UE代码的原始类型的默认值
3. 修复打包时 `Discovered module-info.class. Shading will break its strong encapsulation.` 的告警

## 2.13.1

1. 修订UE的FObjectFinder只能用于构造函数的问题。
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,20 @@ Excel里的Key使用@后缀的字段名,@后面的部分都属于验证器。

#### Protobuf插件 - Field插件

| 插件名称 | 插件功能 |
| :-------------------------------: | :------------------------------------------------------------------------------------------------------------: |
| org.xresloader.verifier | 验证器,可填范围(log-high),message名,enum名。多个由 `|` 分隔。任意验证器通过检查则认为数据有效 |
| org.xresloader.field_description | 字段描述信息,会写入输出的header中和代码中 |
| org.xresloader.field_alias | 字段别名,配合 **验证器** 功能,允许在数据源中直接填写别名来配置数据 |
| org.xresloader.field_ratio | 字段放大,用于比如配置百分率为 0.12,当 org.xresloader.field_ratio=100时转出的数据为12 |
| org.xresloader.field_separator | Plain模式分隔符,可指定多个,用于在一个单元格内配置复杂格式时的分隔符列表,默认值: `,;| ` |
| org.xresloader.field_required | 设置字段为 **required** ,用于向proto3提供,proto2的 **required** 约束 |
| org.xresloader.field_origin_value | 写出原始数据到指定字段( `TImestamp``Duration` 类型) |
| org.xresloader.ue.key_tag | 生成UE代码时,如果需要支持多个Key组合成一个Name,用这个字段指定系数(必须大于0) |
| org.xresloader.ue.ueTypeName | 生成UE代码时,如果指定了这个字段,那么生成的字段类型将是 `TSoftObjectPtr<ueTypeName>` , 并且支持蓝图中直接引用 |
| 插件名称 | 插件功能 |
| :----------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------: |
| org.xresloader.verifier | 验证器,可填范围(log-high),message名,enum名。多个由 `|` 分隔。任意验证器通过检查则认为数据有效 |
| org.xresloader.field_description | 字段描述信息,会写入输出的header中和代码中 |
| org.xresloader.field_alias | 字段别名,配合 **验证器** 功能,允许在数据源中直接填写别名来配置数据 |
| org.xresloader.field_ratio | 字段放大,用于比如配置百分率为 0.12,当 org.xresloader.field_ratio=100时转出的数据为12 |
| org.xresloader.field_separator | Plain模式分隔符,可指定多个,用于在一个单元格内配置复杂格式时的分隔符列表,默认值: `,;| ` |
| org.xresloader.field_required | 设置字段为 **required** ,用于向proto3提供,proto2的 **required** 约束 |
| org.xresloader.field_origin_value | 写出原始数据到指定字段( `TImestamp``Duration` 类型) |
| 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>` , 并且支持蓝图中直接引用 |
| org.xresloader.ue.ue_origin_type_name | 生成UE代码时,如果指定了这个字段,那么生成的字段类型将使用这个类型,需要用户自己确保类型有效且对应的proto类型可以隐式转换到该类型 |
| org.xresloader.ue.ue_origin_type_default_value | 生成UE代码时,如果指定了这个字段,那么生成的字段的Reset代码将使用这个表达式,需要用户自己确保表达式有效且对应的proto类型可以隐式转换到该类型 |

#### Protobuf插件 - EnumValue插件

Expand Down
65 changes: 52 additions & 13 deletions header/org/xresloader/ue/XresloaderUe.java

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

9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.xresloader</groupId>
<artifactId>xresloader</artifactId>
<version>2.13.1</version>
<version>2.13.2</version>
<packaging>jar</packaging>
<name>xresloader</name>

Expand Down Expand Up @@ -99,6 +99,7 @@
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.MF</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
Expand Down Expand Up @@ -299,11 +300,5 @@
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
2 changes: 2 additions & 0 deletions src/org/xresloader/core/data/dst/DataDstJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ static private class ParseResult {
}

public static class SpecialInnerHashMap<K, V> extends HashMap<K, V> {
private static final long serialVersionUID = 1L;

public SpecialInnerHashMap(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
}
Expand Down
10 changes: 10 additions & 0 deletions src/org/xresloader/core/data/dst/DataDstPb.java
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,16 @@ static private void setup_extension(DataDstTypeDescriptor parent_message, DataDs
child_field.mutableExtension().mutableUE().ueTypeIsClass = fd.getOptions()
.getExtension(XresloaderUe.ueTypeIsClass);
}

if (fd.getOptions().hasExtension(XresloaderUe.ueOriginTypeName)) {
child_field.mutableExtension().mutableUE().ueOriginTypeName = fd.getOptions()
.getExtension(XresloaderUe.ueOriginTypeName);
}

if (fd.getOptions().hasExtension(XresloaderUe.ueOriginTypeDefaultValue)) {
child_field.mutableExtension().mutableUE().ueOriginTypeDefaultValue = fd.getOptions()
.getExtension(XresloaderUe.ueOriginTypeDefaultValue);
}
}

static private void setup_extension(DataDstTypeDescriptor parent_message, DataDstOneofDescriptor child_field,
Expand Down
15 changes: 13 additions & 2 deletions src/org/xresloader/core/data/dst/DataDstUEBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -1753,10 +1753,14 @@ private final void writeCodeHeaderField(FileOutputStream fout, DataDstFieldDescr
if (enable) {
if (null == ueTypeName) {
String ueTypeNameIdent = null;
String ueOriginTypeName = null;
if (null != fieldDesc) {
ueTypeNameIdent = fieldDesc.mutableExtension().mutableUE().ueTypeName;
ueOriginTypeName = fieldDesc.mutableExtension().mutableUE().ueOriginTypeName;
}
if (ueTypeNameIdent == null || ueTypeNameIdent.isEmpty()) {
if (ueOriginTypeName != null && !ueOriginTypeName.trim().isEmpty()) {
ueTypeName = ueOriginTypeName.trim();
} else if (ueTypeNameIdent == null || ueTypeNameIdent.isEmpty()) {
ueTypeName = getUETypeName(typeDesc);
} else {
if (null != fieldDesc && fieldDesc.mutableExtension().mutableUE().ueTypeIsClass) {
Expand All @@ -1771,8 +1775,11 @@ private final void writeCodeHeaderField(FileOutputStream fout, DataDstFieldDescr
if (fieldDesc.isMap() && typeDesc != null && typeDesc.getSortedFields().size() >= 2) {
String keyUeTypeName = getUETypeName(typeDesc.getSortedFields().get(0).getTypeDescriptor());
String ueTypeNameIdent = fieldDesc.mutableExtension().mutableUE().ueTypeName;
String ueOriginTypeName = fieldDesc.mutableExtension().mutableUE().ueOriginTypeName;
String valueUeTypeName;
if (ueTypeNameIdent == null || ueTypeNameIdent.isEmpty()) {
if (ueOriginTypeName != null && !ueOriginTypeName.trim().isEmpty()) {
valueUeTypeName = ueOriginTypeName.trim();
} else if (ueTypeNameIdent == null || ueTypeNameIdent.isEmpty()) {
valueUeTypeName = getUETypeName(typeDesc.getSortedFields().get(1).getTypeDescriptor());
} else {
if (null != fieldDesc && fieldDesc.mutableExtension().mutableUE().ueTypeIsClass) {
Expand Down Expand Up @@ -1843,7 +1850,11 @@ static private final String getUETypeName(DataDstTypeDescriptor desc) {
protected final String getUETypeDefault(DataDstFieldDescriptor field) {
DataDstWriterNode.JAVA_TYPE descType = field.getType();
String ueTypeNameIdent = field.mutableExtension().mutableUE().ueTypeName;
String ueOriginTypeDefaultValue = field.mutableExtension().mutableUE().ueOriginTypeDefaultValue;

if (ueOriginTypeDefaultValue != null && !ueOriginTypeDefaultValue.trim().isEmpty()) {
return ueOriginTypeDefaultValue.trim();
}
if (ueTypeNameIdent != null && !ueTypeNameIdent.isEmpty()) {
return "nullptr";
}
Expand Down
2 changes: 2 additions & 0 deletions src/org/xresloader/core/data/dst/DataDstWriterNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ static public class DataDstFieldExtUE {
public long keyTag = 0;
public String ueTypeName = null;
public boolean ueTypeIsClass = false;
public String ueOriginTypeName = null;
public String ueOriginTypeDefaultValue = null;
}

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 6688104

Please sign in to comment.