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

Add new cross-platform APIs to Jsrt #766

Merged
merged 4 commits into from
Apr 9, 2016

Conversation

digitalinfinity
Copy link
Contributor

This change introduces the cross-platform API shape for JSRT.
It starts with the following assumptions:

  • Changing the definition of existing APIs is ok, as long as the effective shape doesnt change
    (so it's fine to use new macros etc as long as signature/calling convention/linkage etc doesn't change)
  • Existing APIs which take wchar_t* as a parameter will be exposed only on Windows
  • New variants of these APIs that take in UTF-8 strings will be exposed on all platforms

Here is a summary of the changes:

New macros introduced:
CHAKRA_CALLBACK - Calling convention attribute of callback functions consumed by jsrt APIs. Used in place of Win32 CALLBACK macro.
CHAKRA_API - Calling convention, linkage and return type of Jsrt APIs (always returns JsErrorCode). Used in place of Win32 STDAPI_ macro.

New types introduced
ChakraCookie - Type of cookies consumed by Jsrt Apis. Used in place of Win32 DWORD_PTR datatype.
JsSerializedScriptLoadUtf8SourceCallback - Callback called to load source code of serialized script encoded as utf8

Following APIs become WIN32 only:
JsParseScript
JsParseScriptWithFlags
JsRunScript
JsExperimentalApiRunModule
JsSerializeScript
JsParseSerializedScriptWithCallback
JsRunSerializedScriptWithCallback
JsParseSerializedScript
JsRunSerializedScript
JsGetPropertyIdFromName
JsGetPropertyNameFromId
JsPointerToString
JsStringToPointer

New APIs introduced (available on all platforms):
JsParseScriptUtf8
JsParseScriptWithAttributesUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsSerializeScriptUtf8
JsParseSerializedScriptUtf8
JsRunSerializedScriptUtf8
JsGetPropertyIdFromNameUtf8
JsGetPropertyNameFromIdUtf8
JsPointerToStringUtf8
JsStringToPointerUtf8

Couple notes:

  •  All utf8 strings are passed in as char*
    
  •  All string parameters in the new APIs are utf8 (e.g source, url etc).
    

This change introduces the cross-platform API shape for JSRT.
It starts with the following assumptions:
-  Changing the definition of existing APIs is ok, as long as the effective shape doesnt change
   (so it's fine to use new macros etc as long as signature/calling convention/linkage etc doesn't change)
-  Existing APIs which take wchar_t* as a parameter will be exposed only on Windows
-  New variants of these APIs that take in UTF-8 strings will be exposed on *all* platforms

Here is a summary of the changes:

New macros introduced:
CHAKRA_CALLBACK - Calling convention attribute of callback functions consumed by jsrt APIs. Used in place of Win32 CALLBACK macro.
CHAKRA_API - Calling convention, linkage and return type of Jsrt APIs (always returns JsErrorCode). Used in place of Win32 STDAPI_ macro.

New types introduced
ChakraCookie - Type of cookies consumed by Jsrt Apis. Used in place of Win32 DWORD_PTR datatype.
JsSerializedScriptLoadUtf8SourceCallback - Callback called to load source code of serialized script encoded as utf8

Following APIs become WIN32 only:
JsParseScript
JsParseScriptWithFlags
JsRunScript
JsExperimentalApiRunModule
JsSerializeScript
JsParseSerializedScriptWithCallback
JsRunSerializedScriptWithCallback
JsParseSerializedScript
JsRunSerializedScript
JsGetPropertyIdFromName
JsGetPropertyNameFromId
JsPointerToString
JsStringToPointer

New APIs introduced (available on all platforms):
JsParseScriptUtf8
JsParseScriptWithAttributesUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsSerializeScriptUtf8
JsParseSerializedScriptUtf8
JsRunSerializedScriptUtf8
JsGetPropertyIdFromNameUtf8
JsGetPropertyNameFromIdUtf8
JsPointerToStringUtf8
JsStringToPointerUtf8

Couple notes:
-      All utf8 strings are passed in as char*
-      All string parameters in the new APIs are utf8 (e.g source, url etc).
@digitalinfinity
Copy link
Contributor Author

@dilijev fixed the whitespace issue. @agarwal-sandeep @ianwjhalliday any comments? I think @curtisman @Yongqu @liminzhu have already reviewed so if you guys are fine with this, I'll merge to master


typedef uintptr_t ChakraCookie;
typedef unsigned char* ChakraBytePtr;
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add comments at all #else and #endif to mark which #if it refers to? makes it easier to read the definition blocks

@digitalinfinity
Copy link
Contributor Author

Thanks @agarwal-sandeep. Updated the PR.

@agarwal-sandeep
Copy link
Collaborator

LGTM

@ianwjhalliday
Copy link
Collaborator

👍

@dilijev
Copy link
Contributor

dilijev commented Apr 8, 2016

@agarwal-sandeep Do you know why the majority of ChakraCommon.h is indented without a block wrapping it? (Starting at line 69)

@dilijev
Copy link
Contributor

dilijev commented Apr 8, 2016

LGTM

@agarwal-sandeep
Copy link
Collaborator

@dilijev it has been like this when we split jsrt.h for USE_EDGEMODE_JSRT

@digitalinfinity
Copy link
Contributor Author

Thanks all- going to merge this guy to master

@chakrabot chakrabot merged commit 5c74acc into chakra-core:master Apr 9, 2016
chakrabot pushed a commit that referenced this pull request Apr 9, 2016
Merge pull request #766 from digitalinfinity:linux_jsrt_master
This change introduces the cross-platform API shape for JSRT.
It starts with the following assumptions:
-  Changing the definition of existing APIs is ok, as long as the effective shape doesnt change
   (so it's fine to use new macros etc as long as signature/calling convention/linkage etc doesn't change)
-  Existing APIs which take wchar_t* as a parameter will be exposed only on Windows
-  New variants of these APIs that take in UTF-8 strings will be exposed on *all* platforms

Here is a summary of the changes:

New macros introduced:
CHAKRA_CALLBACK - Calling convention attribute of callback functions consumed by jsrt APIs. Used in place of Win32 CALLBACK macro.
CHAKRA_API - Calling convention, linkage and return type of Jsrt APIs (always returns JsErrorCode). Used in place of Win32 STDAPI_ macro.

New types introduced
ChakraCookie - Type of cookies consumed by Jsrt Apis. Used in place of Win32 DWORD_PTR datatype.
JsSerializedScriptLoadUtf8SourceCallback - Callback called to load source code of serialized script encoded as utf8

Following APIs become WIN32 only:
JsParseScript
JsParseScriptWithFlags
JsRunScript
JsExperimentalApiRunModule
JsSerializeScript
JsParseSerializedScriptWithCallback
JsRunSerializedScriptWithCallback
JsParseSerializedScript
JsRunSerializedScript
JsGetPropertyIdFromName
JsGetPropertyNameFromId
JsPointerToString
JsStringToPointer

New APIs introduced (available on all platforms):
JsParseScriptUtf8
JsParseScriptWithAttributesUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsRunScriptUtf8
JsExperimentalApiRunModuleUtf8
JsSerializeScriptUtf8
JsParseSerializedScriptUtf8
JsRunSerializedScriptUtf8
JsGetPropertyIdFromNameUtf8
JsGetPropertyNameFromIdUtf8
JsPointerToStringUtf8
JsStringToPointerUtf8

Couple notes:
-      All utf8 strings are passed in as char*
-      All string parameters in the new APIs are utf8 (e.g source, url etc).
@digitalinfinity digitalinfinity deleted the linux_jsrt_master branch June 30, 2016 23:30
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.

6 participants