Advertisement
snake5

SGScript - all C API functions (with some overlap)

Mar 8th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.15 KB | None | 0 0
  1. # Context management [info]
  2.  
  3. @sgs_CreateEngine - create scripting engine context
  4. @sgs_CreateEngineExt - create scripting engine context and pass a custom memory function
  5. @sgs_DestroyEngine - validate memory statistics and destroy engine context
  6. @sgs_DefaultMemFunc - example memory management callback
  7. @sgs_GetOutputFunc - return the current output callback and its user data pointer
  8. @sgs_SetOutputFunc - set the output callback and its user data pointer
  9. @sgs_GetMsgFunc - return the current messaging callback and its user data pointer
  10. @sgs_SetMsgFunc - set the messaging callback and its user data pointer
  11. @sgs_Cntl - set and/or retrieve various states in the system
  12.  
  13.  
  14. # Memory management [info]
  15.  
  16. @sgs_DefaultMemFunc - example memory management callback
  17. @sgs_Memory - allocate/reallocate/free memory
  18. @sgs_Malloc - allocate specified amount of memory
  19. @sgs_Free - free a previously allocated memory pointer
  20. @sgs_Realloc - allocate/reallocate/free memory (requires implicit sgs_Context* C)
  21. @sgs_Alloc - allocate object (requires implicit sgs_Context* C)
  22. @sgs_Alloc_n - allocate an array of objects (requires implicit sgs_Context* C)
  23. @sgs_Alloc_a - allocate object + additional memory (requires implicit sgs_Context* C)
  24. @sgs_Dealloc - free a previously allocated memory pointer (requires implicit sgs_Context* C)
  25.  
  26.  
  27. # Input / output [info]
  28.  
  29. @sgs_GetOutputFunc - return the current output callback and its user data pointer
  30. @sgs_SetOutputFunc - set the output callback and its user data pointer
  31. @sgs_Write - pass a character buffer to the output callback
  32. @sgs_Writef - pass a formatted string to the output callback
  33. @sgs_WriteStr - pass a null-terminated string to the output callback
  34. @sgs_GetMsgFunc - return the current messaging callback and its user data pointer
  35. @sgs_SetMsgFunc - set the messaging callback and its user data pointer
  36. @sgs_Msg - invoke the messaging system
  37. @sgs_WriteErrorInfo - write message info to output callback
  38. @sgs_PushErrorInfo - push message info to stack
  39. @sgs_HasFuncName - check if current C function has a name set
  40. @sgs_FuncName - set current C function name
  41. @SGSFN - set current C function name
  42. @SGSBASEFN - set current C function name if it's not already set
  43. @sgs_Errno - copy errno to internal errno if 2nd argument is false, otherwise clear it
  44. @sgs_SetErrno - set the internal errno value
  45. @sgs_GetLastErrno - return the currently set internal errno value
  46. @sgs_StdOutputFunc - example output callback
  47. @sgs_StdMsgFunc_NoAbort - example messaging callback that does not abort on errors
  48. @sgs_StdMsgFunc - example messaging callback
  49. @sgs_Cntl - set and/or retrieve various states in the system
  50. @sgs_ArgErrorExt - emit an argument type mismatch error with additional formatting options
  51. @sgs_ArgError - emit an argument type mismatch error
  52. @sgs_FuncArgError - emit an argument type mismatch error (alias for states where `this` variable is hidden)
  53. @sgs_MethodArgError - emit an argument type mismatch error (alias for states where `this` variable is NOT hidden)
  54.  
  55.  
  56. # Code handling [info]
  57.  
  58. @sgs_ExecBuffer - execute a character buffer
  59. @sgs_EvalBuffer - execute a character buffer, keep returned variables on stack
  60. @sgs_ExecFile - execute a file
  61. @sgs_EvalFile - execute a file, keep returned variables on stack
  62. @sgs_ExecString - execute a null-terminated string
  63. @sgs_EvalString - execute a null-terminated string, keep returned variables on stack
  64. @sgs_Include - include an item from the file system
  65. @sgs_IncludeExt - include an item from the file system, optionally specifying a search path
  66. @sgs_Compile - compile character buffer to bytecode buffer
  67. @sgs_DumpCompiled - dump bytecode/constant info from a compiled bytecode buffer
  68.  
  69.  
  70. # Introspection [info]
  71.  
  72. @sgs_Stat - retrieve or dump various parts of VM state
  73. @sgs_StackFrameInfo - retrieve preprocessed info from stack frame
  74. @sgs_GetFramePtr - return a stack frame pointer
  75.  
  76.  
  77. # Execution control [info]
  78.  
  79. @sgs_FCallP - call variable as function
  80. @sgs_CallP - call variable as function without `this` passed to it
  81. @sgs_ThisCallP - call variable as function function with `this` passed to it
  82. @sgs_FCall - call the topmost stack item as function
  83. @sgs_Call - call the topmost stack item as function without `this` passed to it
  84. @sgs_ThisCall - call the topmost stack item as function with `this` passed to it
  85. @sgs_GlobalCall - call a global function
  86. @sgs_Abort - abort the execution of the previous SGS functions up to the last C function before them
  87. @sgs_Cntl - set and/or retrieve various states in the system
  88.  
  89.  
  90. # Binding helpers [info]
  91.  
  92. @sgs_LoadLib_Fmt - load the formatting library
  93. @sgs_LoadLib_IO - load the input/output library
  94. @sgs_LoadLib_Math - load the math library
  95. @sgs_LoadLib_OS - load the operating system library
  96. @sgs_LoadLib_RE - load the regular expression library
  97. @sgs_LoadLib_String - load the string library
  98. @sgs_RegFuncConsts - register a list of global C function constants
  99. @sgs_RegIntConsts - register a list of global integer constants
  100. @sgs_RegRealConsts - register a list of global real value constants
  101.  
  102.  
  103. # Object type storage [info]
  104.  
  105. @sgs_RegisterType - register an object interface pointer by name
  106. @sgs_UnregisterType - unregister an object interface pointer by name
  107. @sgs_FindType - find a registered object interface pointer by name
  108. @sgs_IsType - check if variable on stack is of specified registered type
  109.  
  110.  
  111. # Variable initialization [info]
  112.  
  113. @sgs_InitNull - initialize variable to a null variable
  114. @sgs_InitBool - initialize variable to a boolean variable
  115. @sgs_InitInt - initialize variable to an integer
  116. @sgs_InitReal - initialize variable to a real value
  117. @sgs_InitStringBuf - initialize variable to a new char buffer
  118. @sgs_InitString - initialize variable to a new string
  119. @sgs_InitCFunction - initialize variable to C function
  120. @sgs_InitObject - initialize variable to a new object
  121. @sgs_InitObjectIPA - initialize variable to a new object with additional memory allocated in-place for the internal data pointer
  122. @sgs_InitPtr - initialize variable to a pointer variable
  123. @sgs_InitObjectPtr - initialize variable to an existing object and acquire it
  124. @sgs_InitArray - initialize variable to a new array, optionally using the specified number of pushed items on stack
  125. @sgs_InitDict - initialize variable to a new dict, optionally using the specified number of pushed items on stack
  126. @sgs_InitMap - initialize variable to a new map, optionally using the specified number of pushed items on stack
  127.  
  128.  
  129. # Stack primary interface [info]
  130.  
  131. @sgs_PushNull - push a null variable
  132. @sgs_PushBool - push a boolean variable
  133. @sgs_PushInt - push an integer
  134. @sgs_PushReal - push a real value
  135. @sgs_PushStringBuf - push a new string from char buffer
  136. @sgs_PushString - push a new string
  137. @sgs_PushCFunction - push a C function
  138. @sgs_PushObject - push a new object
  139. @sgs_PushObjectIPA - push a new object with additional memory allocated in-place for the internal data pointer
  140. @sgs_PushPtr - push a pointer
  141. @sgs_PushObjectPtr - push an object pointer
  142. @sgs_PushArray - push a new array variable, optionally using the specified number of pushed items on stack
  143. @sgs_PushDict - push a new dict variable, optionally using the specified number of pushed items on stack
  144. @sgs_PushMap - push a new map variable, optionally using the specified number of pushed items on stack
  145. @sgs_PushVariable - push the specified variable
  146. @sgs_StoreVariable - retrieve, acquire and pop the topmost variable on stack
  147. @sgs_PushItem - retrieve and push the specified variable on stack
  148. @sgs_StoreItem - store and pop the topmost variable to the specified position after removal in stack
  149. @sgs_InsertVariable - insert a variable on stack in the specified position
  150. @sgs_Pop - pop the specified number of items from stack
  151. @sgs_PopSkip - pop the specified number of items from stack, skipping some topmost items
  152. @sgs_StackSize - return the size of the current stack frame
  153. @sgs_SetStackSize - resize the current stack frame
  154. @sgs_AbsIndex - convert stack index to positive if possible (if it's <0 or >=StackSize, then it's invalid)
  155. @sgs_IsValidIndex - check if specified stack index is valid
  156. @sgs_PeekStackItem - retrieve without acquisition the specified variable on stack
  157. @sgs_GetStackItem - retrieve and acquire the specified variable on stack
  158. @sgs_SetStackItem - assign variable to the specified variable on stack
  159. @sgs_ItemType - return the variable type of the specified variable on stack
  160. @sgs_LoadArgsExtVA - parse the stack as an argument list with additional options (for custom wrapper functions)
  161. @sgs_LoadArgsExt - parse the stack as an argument list with additional options
  162. @sgs_LoadArgs - parse the stack as an argument list
  163. @sgs_ParseMethod - the `this` object variable handling function, using the macro is preferred to this
  164. @SGS_PARSE_METHOD - automagically handle a `this` object variable regardless of the way its passed
  165. @sgs_Method - unhide the first variable on stack if there is a hidden `this` variable
  166. @sgs_HideThis - hide the first variable on stack if the stack already doesn't contain a hidden `this` variable
  167. @sgs_ForceHideThis - hide the first variable even if it wasn't previously hidden before unhiding
  168.  
  169.  
  170. # Sub-item usage [info]
  171.  
  172. @sgs_GetIndex*** - retrieve a sub-item
  173. @sgs_SetIndex*** - set a sub-item
  174. @sgs_PushIndex** - retrieve and push a sub-item
  175. @sgs_StoreIndex** - store and pop a sub-item
  176. @sgs_GetGlobalPP - retrieve a global variable
  177. @sgs_SetGlobalPP - set a global variable
  178. @sgs_PushProperty - retrieve and push the string property of a variable on stack
  179. @sgs_StoreProperty - store and pop the topmost stack item to a string property of a variable on stack
  180. @sgs_PushNumIndex - retrieve and push the integer index of a variable on stack
  181. @sgs_StoreNumIndex - store and pop the topmost stack item to an integer index of a variable on stack
  182. @sgs_PushGlobal - retrieve and push the global variable, specified by a string
  183. @sgs_StoreGlobal - store and pop the topmost stack item as a global variable, specified by a string
  184. @sgs_GetEnv - retrieve the global environment hash table (dict)
  185. @sgs_SetEnv - set the variable as the global environment hash table (dict), if possible
  186. @sgs_PushEnv - push the global environment hash table (dict)
  187. @sgs_StoreEnv - store and pop the topmost stack item as the global environment hash table (dict), if possible
  188. @sgs_PushPath - retrieve and push a variable from a path of sub-items
  189. @sgs_StorePath - store and pop the topmost stack item into a path of sub-items
  190.  
  191.  
  192. # Argument handling [info]
  193.  
  194. @sgs_ArgErrorExt - emit an argument type mismatch error with additional formatting options
  195. @sgs_ArgError - emit an argument type mismatch error
  196. @sgs_FuncArgError - emit an argument type mismatch error (alias for states where `this` variable is hidden)
  197. @sgs_MethodArgError - emit an argument type mismatch error (alias for states where `this` variable is NOT hidden)
  198. @sgs_LoadArgsExtVA - parse the stack as an argument list with additional options (for custom wrapper functions)
  199. @sgs_LoadArgsExt - parse the stack as an argument list with additional options
  200. @sgs_LoadArgs - parse the stack as an argument list
  201. @sgs_ParseMethod - the `this` object variable handling function, using the macro is preferred to this
  202. @SGS_PARSE_METHOD - automagically handle a `this` object variable regardless of the way its passed
  203. @sgs_Method - unhide the first variable on stack if there is a hidden `this` variable
  204. @sgs_HideThis - hide the first variable on stack if the stack already doesn't contain a hidden `this` variable
  205. @sgs_ForceHideThis - hide the first variable even if it wasn't previously hidden before unhiding
  206.  
  207.  
  208. # Virtual machine operations [info]
  209.  
  210. @sgs_Assign - release the current variable and acquire-assign to it from the source
  211. @sgs_ArithOp - run an arithmetic operation (+,-,*,/,%) on two variables to generate a third one
  212. @sgs_Compare - check if both variables compare equal to each other
  213. @sgs_EqualTypes - check if both variables have the same type and object interface (if both are objects)
  214. @sgs_IncDec - increment or decrement the specified variable
  215. @sgs_TypeOf - convert the topmost variable on stack to a type name string
  216. @sgs_DumpVar - convert the topmost variable on stack to a string that contains detailed info about its contents
  217. @sgs_GCExecute - run the garbage collection system to remove all unreachable objects
  218. @sgs_StringConcat - concatenate two or more variables into a string
  219. @sgs_CloneItem - clone the topmost stack item if it's mutable
  220. @sgs_ObjectAction - execute actions on object variable on stack
  221. @sgs_Serialize - serialize the topmost variable on stack by converting it recursively to an instruction stream
  222. @sgs_SerializeObject - emit a call to the specified function to the serialized stream
  223. @sgs_Unserialize - unserialize the topmost variable on stack by running its serialized instruction stream
  224.  
  225.  
  226. # String helpers [info]
  227.  
  228. @sgs_PadString - return a string with two spaces appended to all newline characters
  229. @sgs_ToPrintSafeString - return a string with all non-printable (except space), non-ASCII characters converted to a character hex code
  230. @sgs_StringConcat - concatenate two or more variables into a string
  231.  
  232.  
  233. # Closures [info]
  234.  
  235. @sgs_ClPushNulls - push a number of empty closures to the closure stack
  236. @sgs_ClPushItem - push a variable on stack as a closure to the closure stack
  237. @sgs_ClPop - pop a number of closures from the closure stack
  238. @sgs_MakeClosure - make a callable closure object from the specified callable and number of closures on stack
  239. @sgs_ClGetItem - retrieve the variable from a closure on stack
  240. @sgs_ClSetItem - set the variable to a closure on stack
  241.  
  242.  
  243. # Data retrieval & conversion [info]
  244.  
  245. @sgs_GetBoolP - return the boolean version of the variable
  246. @sgs_GetIntP - return the integer version of the variable
  247. @sgs_GetRealP - return the real value version of the variable
  248. @sgs_GetPtrP - return the pointer version of the variable
  249. @sgs_ToBoolP - convert variable to a boolear value and return it
  250. @sgs_ToIntP - convert variable to an integer and return it
  251. @sgs_ToRealP - convert variable to a real value and return it
  252. @sgs_ToPtrP - convert variable to a pointer and return it
  253. @sgs_ToStringBufP - convert variable to a string, returning size
  254. @sgs_ToStringP - convert variable to a string
  255. @sgs_ToStringBufFastP - convert variable to a string, preventing possible recursion and returning size
  256. @sgs_ToStringFastP - convert variable to a string, preventing possible recursion
  257. @sgs_IsObjectP - check if variable is an object and has the specified interface pointer
  258. @sgs_IsTypeP - check if variable is of specified registered type
  259. @sgs_IsCallableP - check if variable is callable (SGS function, C function or object with CALL impl.)
  260. @sgs_ParseBoolP - validate conversion, optionally return boolean value from variable, if possible
  261. @sgs_ParseIntP - validate conversion, optionally return integer value from variable, if possible
  262. @sgs_ParseRealP - validate conversion, optionally return real value from variable, if possible
  263. @sgs_ParseStringP - validate conversion, optionally return string or buffer from variable, if possible
  264. @sgs_ParseObjectPtrP - validate conversion, optionally return object pointer from variable, if possible
  265. @sgs_ParsePtrP - validate conversion, optionally return pointer from variable, if possible
  266. @sgs_ArraySizeP - retrieve size of array variable, if possible
  267. @sgs_GetBool - return the boolean version of the variable on stack
  268. @sgs_GetInt - return the integer version of the variable on stack
  269. @sgs_GetReal - return the real value version of the variable on stack
  270. @sgs_GetPtr - return the pointer version of the variable on stack
  271. @sgs_ToBool - convert variable on stack to a boolear value and return it
  272. @sgs_ToInt - convert variable on stack to an integer and return it
  273. @sgs_ToReal - convert variable on stack to a real value and return it
  274. @sgs_ToPtr - convert variable on stack to a pointer and return it
  275. @sgs_ToStringBuf - convert variable on stack to a string, returning size
  276. @sgs_ToString - convert variable on stack to a string
  277. @sgs_ToStringBufFast - convert variable on stack to a string, preventing possible recursion and returning size
  278. @sgs_ToStringFast - convert variable on stack to a string, preventing possible recursion
  279. @sgs_IsObject - check if variable on stack is an object and has the specified interface pointer
  280. @sgs_IsType - check if variable on stack is of specified registered type
  281. @sgs_IsCallable - check if variable on stack is callable (SGS function, C function or object with CALL impl.)
  282. @sgs_ParseBool - validate conversion, optionally return boolean value from variable on stack, if possible
  283. @sgs_ParseInt - validate conversion, optionally return integer value from variable on stack, if possible
  284. @sgs_ParseReal - validate conversion, optionally return real value from variable on stack, if possible
  285. @sgs_ParseString - validate conversion, optionally return string or buffer from variable on stack, if possible
  286. @sgs_ParseObjectPtr - validate conversion, optionally return object pointer from variable on stack, if possible
  287. @sgs_ParsePtr - validate conversion, optionally return pointer from variable on stack, if possible
  288. @sgs_ArraySize - retrieve size of array variable on stack, if possible
  289. @sgs_GlobalBool - retrieve global by name as bool
  290. @sgs_GlobalInt - retrieve global by name as integer
  291. @sgs_GlobalReal - retrieve global by name as real
  292. @sgs_GlobalStringBuf - retrieve global by name as string buffer
  293. @sgs_GlobalString - retrieve global by name as string
  294. @sgs_GetStringPtrP - get string pointer from variable pointer
  295. @sgs_GetStringSizeP - get string size from variable pointer
  296. @sgs_GetObjectStructP - get object pointer from variable pointer
  297. @sgs_GetObjectDataP - get data pointer of object variable pointer
  298. @sgs_GetObjectIfaceP - get interface pointer of object variable pointer
  299. @sgs_SetObjectDataP - set data pointer of object variable pointer
  300. @sgs_SetObjectIfaceP - set interface pointer of object variable pointer
  301. @sgs_GetStringPtr - get string pointer from variable on stack
  302. @sgs_GetStringSize - get string size from variable on stack
  303. @sgs_GetObjectStruct - get object pointer from variable on stack
  304. @sgs_GetObjectData - get data pointer of object variable on stack
  305. @sgs_GetObjectIface - get interface pointer of object variable on stack
  306. @sgs_SetObjectData - set data pointer of object variable on stack
  307. @sgs_SetObjectIface - set interface pointer of object variable on stack
  308.  
  309.  
  310. # Iterators [info]
  311.  
  312. @sgs_PushIteratorP - create and push iterator from variable pointer
  313. @sgs_GetIteratorP - create iterator from variable pointer
  314. @sgs_IterAdvanceP - advance iterator, specified by its variable pointer
  315. @sgs_IterPushDataP - extract and push data of current iteration of the iterator, specified by its variable pointer
  316. @sgs_IterGetDataP - extract data of current iteration of the iterator, specified by its variable pointer
  317. @sgs_PushIterator - create and push iterator from variable on stack
  318. @sgs_GetIterator - create iterator from variable on stack
  319. @sgs_IterAdvance - advance iterator, specified by its stack index
  320. @sgs_IterPushData - extract and push data of current iteration of the iterator variable on stack
  321. @sgs_IterGetData - extract data of current iteration of the iterator variable on stack
  322.  
  323.  
  324. # Variable ownership [info]
  325.  
  326. @sgs_Acquire - increment reference count of a variable if the type implements reference counting
  327. @sgs_Release - decrement reference count and possibly destroy a variable if the type implements ref.counting
  328. @sgs_ReleaseArray - release an array of variables
  329. @sgs_GCMark - mark a variable as available to prevent GC from removing it
  330. @sgs_GCMarkArray - mark an array of variables as available
  331. @sgs_ObjAcquire - acquire an object variable by its sgs_VarObj pointer
  332. @sgs_ObjRelease - release an object variable by its sgs_VarObj pointer
  333. @sgs_ObjGCMark - mark an object variable by its sgs_VarObj pointer
  334. @sgs_ObjCallDtor - call the destruction function of an object variable if it's defined
  335.  
  336.  
  337. # String32 optimization interface [info]
  338.  
  339. @sgs_PushStringBuf32 - initialize and push string32 object on stack
  340. @sgs_PushString32 - initialize and push string32 object on stack
  341. @sgs_CheckString32 - trigger a breakpoint if string32 object is not freed
  342. @sgs_IsFreedString32 - check if string32 object is freed
  343.  
  344.  
  345. # Utility functions [info]
  346.  
  347. @sgs_CodeString - retrieve a name string for the specified constant
  348. @sgs_IsNumericString - check if string is going to be parsed as a number by the internal parser
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement