Passing arguments to a function
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
So I actually rewrote y_va just yesterday! Doing what you want there has always been awkward and there were several solutions from macros up to y_va, but they all had downsides. I'll write a bit more about this later, but in short:

1) Macros are fragile and prone to breaking code without great care. They also bloat your code and have length limits.

2) Explicit assembly requires knowing assembly.

3) y_va needs wrappers for every function you would want - "format" was wrapped (as "va_format") but if you wanted something else you needed assembly again - "mysql_tquery" wasn't wrapped.

4) Your method I've not seen before, but it won't work with strings or arrays.

As I said though, if you have the very newest version of YSI, I've written a new "___" macro (triple underscore, like the "..." triple dot (elipses)):

PHP код:
m_query(const query[], const callback[] = "", const format[] = ""GLOBAL_TAG_TYPES:...)
{
    switch (
numargs())
    {
        case 
02:
            
// Probably bad somehow.
            
return;
        case 
1:
            
mysql_tquery(gSQLquery);
        default:
            
mysql_tquery(gSQLquerycallbackformat___(3));
    }

Using "GLOBAL_TAG_TYPES" just means you can pass many different types of data in, not just floats and integers, but use "{Float, _}" if you prefer. "___(3)" means "all remaining parameters after the third one".
thanks, it is working as I want.
Issue not related to the topic, y_va include gives warnings on lines 336 and 428.
Код:
CodeScanGetMatchDisasm(m, dctx, len);
CodeScanGetMatchDisasm(m, dctx, -12);
function declared as
Код:
stock CodeScanGetMatchDisasm(csm[CodeScanner], ctx[DisasmContext]) {
	// Doesn't do any decompilation, just gets the information for decompiling
	// the currently found match.
	ctx[DisasmContext_end_ip] = 0,
	ctx[DisasmContext_start_ip] = ctx[DisasmContext_nip] = ctx[DisasmContext_cip] = csm[CodeScanMatch_cip];
}
Reply


Messages In This Thread
Passing arguments to a function - by Scottas - 04.06.2017, 10:47
Re: Passing arguments to a function - by GoldenLion - 04.06.2017, 11:12
Re: Passing arguments to a function - by Dayvison_ - 04.06.2017, 12:06
Re: Passing arguments to a function - by Scottas - 04.06.2017, 12:07
Re: Passing arguments to a function - by Scottas - 04.06.2017, 21:24

Forum Jump:


Users browsing this thread: 1 Guest(s)