diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php index c997232..8b8ba66 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/CompilerHandler.php @@ -1134,7 +1134,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d $ext = pathinfo($file, PATHINFO_EXTENSION); if (!in_array($ext, array("ino", "c", "cpp", "h", "hpp"))) - return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp or .h files."); + return array("success" => false, "message" => "Sorry, autocompletion is only supported for .ino, .c, .cpp, .h or .hpp files."); if ($ext == "ino") { $ext = "cpp"; @@ -1149,7 +1149,7 @@ private function doAutocomplete($ARDUINO_CORES_DIR, $compiler_config, $compile_d $json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline); } - elseif ($ext == "cpp" || $ext == "h") + elseif ($ext == "cpp" || $ext == "h" || $ext == "hpp" ) { $commandline = "$CPP $CPPFLAGS $core_includes $target_arch -MMD $include_directories -c -o $filename.o $filename.$ext 2>&1"; $json_array = array("file" => $compiler_config["autocmpfile"], "row" => $compiler_config["autocmprow"], "column" => $compiler_config["autocmpcol"], "prefix" => $compiler_config["autocmpprefix"], "command" => $commandline); diff --git a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php index f674b6e..095467f 100644 --- a/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php +++ b/Symfony/src/Codebender/CompilerBundle/Handler/UtilityHandler.php @@ -36,7 +36,7 @@ function extractFiles($directory, $request_files, $lib_extraction) // separated by "|" to be used in regular expressions. They are also // used as keys in an array that will contain the paths of all the // extracted files. - $allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S"); + $allowedExtensions = array("c", "cpp", "h", "inc", "ino", "o", "S", "hpp"); $files = array(); foreach ($allowedExtensions as $ext) $files[$ext] = array(); diff --git a/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php b/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php index d4e11b6..26f35b0 100644 --- a/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php +++ b/Symfony/src/Codebender/CompilerBundle/Tests/Controller/DefaultControllerFunctionalTest.php @@ -50,6 +50,30 @@ public function testInvalidInput() } + public function testSkchHppUnoSyntaxCheck() + { + $files = array(array("filename" => "SkchHpp.ino", "content" => "#include\nvoid setup()\n{\nSerial.begin(9600);\n\tint x = vardeb+5;\nSerial.println(x);\n}\n\nvoid loop()\n{\n\n}\n")); + $format = "syntax"; + $version = "105"; + $libraries = array('jsonlib' => array('files' => array('filename' => 'jsonhp.hpp', 'content' => "#define vardeb 3;\n"))); + $build = array("mcu" => "atmega328p", "f_cpu" => "16000000", "core" => "arduino", "variant" => "standard"); + + $data = json_encode(array("files" => $files, "format" => $format, "version" => $version, "libraries" => $libraries, "build" => $build)); + + $client = static::createClient(); + + $authorizationKey = $client->getContainer()->getParameter("authorizationKey"); + + $client->request('POST', '/' . $authorizationKey . '/v1', array(), array(), array(), $data); + + $response = json_decode($client->getResponse()->getContent(), true); + + $this->assertEquals($response["success"], true); + $this->assertTrue(is_numeric($response["time"])); + + } + + public function testBlinkUnoSyntaxCheck() { $files = array(array("filename" => "Blink.ino", "content" => "int led = 13;\nvoid setup() {pinMode(led, OUTPUT);}\nvoid loop() {\ndigitalWrite(led, HIGH);\ndelay(1000);\ndigitalWrite(led, LOW);\ndelay(1000);\n}\n"));