improve tools

This commit is contained in:
lixianjing 2020-01-08 22:55:03 -08:00
parent 5b22cb8bcc
commit 165bdf18b4
2 changed files with 25 additions and 12 deletions

View File

@ -364,11 +364,28 @@ ret_t ${className}_set_${iter.name}(widget_t* widget, ${paramDecl}) {
return result;
}
genFreeProps(json) {
let result = '';
const className = json.name;
if (!json.props || !json.props.length) {
return result;
}
result = json.props.map((iter, index) => {
if(iter.type.indexOf('char*') >= 0) {
return ` TKMEM_FREE(${className}->${iter.name});\n`;
} else {
return '';
}
}).join('');
return result;
}
genGetPropDispatch(json) {
let result = '';
if (!json.props || !json.props.length) {
return result;
return result;
}
const className = json.name;
@ -401,6 +418,7 @@ ret_t ${className}_set_${iter.name}(widget_t* widget, ${paramDecl}) {
const propSetterImpls = this.genPropSetterImpls(json);
const propSetPropDispatch = this.genSetPropDispatch(json);
const propGetPropDispatch = this.genGetPropDispatch(json);
const freeProps = this.genFreeProps(json);
let defaultInclude = this.genIncludes(className);
if (json.includes) {
@ -436,7 +454,7 @@ static ret_t ${className}_on_destroy(widget_t* widget) {
${className}_t* ${className} = ${uclassName}(widget);
return_value_if_fail(widget != NULL && ${className} != NULL, RET_BAD_PARAMS);
(void)${className};
${freeProps}
return RET_OK;
}

View File

@ -13,18 +13,13 @@
"type":"char*"
},
{
"name":"file_icon",
"desc":"文件项的图标",
"type":"char*"
"name":"ignore_hidden_files",
"desc":"忽略隐藏文件",
"type":"bool_t"
},
{
"name":"folder_icon",
"desc":"目录项的图标",
"type":"char*"
},
{
"name":"return_up_icon",
"desc":"返回上一级目录的图标",
"name":"sort_by",
"desc":"排序方式。可选值(name, size, mtime)",
"type":"char*"
}
]