Skip to content

Allowing editing .S files #3227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ public boolean addFile(File sourceFile) {
destFile = new File(data.getCodeFolder(), filename);

} else {
for (String extension : data.getExtensions()) {
for (String extension : SketchData.EXTENSIONS) {
String lower = filename.toLowerCase();
if (lower.endsWith("." + extension)) {
destFile = new File(data.getFolder(), filename);
Expand Down Expand Up @@ -1345,7 +1345,7 @@ public boolean isDefaultExtension(String what) {
* extensions.
*/
public boolean validExtension(String what) {
return data.getExtensions().contains(what);
return SketchData.EXTENSIONS.contains(what);
}


Expand Down
23 changes: 8 additions & 15 deletions arduino-core/src/processing/app/SketchData.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package processing.app;

import com.google.common.collect.FluentIterable;

import static processing.app.I18n._;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.*;

public class SketchData {

public static final List<String> SKETCH_EXTENSIONS = Arrays.asList("ino", "pde");
public static final List<String> OTHER_ALLOWED_EXTENSIONS = Arrays.asList("c", "cpp", "h", "s");
public static final List<String> EXTENSIONS = new LinkedList<String>(FluentIterable.from(SKETCH_EXTENSIONS).append(OTHER_ALLOWED_EXTENSIONS).toList());

/** main pde file for this sketch. */
private File primaryFile;

Expand Down Expand Up @@ -105,8 +107,6 @@ protected void load() throws IOException {
clearCodeDocs();
// data.setCodeDocs(codeDocs);

List<String> extensions = getExtensions();

for (String filename : list) {
// Ignoring the dot prefix files is especially important to avoid files
// with the ._ prefix on Mac OS X. (You'll see this with Mac files on
Expand All @@ -119,7 +119,7 @@ protected void load() throws IOException {
// figure out the name without any extension
String base = filename;
// now strip off the .pde and .java extensions
for (String extension : extensions) {
for (String extension : EXTENSIONS) {
if (base.toLowerCase().endsWith("." + extension)) {
base = base.substring(0, base.length() - (extension.length() + 1));

Expand Down Expand Up @@ -173,13 +173,6 @@ public String getDefaultExtension() {
return "ino";
}

/**
* Returns a String[] array of proper extensions.
*/
public List<String> getExtensions() {
return Arrays.asList("ino", "pde", "c", "cpp", "h");
}

/**
* Returns a file object for the primary .pde of this sketch.
*/
Expand Down
4 changes: 2 additions & 2 deletions arduino-core/src/processing/app/debug/Compiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws Ru
StringBuffer bigCode = new StringBuffer();
int bigCount = 0;
for (SketchCode sc : sketch.getCodes()) {
if (sc.isExtension("ino") || sc.isExtension("pde")) {
if (sc.isExtension(SketchData.SKETCH_EXTENSIONS)) {
sc.setPreprocOffset(bigCount);
// These #line directives help the compiler report errors with
// correct the filename and line number (issue 281 & 907)
Expand Down Expand Up @@ -1272,7 +1272,7 @@ public void preprocess(String buildPath, PdePreprocessor preprocessor) throws Ru
// 3. then loop over the code[] and save each .java file

for (SketchCode sc : sketch.getCodes()) {
if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
if (sc.isExtension(SketchData.OTHER_ALLOWED_EXTENSIONS)) {
// no pre-processing services necessary for java files
// just write the the contents of 'program' to a .java file
// into the build directory. uses byte stream and reader/writer
Expand Down