113 lines
2.9 KiB
Plaintext
113 lines
2.9 KiB
Plaintext
|
|
fn get_attr(atts, name) {
|
||
|
|
for att in atts {
|
||
|
|
if att.name.join(".") == name {
|
||
|
|
return att;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn get_param(params, name) {
|
||
|
|
for param in params {
|
||
|
|
if param.name == name {
|
||
|
|
return param;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
"packages:" ++ NL;
|
||
|
|
IND ++ "- name: " ++ module.name.join(".") ++ NL;
|
||
|
|
IND ++ " interfaces:" ++ NL;
|
||
|
|
|
||
|
|
for service in module.services {
|
||
|
|
IND(2) ++ "- name: " ++ service.first ++ NL;
|
||
|
|
|
||
|
|
let version = get_attr(service.second.attributes, "version");
|
||
|
|
IND(2) ++ " version:" + NL;
|
||
|
|
let major = "1";
|
||
|
|
let minor = "0";
|
||
|
|
if version != () {
|
||
|
|
major = get_param(version.parameters, "major").value.unwrap_or(major);
|
||
|
|
minor = get_param(version.parameters, "minor").value.unwrap_or(minor);
|
||
|
|
}
|
||
|
|
IND(3) ++ "major: " ++ major ++ NL;
|
||
|
|
IND(3) ++ "minor: " ++ minor ++ NL;
|
||
|
|
|
||
|
|
if service.second.functions.len() > 0 {
|
||
|
|
IND(2) ++ " methods:" ++ NL;
|
||
|
|
|
||
|
|
for function in service.second.functions {
|
||
|
|
IND(3) ++ "- name: " ++ function.first ++ NL;
|
||
|
|
|
||
|
|
if function.second.arguments.len() > 0 {
|
||
|
|
IND(3) ++ " arguments:" + NL;
|
||
|
|
for argument in function.second.arguments {
|
||
|
|
IND(4) ++ "- name: " ++ argument.first ++ NL;
|
||
|
|
IND(4) ++ " type: " ++ argument.second.typ.join("::") ++ NL;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if is_some(function.second.return_type) {
|
||
|
|
let return_type = unwrap(function.second.return_type);
|
||
|
|
IND(3) ++ " return: " ++ return_type.typ.join("::");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
-(to_string(service.second.events.len()));
|
||
|
|
if service.second.events.len() > 0 {
|
||
|
|
IND(2) ++ " events:" ++ NL;
|
||
|
|
for event in service.second.events {
|
||
|
|
let is_field = get_attr(event, "field") != ();
|
||
|
|
debug(is_field);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
|
||
|
|
for enum in module.enums {
|
||
|
|
"enum " ++ enum.first ++ " {";
|
||
|
|
let prefix = "";
|
||
|
|
for enum_value in enum.second.values {
|
||
|
|
let name = enum_value.first;
|
||
|
|
let enum_value = enum_value.second;
|
||
|
|
if is_some(enum_value.value) {
|
||
|
|
prefix ++ NL ++ IND ++ name ++ " = " ++ unwrap(enum_value.value);
|
||
|
|
} else {
|
||
|
|
prefix ++ NL ++ IND ++ name;
|
||
|
|
}
|
||
|
|
prefix = ","
|
||
|
|
}
|
||
|
|
NL ++ "};" ++ NL(2);
|
||
|
|
}
|
||
|
|
|
||
|
|
end("ENUMS");
|
||
|
|
|
||
|
|
-(NL);
|
||
|
|
|
||
|
|
begin("DATATYPES");
|
||
|
|
|
||
|
|
for data_type in module.data_types {
|
||
|
|
"struct " ++ data_type.first ++ " {" ++ NL;
|
||
|
|
for property in data_type.second.properties {
|
||
|
|
if property.second.is_list {
|
||
|
|
let count = property.second.count;
|
||
|
|
if is_some(count) {
|
||
|
|
let count = unwrap(count);
|
||
|
|
IND ++ property.second.typ.join("::") ++ " " ++ property.first ++ "[" ++ count ++ "];" ++ NL;
|
||
|
|
} else {
|
||
|
|
IND ++ property.second.typ.join("::") ++ " " ++ property.first ++ "[]" ++ ";" ++ NL;
|
||
|
|
}
|
||
|
|
} else {
|
||
|
|
IND ++ property.second.typ.join("::") ++ " " ++ property.first ++ ";" ++ NL;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
"};" ++ NL(2);
|
||
|
|
}
|
||
|
|
end("DATATYPES");
|
||
|
|
|
||
|
|
"}" ++ NL
|
||
|
|
*/
|