Conversation
Rewrite CLI using cppassist::CommandLineProgram
…i-tool # Conflicts: # source/tools/glkernel-cli/main.cpp
#22 cli api changes
…ascript, and kernel export to JSON
Add --force switch
Working:
- Creating kernels from JS (currently only kernel<float>)
- Calling e.g. kernel.sequence.uniform()
Missing:
- Expose more functions
- Added scale::range and sort::distance - Figured out JS default parameters (see sort.distance) - Started JS-sided detection of parameter type
…rn reference at end of file
…ing implementation to cpp file
Cleanup helper.h
Return kernel object in every js function
|
|
||
| namespace | ||
| { | ||
| using uint = unsigned int; |
There was a problem hiding this comment.
It seems like this type isn't used anymore. Additionally, I advise against using this type.
There was a problem hiding this comment.
This was a compile fix for the to-be-deprecated glkernel-cmd.
source/tools/glkernel-cli/main.cpp
Outdated
| } | ||
|
|
||
| std::string extractOutputFormat(const std::string & outFileName, const bool shouldConvert) { | ||
| if (outFileName.find('.') == std::string::npos) |
There was a problem hiding this comment.
There is a doubled search for '.' in the string. Search it once (outFileName.find_last_of('.')), store the result and reuse it both times.
source/tools/glkernel-cli/main.cpp
Outdated
|
|
||
|
|
||
| std::string extractInputFormat(const std::string & inFileName) { | ||
| if (inFileName.find('.') == std::string::npos) |
There was a problem hiding this comment.
There is a doubled search for '.' in the string. Search it once (inFileName.find_last_of('.')), store the result and reuse it both times.
Generally, you're performing file name operations, that are implemented in cppassist as well: https://github.com/cginternals/cppassist/blob/master/source/cppassist/include/cppassist/fs/FilePath.h
| } | ||
|
|
||
| bool canBeVec2(const cppexpose::Variant & v) { | ||
| const auto arr = v.asArray(); |
There was a problem hiding this comment.
This conversion may fail, at least assert against nullptr.
There was a problem hiding this comment.
If this returns a nullptr we return false, since this conversion did not work.
source/tools/glkernel-cli/helper.cpp
Outdated
| float min = std::numeric_limits<float>::max(); | ||
| float max = std::numeric_limits<float>::min(); | ||
| const auto end = kernel.cend(); | ||
| for (auto it = kernel.cbegin(); it != end; ++it) |
There was a problem hiding this comment.
I suggest adding a const-overloaded begin and end to tkernel and use a range-based for loop instead:
for (const auto & p : kernel)
{
const auto x = p.x;
const auto y = p.y;
//...
}| { | ||
| public: | ||
| Kernel4Object(int width, int height, int depth); | ||
| glkernel::kernel4& kernel(); |
There was a problem hiding this comment.
Please switch to 4 spaces instead of tabs.
|
|
||
| #include <cppassist/logging/logging.h> | ||
|
|
||
| void forEachCell(cppexpose::VariantArray * depthArray, std::function<void(const cppexpose::Variant&)> lambda) |
There was a problem hiding this comment.
I suggest you provide an forEachCell overload where the lambda takes the current index as second parameter.
|
|
||
|
|
||
| std::string JsonExporter::stringify(const cppexpose::Variant &array) { | ||
| auto outputMode = m_beautify |
There was a problem hiding this comment.
The outputMode may be const, too.
| auto outputMode = m_beautify | ||
| ? cppexpose::JSON::OutputMode::Beautify | ||
| : cppexpose::JSON::OutputMode::Compact; | ||
| return cppexpose::JSON::stringify(array, outputMode); |
There was a problem hiding this comment.
Once cginternals/cppexpose#56 is implemented, you should use the interface writing to a stream.
| JsonImporter.h | ||
| PngExporter.h | ||
| helper.h | ||
| ) |
There was a problem hiding this comment.
We choose to indent the closing brace as much as the line containing the opening one. In this case: no identation.
Update readme: add cli-tool manual
This PR introduces the new command line interface for glkernel.
As discussed in our e-mail, there are still open issues which can be found under https://github.com/p-otto/glkernel/issues
#25 should be merged before this, to make the code generation work correctly.
Additionally, #26 should be merged together with this, as it removes the old command line interface.