• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] [Help] Convert code written on YSI 4.x to 5.x(y_inline and y_malloc)
#1
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!
  Reply
#2
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?
  Reply
#3
(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
  Reply
#4
(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.
  Reply
#5
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<>, delaybool:repeat)

{

    new 
timer SetTimerEx("InlineTimersHandler"delay_:repeat"ii"_:cb_:repeat);

    if (
timer)

    {

        
Indirect_SetMeta(cbtimer);

        
Indirect_Claim(cb);

        return 
_:cb;

    }

    return 
0;

}



stock KillInlineTimer(cb)

{

    
KillTimer(Indirect_GetMeta(cb));

    
Indirect_Release(cb);


  Reply


Forum Jump: