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

Jshooks [DO NOT MERGE] #318

Open
wants to merge 85 commits into
base: dev
Choose a base branch
from
Open

Jshooks [DO NOT MERGE] #318

wants to merge 85 commits into from

Conversation

RichardAH
Copy link
Contributor

@RichardAH RichardAH commented May 24, 2024

High Level Overview of Change

Context of Change

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

RichardAH and others added 30 commits May 24, 2024 10:07
…ubfield slot_type slot_float compiling not tested
… float_sum float_sto float_sto_set float_invert float_divide float_one float_mantissa float_sign float_int float_log float_root
@RichardAH RichardAH force-pushed the dev branch 2 times, most recently from 77b8c83 to 532a471 Compare December 11, 2024 02:30
src/ripple/app/hook/impl/applyHook.cpp Outdated Show resolved Hide resolved
src/ripple/app/hook/impl/applyHook.cpp Outdated Show resolved Hide resolved
if (!sto.has_value())
returnJS(INVALID_ARGUMENT);

returnJS(__float_sto_set(hookCtx, applyCtx, j, sto->data(), sto->size()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

float_sto_set should return successful value as bigint(XFL)

Suggested change
returnJS(__float_sto_set(hookCtx, applyCtx, j, sto->data(), sto->size()));
int64_t const out = __float_sto_set(hookCtx, applyCtx, j, sto->data(), sto->size());
if (out < 0)
returnJS(out);
returnJSXFL(out);

Comment on lines +1433 to +1438
if (rt)
JS_FreeRuntime(rt);
if (ctx)
JS_FreeContext(ctx);
rt = NULL;
ctx = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my environment, Object Leaks error occurred when running a local build, but changing it as suggested resolved the error.

Also, in the quickjs sample code, JS_FreeRuntime is called after JS_FreeContext, as suggested.

Suggested change
if (rt)
JS_FreeRuntime(rt);
if (ctx)
JS_FreeContext(ctx);
rt = NULL;
ctx = NULL;
if (ctx)
JS_FreeContext(ctx);
if (rt)
JS_FreeRuntime(rt);
ctx = NULL;
rt = NULL;

Comment on lines +1577 to +1582
int expr_len =
snprintf(expr, 256, "%s(%d)",
callback ? "Callback" : "Hook",
hookArgument);

if (expr_len < 7 || expr_len == 256)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This change makes it possible to do #332 Request 2.

Suggested change
int expr_len =
snprintf(expr, 256, "%s(%d)",
callback ? "Callback" : "Hook",
hookArgument);
if (expr_len < 7 || expr_len == 256)
int expr_len =
snprintf(expr, 256, "%s(%d, otxn_json())",
callback ? "Callback" : "Hook",
hookArgument);
if (expr_len < 20 || expr_len == 256)

uint32_t write_len)
DEFINE_JS_FUNCNARG(
JSValue,
hook_account);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Unnecessary semicolon

Suggested change
hook_account);
hook_account)

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.

4 participants