Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc)

 
  • 0 Vote(s) - 0 Average
Pawn [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc)
MattHudson
Offline

PS
Posts: 8
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: My House, San Miguel, Buenos Aires, Argentina, South America
#1
2019-04-20, 03:27 AM (This post was last modified: 2019-04-20, 05:08 PM by MattHudson. Edit Reason: Title changed )
Hi guys, i'm trying to convert this code:
Code:
   new
       cb_data[E_CALLBACK_DATA]
   ;

   cb_data[E_CALLBACK_DATA_ALLOC]      = ResolvedAlloc: address;
   cb_data[E_CALLBACK_DATA_POINTER]    = Function: pointer;
   cb_data[E_CALLBACK_DATA_OFFSET]     = offset;
   cb_data[E_CALLBACK_DATA_FORMAT][0]  = data1;
   cb_data[E_CALLBACK_DATA_FORMAT][1]  = data2;

To YSI 5.x Inline, but i really don't know what to do or how to start...
I read y_inline_impl2.inc documentation and note "How to convert from old y_inline to new y_inline:", but i didn't understand it.

Thanks for reading!
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#2
2019-04-20, 11:07 AM
That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA?
#Fede
Offline

Burgershot Member
Posts: 12
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: Montevideo, Uruguay
#3
2019-04-20, 04:43 PM
(2019-04-20, 11:07 AM)Y_Less Wrote: That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA?

He is trying to do this include work with YSI 5.x
MattHudson
Offline

PS
Posts: 8
Threads: 1
Joined: Apr 2019
Reputation: 0
Location: My House, San Miguel, Buenos Aires, Argentina, South America
#4
2019-04-20, 04:53 PM (This post was last modified: 2019-04-20, 04:57 PM by MattHudson.)
(2019-04-20, 11:07 AM)Y_Less Wrote: That doesn't look like y_inline code, that looks like you are directly manipulating internal data structures. That's not documented at all. What are you trying to do with that? Why are you modifying E_CALLBACK_DATA?

Well... basically i'm trying to upgrade this library because i'm using YSI 5.x on my code. I re-write most of it based on this documentation of converting old to new but i stopped on the lines i said up...

Thanks for answer!

[Edit] So sorry,i didn't see #Fede's answer.
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#5
2019-04-21, 11:14 PM
The documentation covers standard uses. This is a completely non-standard use, and exploits internal details. Those details have never been guaranteed to be stable and change a lot.

Fortunately, rewriting that isn't too hard because the timer doesn't accept any additional parameters (i.e. it is a `SetTimer` wrapper, not a `SetTimerEx` wrapper). Something like this:

PHP Code:
#if defined _inline_timers_included
    #endinput
#endif
#define _inline_timers_included

#include <YSI_Coding\y_inline>

forward InlineTimersHandler(Func:cb<>, bool:repeat);

public 
InlineTimersHandler(Func:cb<>, bool:repeat)
{
    @.
cb();
    if (!
repeat)
    {
        
Indirect_Release(cb);
    }
}

stock SetInlineTimer(Func:cb<>, delay, bool:repeat)
{
    new 
timer = SetTimerEx("InlineTimersHandler", delay, _:repeat, "ii", _:cb, _:repeat);
    if (
timer)
    {
        
Indirect_SetMeta(cb, timer);
        
Indirect_Claim(cb);
        return 
_:cb;
    }
    return 
0;
}

stock KillInlineTimer(cb)
{
    
KillTimer(Indirect_GetMeta(cb));
    
Indirect_Release(cb);
} 
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode