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 natives to work with 64 bit Protobuf values #943

Merged
merged 6 commits into from Mar 4, 2019

Conversation

@komashchenko
Copy link
Contributor

komashchenko commented Dec 29, 2018

No description provided.

Copy link
Member

asherkin left a comment

This looks pretty good - one inline about alignment requirements that would be good to address (but isn't strictly required.)

GET_FIELD_NAME_OR_ERR();

int64 *ret;
pCtx->LocalToPhysAddr(params[3], reinterpret_cast<cell_t **>(&ret));

This comment has been minimized.

Copy link
@asherkin

asherkin Dec 29, 2018

Member

This isn't strictly legal as cell_t and int64 have differing alignment requirements (4 and 8 bytes respectively) and this could end up unaligned. (Which is just a perf penalty on x86, but can be fatal on other architectures.)

It would be better to use a temporary int64 variable and combine manually.

This comment applies generally throughout the PR.

@komashchenko

This comment has been minimized.

Copy link
Contributor Author

komashchenko commented Jan 4, 2019

@asherkin As I understand, do not need to add legacy API ?
#946 (comment)

@@ -747,6 +827,7 @@ static cell_t smn_PbAddMessage(IPluginContext *pCtx, const cell_t *params)
REGISTER_NATIVES(protobufnatives)
{
{"PbReadInt", smn_PbReadInt},
{"PbReadInt64", smn_PbReadInt64},

This comment has been minimized.

Copy link
@peace-maker

peace-maker Jan 4, 2019

Contributor

You missed those from the non-methodmap api.

@kireevvv

This comment has been minimized.

Copy link

kireevvv commented Mar 3, 2019

Add this function is very necessary

Copy link
Member

KyleSanderson left a comment

I don't run this game anymore unfortunately but this looks good if the code works. I don't like the macro hell but that's existing so: not your problem. If you can use c++ casting instead of c that would be appreciated but beyond that this looks good bud and I'll merge in a day regardless.

Thanks for being patient.

cell_t *value;
pCtx->LocalToPhysAddr(params[3], &value);
int64 temp;
((cell_t *)&temp)[0] = value[0];

This comment has been minimized.

Copy link
@KyleSanderson

KyleSanderson Mar 3, 2019

Member

Nit: static_cast please.

@KyleSanderson KyleSanderson merged commit 8031e42 into alliedmodders:master Mar 4, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.