diff --git a/Symfony/src/Codebender/LibraryBundle/Controller/DefaultController.php b/Symfony/src/Codebender/LibraryBundle/Controller/DefaultController.php index b57f85dc..90847c98 100644 --- a/Symfony/src/Codebender/LibraryBundle/Controller/DefaultController.php +++ b/Symfony/src/Codebender/LibraryBundle/Controller/DefaultController.php @@ -313,7 +313,7 @@ private function getLibraryExamples($library) // TODO: Not only .h and .cpp files in Arduino examples $notInoFilesFinder = new Finder(); - $notInoFilesFinder->files()->name('*.h')->name('*.cpp'); + $notInoFilesFinder->files()->name('*.h')->name('*.cpp')->name('*.hpp'); $notInoFilesFinder->in($path . "/" . $example->getRelativePath()); foreach ($notInoFilesFinder as $nonInoFile) { @@ -448,7 +448,7 @@ private function getExampleFilesFromDir($dir) { $filesFinder = new Finder(); $filesFinder->in($dir); - $filesFinder->name('*.cpp')->name('*.h')->name('*.c')->name('*.S')->name('*.pde')->name('*.ino'); + $filesFinder->name('*.hpp')->name('*.cpp')->name('*.h')->name('*.c')->name('*.S')->name('*.pde')->name('*.ino'); $files = array(); foreach ($filesFinder as $file) { diff --git a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php index 60b2594f..07a28aa1 100644 --- a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php +++ b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryData.php @@ -24,6 +24,20 @@ class LoadExternalLibraryData extends AbstractFixture implements OrderedFixtureI */ public function load(ObjectManager $objectManager) { + // A fake JSON library with hpp files in examples + $jsonlibr = new ExternalLibrary(); + $jsonlibr->setHumanName('JSON Library'); + $jsonlibr->setMachineName('jsonlib'); + $jsonlibr->setActive(true); + $jsonlibr->setVerified(false); + $jsonlibr->setDescription('A library containing hpp files in examples which should be correctly fetched'); + $jsonlibr->setSourceUrl('https://some/source/url.com'); + + // Reference to jsonlib library + $this->setReference('JsonLib', $jsonlibr); + $objectManager->persist($jsonlibr); + + // A fake version of the Adafruit GPS library $defaultLibrary = new ExternalLibrary(); $defaultLibrary->setHumanName('Default Arduino Library'); diff --git a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php index 29164ff8..8dc0022f 100644 --- a/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php +++ b/Symfony/src/Codebender/LibraryBundle/DataFixtures/ORM/LoadExternalLibraryExamplesData.php @@ -23,6 +23,20 @@ class LoadExternalLibraryExamplesData extends AbstractFixture implements Ordered */ public function load(ObjectManager $objectManager) { + /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $jsonlibr */ + + $jsonlibr = $this->getReference('JsonLib'); + + $jsonexampleb = new Example(); + $jsonexampleb->setName('IndentedPrintExample'); + $jsonexampleb->setLibrary($jsonlibr); + $jsonexampleb->setPath('jsonlib/examples/IndentedPrintExample/IndentedPrintExample.ino'); + $jsonexampleb->setBoards(null); + + // Persist the new example + $objectManager->persist($jsonexampleb); + + /* @var \Codebender\LibraryBundle\Entity\ExternalLibrary $defaultLibrary */ $defaultLibrary = $this->getReference('defaultLibrary'); diff --git a/Symfony/src/Codebender/LibraryBundle/Handler/DefaultHandler.php b/Symfony/src/Codebender/LibraryBundle/Handler/DefaultHandler.php index f6da0c22..06b4d4e0 100644 --- a/Symfony/src/Codebender/LibraryBundle/Handler/DefaultHandler.php +++ b/Symfony/src/Codebender/LibraryBundle/Handler/DefaultHandler.php @@ -618,7 +618,7 @@ private function getMachineNamesFromChildren($children) $machineNames = array(); foreach ($children as $child) { - if ($child['type'] == 'blob' && pathinfo($child['path'], PATHINFO_EXTENSION) == 'h') { + if ($child['type'] == 'blob' && (pathinfo($child['path'], PATHINFO_EXTENSION) == 'h' || pathinfo($child['path'], PATHINFO_EXTENSION) == 'hpp')) { $machineNames[] = pathinfo($child['path'], PATHINFO_FILENAME); } } diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryc.cpp b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryc.cpp new file mode 100755 index 00000000..61a96b67 --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryc.cpp @@ -0,0 +1 @@ +//nothing here \ No newline at end of file diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryh.h b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryh.h new file mode 100755 index 00000000..5f69aefb --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryh.h @@ -0,0 +1,5 @@ + +#ifdef ARDUINO + + +#endif diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryhp.hpp b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryhp.hpp new file mode 100755 index 00000000..697fd5a7 --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/JsonLibraryhp.hpp @@ -0,0 +1,5 @@ + + +#ifdef ARDUINO + +#endif diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/IndentedPrintExample.ino b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/IndentedPrintExample.ino new file mode 100644 index 00000000..cdcfd858 --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/IndentedPrintExample.ino @@ -0,0 +1,10 @@ +#include "PrintExamplehp.hpp" + +void setup() { +int x= varde+5; + +} + +void loop() { + // not used in this example +} diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/PrintExamplehp.hpp b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/PrintExamplehp.hpp new file mode 100644 index 00000000..c8189283 --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/examples/IndentedPrintExample/PrintExamplehp.hpp @@ -0,0 +1 @@ +#define varde 2 ; diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/jsonlib.h b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/jsonlib.h new file mode 100755 index 00000000..5f69aefb --- /dev/null +++ b/Symfony/src/Codebender/LibraryBundle/Resources/library_files/jsonlib/jsonlib.h @@ -0,0 +1,5 @@ + +#ifdef ARDUINO + + +#endif diff --git a/Symfony/src/Codebender/LibraryBundle/Resources/views/Default/page-logic.html.twig b/Symfony/src/Codebender/LibraryBundle/Resources/views/Default/page-logic.html.twig index 6c787cde..3a890214 100644 --- a/Symfony/src/Codebender/LibraryBundle/Resources/views/Default/page-logic.html.twig +++ b/Symfony/src/Codebender/LibraryBundle/Resources/views/Default/page-logic.html.twig @@ -138,8 +138,20 @@ $el.append($("") .attr("value", $name).text($name)); + }else if(endsWith(entry.filename, ".hpp") && !startsWith(entry.filename, ".") && !startsWith(entry.filename, "_") ) + { + var $lastSlash = entry.filename.lastIndexOf("/"); + var $header = entry.filename.substr($lastSlash+1); + var $name = $header.substr(0,$header.length -4); + $el.append($("") + .attr("value", $name).text($name)); + } - }); + + } + + + ); $el.prop("selected", false); update_machineName(); });