-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce new cli-tool #24
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
@@ -14,6 +14,8 @@ | |||
|
|||
namespace | |||
{ | |||
using uint = unsigned int; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this type isn't used anymore. Additionally, I advise against using this type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
source/tools/glkernel-cli/helper.cpp
Outdated
} | ||
|
||
bool canBeVec2(const cppexpose::Variant & v) { | ||
const auto arr = v.asArray(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conversion may fail, at least assert against nullptr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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;
//...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
{ | ||
public: | ||
Kernel4Object(int width, int height, int depth); | ||
glkernel::kernel4& kernel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.