Skip to content
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

Wip/cpp #4

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Wip/cpp #4

wants to merge 11 commits into from

Conversation

vendethiel
Copy link
Member

No description provided.

Copy link
Contributor

@ingydotnet ingydotnet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work so far. Mostly just have suggestions for keeping this codebase more in sync with the others.

_data = _ast["data"];
}

json Runtime::exec_expr(json fragment) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'fragment' should be called 'expr' to match all the other implementations. Let's try to use the same names as much as possible across code bases. If a name conflicts for some reason I typically add an '_' to the end or some other predetermined unique-ifying method.

It's important for maintainers to be able to look at all the code bases and expect similar names, style and layout.

There will be times when people need to add a feature across 20 langs at once, and it should be relatively straightforward.


json Runtime::exec_dot(json::array_t fragment) {
json context = {}; // result of last call

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line has trailing whitespace. I have a vim plugin that highlights it in red :)

Maybe we can add some kind of git check hook to prevent things like this being committed/pushed.

namespace testml {

namespace {
bool is_all_lowercase(std::string const& s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions like this should go into a testml/util.cpp.

return _currentBlock["point"][name];
}

json Runtime::exec_dot(json::array_t fragment) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fragment should be 'calls'

return value[0].is_string() && value[0] == "=>";
}

void Runtime::run() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be called 'test'. Also try to put the methods in the same order as the coffee and others. All the others are in sync in this way.

for (auto& statement : _ast["code"]) {
exec_expr(statement);
}
testml_done();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should be 'testml_end'. I know it's just naming, but let's start out keeping things in sync. Makes it easier for me and others to jump in and help.

@@ -0,0 +1,29 @@
#include "wrapper.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't the wrapper methods go inside the runtime class? ie Why do we need a separate class here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a separate class. These functions will supposedly be reused by the Bridge"-r" and the Stdlib class, that's why it's separated into its own file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not certain that the bridge classes will (or should) know about and use testml runtime internals, but we can wait and see.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vendethiel now that we forged a common understanding on IRC, I get where you are going.

In TestML lingo a 'method' call like .foo or .Bar is called a 'callable'. .foo is a user defined bridge class callable (because it is lower case) and .Bar is a stdlib callable. Given that the testml::Bridge (base class for user defined TestMLBridge class) and testml::StdLib both need the wrapper stuff I think that wrapper should be a testml::Callable class and both testml::Bridge and testml::StdLib should inherit from it.

TestML_Run_TAP::run(file);
// tap.run();
testml::Bridge bridge;
bridge.bind("add", +[](int a, int b) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions (supposedly user defined) need to be in test/testml-bridge.cpp. That's where a user will add the C++ methods need to make the tests run.


using json = nlohmann::json;

json Bridge::call(std::string const& name, std::vector<json> const& args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the call method belongs in the bridge base class. This implies that a user defined bridge method would want to call this method directly. Maybe this method should be called can and it returns the bridge method pointer of the requested method, if found.

@ingydotnet
Copy link
Contributor

@vendethiel can you git rebase master && make clean test && git push -f on your wip/cpp branch? That will fix make test running on a fresh clone...

@ingydotnet
Copy link
Contributor

@vendethiel you should join #testml again. I'm in a nearby TZ for a while...

@vendethiel vendethiel force-pushed the wip/cpp branch 2 times, most recently from e3477a2 to 870b2a2 Compare October 17, 2018 15:50
@ingydotnet
Copy link
Contributor

C++ might be better implemented by generating C++ code from the Lingy AST.

That's how I did Bash support for testml. Walking a JSON structure seemed like
it was going to be tricky. Generating Bash code was much simpler, though I
haven't passed all the test suite yet.

@vendethiel been looking for you on #testml

Would like to discuss this approach with you.

@vendethiel
Copy link
Member Author

I've been connected a few times a week, rebased the PR late 2018.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants