Skip to content

Make target provide jerry-port.c #945

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

Merged
merged 1 commit into from
Mar 22, 2016

Conversation

franc0is
Copy link
Contributor

@franc0is franc0is commented Mar 9, 2016

This change-set pushes ports forward a bit and adds a Pebble port (happy to remove the latter if it is inappropriate).

JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com

@franc0is franc0is changed the title Allow external jerry-port.c, use those APIs more consistently Make target provide jerry-port.c, use those APIs more consistently Mar 9, 2016
@LaszloLango LaszloLango added the development Feature implementation label Mar 9, 2016
@zherczeg
Copy link
Member

zherczeg commented Mar 9, 2016

Please check CI, and I recommend to run make precommit before uploading a patch.

Signed-off-by message is incorrect. The following line should be at the end of the 3413e96 commit's message: 'JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com'.

@akosthekiss
Copy link
Member

As you also mention in your comment, this patch does several things. Since some of them are easier to accept than others, I'd suggest splitting it up to several PRs.

  • I'm all in for the use of jerry_port_errormsg in jrt-fatals. However, there are macros in jrt.h to use it (JERRY_ERROR_MSG).
  • The use of jerry_port_putchar in ecma-builtin-global.c is incorrect. E.g., current implementation prints the char literals backslash-u-zero-zero-zero-zero for a NUL char, while the suggested change here would print the NUL char itself. Similar incompatible change happens to the two-byte code points. It can be OK to use the port function to output a char to the console instead of printf but then it should be done correctly.
  • About extending the port API, I haven't come to a consensus with myself yet. I have a feeling that it starts duplicating the libc API with slightly different names, which is somewhat disturbing.

@franc0is
Copy link
Contributor Author

franc0is commented Mar 9, 2016

@zherczeg I am planning on squashing that commit after I address other comments. Thanks for taking a look!

@franc0is
Copy link
Contributor Author

franc0is commented Mar 9, 2016

@akiss77 Thank you for the thoughtful comments. I'll try to address them as best I can:

As you also mention in your comment, this patch does several things. Since some of them are easier to accept than others, I'd suggest splitting it up to several PRs.

OK - I think I can split it into 2 to start. One for the port, one for some of the CMakelist changes

I'm all in for the use of jerry_port_errormsg in jrt-fatals. However, there are macros in jrt.h to use it (JERRY_ERROR_MSG).

Ah, I did not see this. Will change.

The use of jerry_port_putchar in ecma-builtin-global.c is incorrect. E.g., current implementation prints the char literals backslash-u-zero-zero-zero-zero for a NUL char, while the suggested change here would print the NUL char itself.

As best I can tell, those two are equivalent. \u0000 is the unicode representation of the NUL character.

Similar incompatible change happens to the two-byte code points. It can be OK to use the port function to output a char to the console instead of printf but then it should be done correctly.

You are right. I need to encode those bytes before I output them with putchar. Thanks for catching this, I will fix it.

About extending the port API, I haven't come to a consensus with myself yet. I have a feeling that it starts duplicating the libc API with slightly different names, which is somewhat disturbing.

The reason I introduced jerry_port_abort rather than simply rely on libc functionality is that on my platform I want to do something specific to jerryscript (i.e. clean-up the JS context and show a dialog on the device) whereas libc's abort is necessarily more broad.

@franc0is franc0is force-pushed the more-flexible-ports branch from 3413e96 to da21cbd Compare March 10, 2016 01:46
@franc0is franc0is changed the title Make target provide jerry-port.c, use those APIs more consistently Make target provide jerry-port.c Mar 10, 2016
@franc0is
Copy link
Contributor Author

Split #955, #956, and #957 out of this PR

@franc0is franc0is force-pushed the more-flexible-ports branch 3 times, most recently from b2fd47b to dcd429e Compare March 10, 2016 01:58
return c;
}

void wtf(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a better name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the name of the abort API internal to the Pebble firmware, I cannot change it easily. Only option is to remove the Pebble port from this PR.

@franc0is franc0is force-pushed the more-flexible-ports branch 2 times, most recently from de8afbb to beeac2c Compare March 11, 2016 18:16
@franc0is
Copy link
Contributor Author

I removed the pebble port (it is of little use to those without access to the pebble firmware anyways), so this PR is quite simple now.

@LaszloLango LaszloLango added the jerry-port Related to the port API or the default port implementation label Mar 18, 2016
@franc0is
Copy link
Contributor Author

Ping! I think this does not overlap with the proposal in #964 and should be considered individually.

@LaszloLango
Copy link
Contributor

LGTM

@zherczeg
Copy link
Member

LGTM

JerryScript-DCO-1.0-Signed-off-by: François Baldassari francois@pebble.com
@franc0is franc0is force-pushed the more-flexible-ports branch from beeac2c to 94f8879 Compare March 21, 2016 20:08
@franc0is
Copy link
Contributor Author

rebased.

@LaszloLango LaszloLango merged commit 94f8879 into jerryscript-project:master Mar 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Feature implementation jerry-port Related to the port API or the default port implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants