Skip to content

Move version numbers to public headers #2556

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
Oct 19, 2018

Conversation

Achie72
Copy link
Member

@Achie72 Achie72 commented Oct 8, 2018

JERRY_SNAPSHOT_VERSION and JERRY_DEBUGGER_VERSION were moved into public headers, to grant access to them.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth [email protected]


Enum that contains the following elements:

- JERRY_VERSION_API_MAJOR - signals the major API version
Copy link
Member

Choose a reason for hiding this comment

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

comment: returns the...
Please also modify the others.


```c
uint32_t
jerry_get_api_major_version(void);
Copy link
Member

Choose a reason for hiding this comment

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

These functions are redundant, aren't they?


Enum that contains the following elements:

- JERRY_VERSION_API_MAJOR - signals the major API version
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we would change the "signals" word, to "represents" / "describes"?

- JERRY_VERSION_API_MAJOR - signals the major API version
- JERRY_VERSION_API_MINOR - signals the minor API version
- JERRY_VERSION_DEBUGGER - signals the debugger version
- JERRY_VERSION_SNAPSHOT - signals the snapshot version
Copy link
Contributor

Choose a reason for hiding this comment

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

As these values are only used for one method we should add a "see also" block to refer the method which uses this.

- return value
- API minor version

## jerry_get_component_version
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have this method, why do we need the previous two? (get_api_minor & get_api_major)?

**Summary**

Get the component version described in parameter. If the defined components
asked is not available, then it returns 0, as well as a default value.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by: ..it returns 0, as well as a default value. ? This will return a zero and another value?

```
- `component` - A jerry_versions_t signaling desired component.
- return value
- API major version
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK: this is a typo here: the return value is the version of the requested component.


```c
uint32_t api_version;
api_version = jerry_get_component_version(API_MAJOR_VERSION);
Copy link
Contributor

Choose a reason for hiding this comment

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

There is no API_MAJOR_VERSION described in the jerry_version_t enum.

@@ -5558,6 +5623,7 @@ jerry_get_arraybuffer_byte_length (const jerry_value_t value);
```

**See also**

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this empty line needed here?

* Get the component version described in parameter.
*
* Note:
* * Debugger and snapshot versions are set to undefined, unless they are turned on.
Copy link
Contributor

Choose a reason for hiding this comment

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

The comment states that the "debugger/snapshot version are set to undefined" if they are turned off. But in the code the return value will be 0. That looks pretty defined for me....

* * Debugger and snapshot versions are set to undefined, unless they are turned on.
*
* @return a uint32_t containing:
* API major, API minor, debugger and snapshot version.
Copy link
Contributor

Choose a reason for hiding this comment

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

So.. this will return all of these values? in one uint32_t?

* API major, API minor, debugger and snapshot version.
*/
uint32_t
jerry_get_component_version (jerry_version_t component) /**< the component, the version of which we want */
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment reads a bit awkward.

Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

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

Please, convince me that we need functions to achieve this. include/jerryscript-core.h already has JERRY_API_MAJOR_VERSION and JERRY_API_MINOR_VERSION as macro-defined constants. api/jerry-snapshot.h already has JERRY_SNAPSHOT_VERSION, which could be moved to include/jerryscript-snapshot.h. And debugger/debugger.h already has JERRY_DEBUGGER_VERSION, which could be moved to include/jerryscript-debugger.h. I see no point in hiding these behind functions nor introducing a new enum to programmatically choose from different version numbers. All that's needed is to publish two already existing macros in public headers. IMO.

@Achie72
Copy link
Member Author

Achie72 commented Oct 11, 2018

It could help, if we only have an binary file, to confirm, which version of jerry is it exactly, to avoid confusion.

@akosthekiss
Copy link
Member

I don't really understand this use case.

If "binary file" means a library (most probably, a static library) then it MUST be accompanied by the appropriate public header files to be useful. But then the macros in the public header file(s) specify the versions. (Using a libxxx.a without an xxx.h is certainly possible at the technical level but that's called reverse engineering and is not a use case library developers (== us) have to support.)

If "binary file" means an executable application then it's the task of the application to identify itself or the components it contains. In this case, the application source code can contain JERRY_API_MAJOR_VERSION just as easily as jerry_get_component_version (...). If the app source contains any of these then the version can be confirmed (e.g., printed by app --version), if not, then functions don't help either.

@zherczeg
Copy link
Member

He is probably talking about dynamic modules, where you load a module and try to confirm the module is what you expected.

@akosthekiss
Copy link
Member

Dynamic libraries are also a tricky thing. If one knows the API version of the library (the major version at least) then one may know what functions can be expected to exist (at least the minimum subset). But that means that one already has to know the value of JERRY_API_MAJOR_VERSION even to call jerry_get_component_version (JERRY_VERSION_API_MAJOR) (because only at a given major version would it be guaranteed to exist). Almost a deadlock.

Moreover, although using jerry-core as a dynamic library is certainly possible, the device class where that's possible is pretty much not the main application area of the engine.

@Achie72
Copy link
Member Author

Achie72 commented Oct 12, 2018

The moving of JERRY_SNAPSHOT_VERSION and JERRY_DEBUGGER_VERSION indeed seems a more simple solution, than the getter functions. If we don't want to complicate the code by introducing these changes, then i can modify the PR with your suggestion, if the other reviewers have no problem with it. @zherczeg @galpeter ?

@zherczeg
Copy link
Member

I have no strong opinion about this, so whatever is good for me.

JERRY_SNAPSHOT_VERSION and JERRY_DEBUGGER_VERSION were moved into public headers, to grant access to them.

JerryScript-DCO-1.0-Signed-off-by: Bela Toth [email protected]
@Achie72 Achie72 changed the title Add API function to retrieve API, debugger, and snapshot version Move version numbers to public headers Oct 15, 2018
Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

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

LGTM

@akosthekiss akosthekiss added api Related to the public API snapshot Related to the snapshot feature debugger Related to the debugger labels Oct 17, 2018
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

LGTM

@zherczeg zherczeg merged commit f8f691d into jerryscript-project:master Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to the public API debugger Related to the debugger snapshot Related to the snapshot feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants