-
- private void breakCodeLines(ArrayList<String> newCode, String code) {
- int begin = 0, end = 0;
- while (end < code.length()) {
- if (code.charAt(end) == '\n') {
- String line = code.substring(begin, end);
- newCode.add(line);
- begin = end + 1;
+
+ // Wrap the interface and then renaem it
+ private void interface2Code(InterfaceConstruct construct) {
+ // If there's no define construct for it, we generate the wrapper just
+ // in place without declaration
+ InterfaceDefineConstruct defineConstruct = _semantics.interfaceName2DefineConstruct
+ .get(construct.name);
+ ArrayList<String> newCode;
+ int lineNum;
+ CodeAddition addition;
+ // Then generate the wrapper if necessary
+ if (defineConstruct != null) { // Need to have a wrapper declaration
+ newCode = CodeVariables.generateInterfaceWrapperDeclaration(
+ _semantics, construct);
+ lineNum = construct.beginLineNum;
+ // Add the wrapper declaration
+ addition = new CodeAddition(lineNum, newCode);
+ if (!codeAdditions.containsKey(construct.file)) {
+ codeAdditions
+ .put(construct.file, new ArrayList<CodeAddition>());
+ }
+ codeAdditions.get(construct.file).add(addition);
+
+ // Add the wrapper definition
+ newCode = CodeVariables.generateInterfaceWrapperDefinition(
+ _semantics, construct);
+ lineNum = defineConstruct.beginLineNum;
+ // Add the wrapper declaration
+ addition = new CodeAddition(lineNum, newCode);
+ if (!codeAdditions.containsKey(defineConstruct.file)) {
+ codeAdditions.put(defineConstruct.file,
+ new ArrayList<CodeAddition>());