[No] Native support for pointers as integers

Moderator: GZDoom Developers

Native support for pointers as integers

Postby Apeirogon » Mon Nov 22, 2021 4:07 am

For testing reasons I needed to get the address of an objects, to differentiate between them from each other.
And the only way its possible to get it is
Code: Select allExpand view
int self_pointer = string.format("%p", self).toint(10);

which is works, yes, but it looks like a hack.

Add native support for pointers as integers please.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Native support for pointers as integers

Postby Graf Zahl » Mon Nov 22, 2021 4:16 am

No, no, no. If you want to differentiate between objects, compare the pointers. It won't even work because pointers are 64 bit values and integers are 32 bit values.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Native support for pointers as integers

Postby Apeirogon » Mon Nov 22, 2021 4:42 am

Problem in this case is, its impossible to transfer actors pointer, as a zscript thing, through network event to the ui side.
I use on screen custom made table that, internally, uses actor pointers to differentiate them. Because dumping all info into the console becomes old too fast with more than one target.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Native support for pointers as integers

Postby Graf Zahl » Mon Nov 22, 2021 5:17 am

In that case a string with "%p" output is your only option.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Native support for pointers as integers

Postby Apeirogon » Mon Nov 22, 2021 7:38 am

I made this instead
Code: Select allExpand view
class six_four_pointer
{
    private uint mantissa, radix;
    void construct(string s)
    {
        int substring_len = s.Length()/2;
        mantissa = s.Mid(0, substring_len ).toint(16);
        radix = s.Mid(substring_len, substring_len ).toint(16);
    }

    clearscope uint get_pointer(bool main = true) const
    {
        if(main)
            return mantissa;
        else
            return radix;
    }
}

It still cheaper than comparing >9000 strings to find corresponding (to the actor) entries in the table.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Native support for pointers as integers

Postby Graf Zahl » Mon Nov 22, 2021 8:19 am

No, that's actually not cheaper at all. You are totally overestimating the cost of a string comparison. The internal overhead of calling get_pointer twice is magnitudes higher than doing a string comparison due to the call oveehead of scripted code.,
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Native support for pointers as integers

Postby Apeirogon » Mon Nov 22, 2021 1:05 pm

'Tested' both integer and string versions and they work approximately with the same speed.
'tested', because if I made more than around 30 "send network event" calls per single tick, Gzdoom crashes WITHOUT very fatal error window.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Native support for pointers as integers

Postby Redneckerz » Tue Nov 23, 2021 11:54 am

Apeirogon wrote:'Tested' both integer and string versions and they work approximately with the same speed.
'tested', because if I made more than around 30 "send network event" calls per single tick, Gzdoom crashes WITHOUT very fatal error window.

If the answer is '''No, and here is why'' i fail to understand why you then go on the defence for your own implementation which does the same but is likely more expensive in the long run.
User avatar
Redneckerz
To it's ports i may have seen
Spotlight Team
 
Joined: 25 Nov 2019
Discord: Redneckerz#8399
Operating System: Windows 10/8.1/8/201x 64-bit
Graphics Processor: Intel (Modern GZDoom)

Re: Native support for pointers as integers

Postby Apeirogon » Wed Nov 24, 2021 9:48 am

????
I done X in Y way
Do X in Z way instead, its faster this way
I compared Y and Z ways, they works approximately with same speed, but I had small testing sample set, due to a bug
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Native support for pointers as integers

Postby Rachael » Wed Nov 24, 2021 11:34 am

I think this topic has reached an appreciable level of tug roping and hair pulling now at this point.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Debian-like Linux (Debian, Ubuntu, Mint, etc) 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests