rokojori-godot/rokojori-cpp-generator/builds/cpp-creation/members/Member.js

67 lines
2.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Member = void 0;
const Parameter_1 = require("../Parameter");
class Member {
constructor(memberType, memberInitializer) {
this.name = "";
this.isMethod = false;
this.isVirtual = true;
this.isStatic = false;
this.isSignal = false;
this.type = "void";
this.initialValue = null;
this.parameters = [];
this.accessModifier = "";
this.parametersDefinition = "";
this.memberType = memberType;
this.accessModifier = memberInitializer.accessModifier;
this.name = memberInitializer.name;
this.type = memberInitializer.type || this.type;
this.isMethod = memberInitializer.isMethod;
this.isSignal = memberInitializer.isSignal;
this.isStatic = memberInitializer.isStatic;
this.isVirtual = memberInitializer.isVirtual;
}
info() {
let methodBrackets = this.isMethod ? "()" : "";
if (methodBrackets === "()" && this.parameters.length > 0) {
methodBrackets = "( " + this.parametersDefinition + " )";
}
if (this.isSignal) {
}
return `// ${this.isSignal ? "[signal] " : ""}${this.name}${methodBrackets} : ${this.type}`;
}
setPublic() {
this.accessModifier = "public";
return this;
}
setProtected() {
this.accessModifier = "protected";
return this;
}
parseMethodParameters(body) {
if (!body) {
return;
}
if (typeof body === "string") {
this.type = body;
return;
}
for (let it in body) {
if (!body.hasOwnProperty(it)) {
continue;
}
let cppParameter = new Parameter_1.Parameter();
cppParameter.name = it;
cppParameter.type = body[it];
this.parameters.push(cppParameter);
}
this.parametersDefinition = this.parameters.map(p => p.get()).join(", ");
}
getParametersDefinition() {
return this.parameters.map(p => p.type + " " + p.name).join(", ");
}
}
exports.Member = Member;
//# sourceMappingURL=Member.js.map