Methods Summary |
---|
private java.lang.String | entity()
switch (myMode) {
case UNION:
return "Union";
case EXCEPTION:
return "Exception";
}
return "Struct";
|
private java.lang.String | getEntityFile()
switch (myMode) {
case UNION:
return "UNIONS";
case EXCEPTION:
return "EXCEPTIONS";
}
return "STRUCTS";
|
private java.lang.String | getEntityName()
if (myEntityName == null) {
initEntityName();
}
return myEntityName;
|
private java.lang.StringBuffer | getGlobalEntityBuffer()
switch (myMode) {
case UNION:
return myScopeProcessor.getGlobalUnionsBuffer();
case EXCEPTION:
return myScopeProcessor.getGlobalExceptionsBuffer();
}
return myScopeProcessor.getGlobalStructsBuffer();
|
public java.lang.StringBuffer | getLocalTypedefs()Get locally generated typedef declarations.
return null; //FIXME
|
private com.togethersoft.openapi.scriptapi.UML.UMLClassifier | getWrappingClass()
UMLAssociationEnumeration enum = myClassifier.getAssociations();
UMLAssociation assoc;
UMLClassifier wrapperClass = null;
while (enum.hasMoreElements()) {
assoc = enum.getNextUMLAssociation();
if (myTagsProcessor.getPropertyValue(assoc, IdlTags.STEREOTYPE).equals(IdlTags.NESTED)) {
wrapperClass = assoc.getDest();
}
}
return wrapperClass;
|
private void | initEntityName()
myEntityName = myClassifier.getName();
if (IdlKeywords.isKeyword(myEntityName)) {
myEntityName += "_";
}
|
private void | insertEntityHeader(java.lang.StringBuffer buffer)
String header = "";
switch (myMode) {
case STRUCT:
header = "struct " + getEntityName() + " {\n";
break;
case UNION:
header = "union " + getEntityName() + " switch(" + mySwitchTypeSpec + ") {\n";
break;
case EXCEPTION:
header = "exception " + getEntityName() + " {\n";
break;
}
buffer.append(header);
|
public void | process()Do-it-all.
myComplainer.produceInheritanceWarnings(myClassifier, entity());
if (myClassifier.hasProperty(IdlTags.IDLUNIONSELECTOR)) {
mySwitchTypeSpec = myTagsProcessor.getPropertyValue(myClassifier, IdlTags.IDLUNIONSELECTOR);
}
UMLAttributeEnumeration attributes = myClassifier.getAllAttributes();
idlModuleName = myTagsProcessor.getPropertyValue(myClassifier, IdlTags.IDLMODULE);
if (idlModuleName != null && !idlModuleName.equals("")) {
isInsideModule = true;
}
insertEntityHeader(myBuffer);
CaseLabelGenerator labelGenerator = null;
if (myMode == UNION) {
try {
labelGenerator = new CaseLabelGenerator(mySwitchTypeSpec);
}
catch(IllegalArgumentException iae) {
myComplainer.error(entity() + " " + myClassifier.getQualifiedName() + " has invalid switch type, ignored");
return;
}
}
myWrappingClass = getWrappingClass();
if (myWrappingClass != null) {
isNested = true;
myWrappingClassName = myWrappingClass.getQualifiedName();
}
AttributeFiller attributeFiller = new AttributeFiller(myScopeProcessor, myTagsProcessor, myConfigLoader,
myTypeConverter, myComplainer);
attributeFiller.setClassifier(myClassifier);
attributeFiller.setPass(false); // imitate second pass for we need attributes
attributeFiller.setStruct(true);
attributeFiller.setLabelGenerator(labelGenerator);
attributeFiller.setBuffer(myBuffer);
attributeFiller.setModuleBuffer(myModuleBuffer); // FIXME: make sure one day
attributeFiller.setIndent(myIndent);
attributeFiller.process();
myBuffer.insert(0, attributeFiller.getLocalTypedefs());
if (!isNested) {
processStandaloneUnion();
}
else {
processNestedUnion();
}
|
private void | processNestedUnion()
if (myMode == EXCEPTION) {
System.err.println("processNestedStruct: adding exception: " + myScopeProcessor.getDestFQ(myWrappingClass, false) +
"::" + getEntityName() + ", " + myScopeProcessor.getFileName(myWrappingClass));
myScopeProcessor.addException(myScopeProcessor.getDestFQ(myWrappingClass, false) + "::" + getEntityName(),
myScopeProcessor.getFileName(myWrappingClass));
}
if (isFirst) {
System.err.println("WRAPPING CLASS = " + myWrappingClass.getName());
myScopeProcessor.addTypeFromClass(myScopeProcessor.getDestFQ(myWrappingClass, false) + "::" + getEntityName(),
myScopeProcessor.getFileName(myWrappingClass));
myBuffer.append("};\n"); // close statements
StringBuffer curValue = myScopeProcessor.getNestedObjectDeclaration(myScopeProcessor.getDestFQ(myWrappingClass,
false));
if (curValue == null) {
curValue = new StringBuffer();
}
if (curValue.equals("")) {
myScopeProcessor.putNestedObjectDeclaration(myScopeProcessor.getDestFQ(myWrappingClass, false), myBuffer);
}
else {
myScopeProcessor.putNestedObjectDeclaration(myScopeProcessor.getDestFQ(myWrappingClass, false),
curValue.append(myBuffer));
}
myScopeProcessor.putNestedObject(myScopeProcessor.getDestFQ(myWrappingClass, false), myClassifier);
}
|
private void | processStandaloneUnion()
if (!isFirst) {
myBuffer.append("};\n");
}
if (!isInsideModule) {
if (isFirst) {
if (myMode == EXCEPTION) {
myScopeProcessor.addTypeFromClass("::" + getEntityName(), getEntityFile()); // "STRUCTS" and so alike
}
else {
myScopeProcessor.addException("::" + getEntityName(), "EXCEPTIONS");
}
return;
}
// FIXME: tempTypes?
myScopeProcessor.checkInnerTypes(tempTypes, "", getEntityFile());
if (!myScopeProcessor.getIncludes().equals("")) {
getGlobalEntityBuffer().insert(0, myScopeProcessor.getIncludes());
}
getGlobalEntityBuffer().append(myBuffer);
}
else {
// handle union inside module
if (isFirst) {
if (myMode == EXCEPTION) {
myScopeProcessor.addException(myScopeProcessor.getDestFQ(myClassifier, false),
myScopeProcessor.getFileName(myClassifier));
}
else {
myScopeProcessor.addTypeFromClass(myScopeProcessor.getDestFQ(myClassifier, false),
myScopeProcessor.getFileName(myClassifier));
}
return;
}
// FIXME: tempTypes ?
myScopeProcessor.checkInnerTypes(tempTypes, myScopeProcessor.getDestFQ(myClassifier, false),
myScopeProcessor.getFileName(myClassifier));
myScopeProcessor.prepareToFillFile();
String fileName = getEntityName();
StringBuffer outBuff = new StringBuffer();
if (myConfigLoader.isUseLongFileNames() && idlModuleName.equals("")) {
String scopeName = myTagsProcessor.processingTag_idlModule(idlModuleName);
myScopeProcessor.setFileName(scopeName + fileName);
}
else {
if (!idlModuleName.equals("")) {
myTagsProcessor.processingTag_idlModule(idlModuleName);
}
}
myScopeProcessor.createIdlFile(myScopeProcessor.getOutputDirectory());
myModuleBuffer = new StringBuffer();
//moduleTypedefs = new String(); FIXME: how come it is not used ever?
if (!idlModuleName.equals("")) {
myScopeProcessor.fillModuleStatements(outBuff, idlModuleName);
}
myModuleBuffer.append(myBuffer);
if (!myScopeProcessor.getIncludes().equals("")) {
outBuff.insert(0, myScopeProcessor.getIncludes());
}
myScopeProcessor.closeModules(myTagsProcessor.getPosition());
myTagsProcessor.resetSettings();
myScopeProcessor.closeIdlFile(myScopeProcessor.getOutputFileWriter(), outBuff, myClassifier,
myScopeProcessor.getFileName());
}
|
public void | setBuffer(java.lang.StringBuffer buffer)Sets the buffer to put generated declarations into
myBuffer = buffer;
|
public void | setClassifier(com.togethersoft.openapi.scriptapi.UML.UMLClassifier classifier)
myClassifier = classifier;
|
public void | setIndent(java.lang.String indent)Sets base indent level
myIndent = indent;
|
public void | setMode(int mode)Sets fill mode.
myMode = mode;
|
public void | setModuleBuffer(java.lang.StringBuffer moduleBuffer)Sets the buffer to hold module-level typedefs
myModuleBuffer = moduleBuffer;
|
public void | setPass(boolean istFirst)Set which pass is going on.
isFirst = istFirst;
|