Add a data argument in INI/SMC_ParseFile() to pass through to callbacks (bug 6228)

This commit is contained in:
Arkshine
2015-07-29 22:20:16 +02:00
parent 2162059352
commit 6d6a1c1ab0
4 changed files with 66 additions and 39 deletions

View File

@ -91,11 +91,12 @@ native INI_DestroyParser(&INIParser:handle);
* @param file A string containing the file path.
* @param line An optional by reference cell to store the last line number read.
* @param col An optional by reference cell to store the last column number read.
* @param data An optional handle or value to pass through to callback functions
*
* @return An SMCParseError result.
* @error Invalid or corrupt handle.
*/
native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0);
native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0, any:data = 0);
/**
* Sets the INI_ParseStart function of a parse handle.
@ -105,10 +106,11 @@ native bool:INI_ParseFile(INIParser:handle, const file[], &line = 0, &col = 0);
* Called when parsing is started.
*
* @param handle A handle to an INI Parse structure.
* @param data Handle or value passed in INI_ParseFile
*
* @noreturn
*
* public OnParseStart(INIParser:handle)
* public OnParseStart(INIParser:handle, any:data)
* -
* @param handle Handle to an INI Parse structure.
* @param func A ParseStart callback.
@ -127,10 +129,11 @@ native INI_SetParseStart(INIParser:handle, const func[]);
*
* @param handle A handle to an INI Parse structure.
* @param halted True if abnormally halted, false otherwise.
* @param data Handle or value passed in INI_ParseFile
*
* @noreturn
*
* public OnParseEnd(INIParser:handle, bool:halted)
* public OnParseEnd(INIParser:handle, bool:halted, any:data)
* -
* @param handle Handle to an INI Parse structure.
* @param func A ParseEnd callback.
@ -155,9 +158,11 @@ native INI_SetParseEnd(INIParser:handle, const func[]);
* @param extra_tokens True if extra tokens were detected on the line.
* @param curtok Contains current token in the line where the section name starts.
* You can add to this offset when failing to point to a token.
* @param data Handle or value passed in INI_ParseFile
*
* @return True to keep parsing, false otherwise.
*
* public bool:OnNewSection(INIParser:handle, const section[], bool:invalid_tokens, bool:close_bracket, bool:extra_tokens, curtok)
* public bool:OnNewSection(INIParser:handle, const section[], bool:invalid_tokens, bool:close_bracket, bool:extra_tokens, curtok, any:data)
*
* KeyValue:
* Called when the parser finds a new key/value pair.
@ -170,9 +175,11 @@ native INI_SetParseEnd(INIParser:handle, const func[]);
* @param quotes Whether value was enclosed in quotes.
* @param curtok Contains the token index of the start of the value string.
* This can be changed when returning false.
* @param data Handle or value passed in INI_ParseFile
*
* @return True to keep parsing, false otherwise.
*
* public bool:OnKeyValue(INIParser:handle, const key[], const value[], bool:invalid_tokens, bool:equal_token, bool:quotes, curtok)
* public bool:OnKeyValue(INIParser:handle, const key[], const value[], bool:invalid_tokens, bool:equal_token, bool:quotes, curtok, any:data)
* -
* @param handle Handle to an INI Parse structure.
* @param kv A KeyValue callback.
@ -193,10 +200,11 @@ native INI_SetReaders(INIParser:smc, const kvFunc[], const nsFunc[] = "" );
* @param line Contents of line.
* @param lineno The line number it occurs on.
* @param curtok Pointer to optionally store failed position in string.
* @param data Handle or value passed in INI_ParseFile
*
* @return True to keep parsing, false otherwise.
*
* public bool:OnRawLine(INIParser:smc, const line[], lineno, curtok)
* public bool:OnRawLine(INIParser:smc, const line[], lineno, curtok, any:data)
*
* @param handle Handle to an INI Parse structure.
* @param func A RawLine callback.

View File

@ -122,11 +122,12 @@ native SMC_DestroyParser(&SMCParser:handle);
* @param file A string containing the file path.
* @param line An optional by reference cell to store the last line number read.
* @param col An optional by reference cell to store the last column number read.
* @param data An optional handle or value to pass through to callback functions
*
* @return An SMCParseError result.
* @error Invalid or corrupt handle.
*/
native SMCError:SMC_ParseFile(SMCParser:handle, const file[], &line = 0, &col = 0);
native SMCError:SMC_ParseFile(SMCParser:handle, const file[], &line = 0, &col = 0, any:data = 0);
/**
* Sets the SMC_ParseStart function of a parse handle.
@ -136,10 +137,11 @@ native SMCError:SMC_ParseFile(SMCParser:handle, const file[], &line = 0, &col =
* Called when parsing is started.
*
* @param handle Handle to an SMC Parse structure.
* @param data Handle or value passed in SMC_ParseFile
*
* @noreturn
*
* public OnParseStart(SMCParser:handle)
* public OnParseStart(SMCParser:handle, any:data)
* -
* @param handle Handle to an SMC Parse structure.
* @param func A ParseStart callback.
@ -159,10 +161,11 @@ native SMC_SetParseStart(SMCParser:handle, const func[]);
* @param handle Handle to an SMC Parse structure.
* @param halted True if abnormally halted, false otherwise.
* @param failed True if parsing failed, false otherwise.
* @param data Handle or value passed in SMC_ParseFile
*
* @noreturn
*
* public OnParseEnd(SMCParser:handle, bool:halted, bool:failed)
* public OnParseEnd(SMCParser:handle, bool:halted, bool:failed, any:data)
* -
* @param handle Handle to an SMC Parse structure.
* @param func A ParseEnd callback.
@ -183,10 +186,11 @@ native SMC_SetParseEnd(SMCParser:handle, const func[]);
*
* @param handle Handle to an SMC Parse structure.
* @param name String containing section name.
* @param data Handle or value passed in SMC_ParseFile
*
* @return An SMCResult action to take.
*
* public SMCResult:OnNewSection(SMCParser:handle, const name[])
* public SMCResult:OnNewSection(SMCParser:handle, const name[], any:data)
*
* KeyValue:
* Called when the parser finds a new key/value pair.
@ -194,19 +198,21 @@ native SMC_SetParseEnd(SMCParser:handle, const func[]);
* @param handle Handle to an SMC Parse structure.
* @param key String containing key name.
* @param value String containing value name.
* @param data Handle or value passed in SMC_ParseFile
*
* @return An SMCResult action to take.
*
* public SMCResult:OnKeyValue(SMCParser:handle, const key[], const value[])
* public SMCResult:OnKeyValue(SMCParser:handle, const key[], const value[], any:data)
*
* EndSection:
* Called when the parser finds the end of the current section.
*
* @param handle Handle to an SMC Parse structure.
*
* @param data Handle or value passed in SMC_ParseFile
*
* @return An SMCResult action to take.
*
* public SMCResult:OnEndSection(SMCParser:handle)
* public SMCResult:OnEndSection(SMCParser:handle, any:data)
* -
* @param handle Handle to an SMC Parse structure.
* @param kv A KeyValue callback.
@ -227,10 +233,11 @@ native SMC_SetReaders(SMCParser:smc, const kvFunc[], const nsFunc[] = "", const
* @param handle Handle to an SMC Parse structure.
* @param line A string containing the raw line from the file.
* @param lineno The line number it occurs on.
* @param data Handle or value passed in SMC_ParseFile
*
* @return An SMCResult action to take.
*
* public SMCResult:SMC_RawLine(SMCParser:handle, const line[], lineno)
* public SMCResult:SMC_RawLine(SMCParser:handle, const line[], lineno, any:data)
* -
* @param handle Handle to an SMC Parse structure.
* @param func A RawLine callback.