1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Updating to C++, new Mac avr tools, Windows to be updated.

This commit is contained in:
David A. Mellis
2006-02-24 15:52:58 +00:00
parent c8711cd2fd
commit 18fc6d6875
6 changed files with 38 additions and 26 deletions

View File

@ -526,14 +526,14 @@ public class Compiler implements MessageConsumer {
String s1 = s.substring(partialStartIndex +
partialTempPath.length() + 1);
//System.out.println(s1);
if (s1.indexOf("In function")!= -1) {
int colon = s1.indexOf(':');
if (s1.indexOf("In function") != -1 || colon == -1) {
System.err.print(s1);
//firstErrorFound = true;
return;
}
int colon = s1.indexOf(':');
int lineNumber = Integer.parseInt(s1.substring(0, colon));
// the "1" corresponds to the amount of lines written to the main code

View File

@ -776,6 +776,15 @@ public class Editor extends JFrame
// });
// menu.add(item);
item = new JMenuItem("Howto");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Base.openURL(System.getProperty("user.dir") + File.separator +
"reference" + File.separator + "howto.html");
}
});
menu.add(item);
item = new JMenuItem("Reference");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -1961,14 +1970,14 @@ public class Editor extends JFrame
cutItem.setEnabled(true);
copyItem.setEnabled(true);
referenceFile = PdeKeywords.getReference(textarea.getSelectedText());
if (referenceFile != null) {
referenceItem.setEnabled(true);
}
//referenceFile = PdeKeywords.getReference(textarea.getSelectedText());
//if (referenceFile != null) {
//referenceItem.setEnabled(true);
//}
} else {
cutItem.setEnabled(false);
copyItem.setEnabled(false);
referenceItem.setEnabled(false);
//referenceItem.setEnabled(false);
}
super.show(component, x, y);
}

View File

@ -1382,7 +1382,8 @@ public class Sketch {
//System.out.println();
} else {
code[0].preprocName = className + "." + Preferences.get("build.extension");
//code[0].preprocName = className + "." + Preferences.get("build.extension");
code[0].preprocName = className + ".cpp";
}
// store this for the compiler and the runtime
@ -1511,7 +1512,8 @@ public class Sketch {
// just write the the contents of 'program' to a .java file
// into the build directory. uses byte stream and reader/writer
// shtuff so that unicode bunk is properly handled
String filename = code[i].name + "." + Preferences.get("build.extension");
//String filename = code[i].name + "." + Preferences.get("build.extension");
String filename = code[i].name + ".cpp";
try {
Base.saveFile(code[i].program, new File(buildPath, filename));
} catch (IOException e) {

View File

@ -236,7 +236,7 @@ public class PdePreprocessor {
String returntype, functioname, parameterlist, prototype;
java.util.LinkedList prototypes = new java.util.LinkedList();
//System.out.println("prototypes:");
if (Preferences.get("build.extension").equals("cpp")) {
//if (Preferences.get("build.extension").equals("cpp")) {
while(matcher.contains(input, pattern)){
result = matcher.getMatch();
//System.out.println(result);
@ -253,7 +253,7 @@ public class PdePreprocessor {
prototypes.add(prototype);
//System.out.println(prototype);
}
}
//}
// store # of prototypes so that line number reporting can be adjusted
prototypeCount = prototypes.size();
@ -299,7 +299,7 @@ public class PdePreprocessor {
// start parsing at the compilationUnit non-terminal
//
//parser.pdeProgram();
parser.translationUnit();
//parser.translationUnit();
// set up the AST for traversal by PdeEmitter
//
@ -329,16 +329,19 @@ public class PdePreprocessor {
// output the code
//
WEmitter emitter = new WEmitter(lexer.getPreprocessorInfoChannel());
File streamFile = new File(buildPath, name + "." + Preferences.get("build.extension"));
//File streamFile = new File(buildPath, name + "." + Preferences.get("build.extension"));
File streamFile = new File(buildPath, name + ".cpp");
PrintStream stream = new PrintStream(new FileOutputStream(streamFile));
//writeHeader(stream, extraImports, name);
writeHeader(stream, name, prototypes);
//added to write the pde code to the cpp file
writeProgram(stream, name, program);
emitter.setASTNodeType(TNode.class.getName());
emitter.setOut(stream);
emitter.printDeclarations(rootNode);
//emitter.printDeclarations(rootNode);
//emitter.print(rootNode);
emitter.translationUnit(parser.getAST());
//emitter.translationUnit(parser.getAST());
writeFooter(stream);
stream.close();
@ -363,6 +366,12 @@ public class PdePreprocessor {
return name;
}
// Write the pde program to the cpp file
void writeProgram(PrintStream out, String className, String program) {
out.print(program);
}
/**
* Write any required header material (eg imports, class decl stuff)
*