[Include] TDW CJump - nonlocal gotos in Pawn
#1

TDW CJump
Description
This library provides you the opportunity to use nonlocal gotos as well as in C language. It is important to note that this one supports JIT-plugin.
Documentation
In Pawn there is a goto operator which provides an unconditional jump from the 'goto' to a labeled statement in the same function. This operator can only jump within the same function, but the library provides a nonlocal unconditional jump between functions.

Functions
NameDescription
setjmpSaves the current environment into the variable for later use by the function longjmp.
Parameters:
  • env[JmpBuf] - buffer for storing environments.
  • &retval - the reference to a variable into which will be written the value from the function longjmp.
longjmpRestores the environment saved by the function setjmp.
Parameters:
  • env[JmpBuf] - buffer for storing environments.
  • val - return value.
Example
pawn Код:
new jmp[JmpBuf];

main() {
    new ret;
    setjmp(jmp, ret);  // save the current environment into the buffer.

    print(!"main()");  // this code will be executed several times.

    if (ret != 2) {    // we need to use the condition to avoid an infinite loop.
        somefunc(ret);
    }
}

somefunc(ret)
{
    print(!"somefunc()");
    longjmp(jmp, ret+1);  // global goto.
}
Download
github
Author: VVWVV
Licensed under the zlib.
Reply
#2

based on script, Good job.

i bet the most of people (me too ) here, don't know what is this.
suggestion: you should add more informations.
Reply
#3

Quote:
Originally Posted by XeonMaster
Посмотреть сообщение
based on script, Good job.

i bet the most of people (me too ) here, don't know what is this.
suggestion: you should add more informations.
Thank you!

I added more information in the documentation section.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)