Skip to content
This repository
tree: 2cffa0eb5b
Fetching contributors…

Cannot retrieve contributors at this time

file 369 lines (326 sloc) 16.593 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>luad.stack - LuaD documentation</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<!-- styles -->
<link href="bootDoc/assets/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<link href="bootDoc/assets/css/bootstrap-responsive.css" rel="stylesheet">
<link href="bootDoc/bootdoc.css" rel="stylesheet">

<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- fav and touch icons -->
<link rel="shortcut icon" href="favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="bootDoc/assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="bootDoc/assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="bootDoc/assets/ico/apple-touch-icon-57-precomposed.png">

<!-- Introduce DDoc settings required by JavaScript -->
<script type="text/javascript">
var Title = 'luad.stack';
var SourceRepository = 'http://github.com/JakobOvrum/LuaD/tree/master';
var PackageSeparator = '.';
</script>

<style type="text/css">
.ddoc-icon-variable { background-image: url('bootDoc/ddoc-icons/var.png'); }
.ddoc-icon-function { background-image: url('bootDoc/ddoc-icons/func.png'); }
.ddoc-icon-property { background-image: url('bootDoc/ddoc-icons/property.png'); }
.ddoc-icon-struct { background-image: url('bootDoc/ddoc-icons/struct.png'); }
.ddoc-icon-class { background-image: url('bootDoc/ddoc-icons/class.png'); }
.ddoc-icon-enum { background-image: url('bootDoc/ddoc-icons/enum.png'); }
.ddoc-icon-template { background-image: url('bootDoc/ddoc-icons/template.png'); }
</style>
</head>

<body>
<!--
JavaScript reaps the module list from this element.
This is required for the MODULES macro to be reusable
in a noscript element later.
-->
<ul id="module-list-source" class="hidden">

<li class="sidebar-list-entry tree-leaf"><a href="luad.all.html" title="luad.all"><i class="icon-th"></i>luad.all</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.state.html" title="luad.state"><i class="icon-th"></i>luad.state</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.base.html" title="luad.base"><i class="icon-th"></i>luad.base</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.table.html" title="luad.table"><i class="icon-th"></i>luad.table</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.lfunction.html" title="luad.lfunction"><i class="icon-th"></i>luad.lfunction</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.dynamic.html" title="luad.dynamic"><i class="icon-th"></i>luad.dynamic</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.error.html" title="luad.error"><i class="icon-th"></i>luad.error</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.stack.html" title="luad.stack"><i class="icon-th"></i>luad.stack</a></li>

<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.arrays.html" title="luad.conversions.arrays"><i class="icon-th"></i>luad.conversions.arrays</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.assocarrays.html" title="luad.conversions.assocarrays"><i class="icon-th"></i>luad.conversions.assocarrays</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.classes.html" title="luad.conversions.classes"><i class="icon-th"></i>luad.conversions.classes</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.functions.html" title="luad.conversions.functions"><i class="icon-th"></i>luad.conversions.functions</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.structs.html" title="luad.conversions.structs"><i class="icon-th"></i>luad.conversions.structs</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.variant.html" title="luad.conversions.variant"><i class="icon-th"></i>luad.conversions.variant</a></li>

<li class="sidebar-list-entry tree-leaf"><a href="luad.c.all.html" title="luad.c.all"><i class="icon-th"></i>luad.c.all</a></li>
</ul>

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html">LuaD</a>
<div class="nav-collapse">
<ul class="nav">
<li class="active"><a href="index.html">Reference</a></li>
</ul>

<form id="gotosymbol" class="navbar-search pull-left hidden">
<input type="text" class="search-query" placeholder="Go to symbol in luad.stack" data-provide="typeahead" data-items="4">
</form>

<p class="navbar-text pull-right"><a href="https://github.com/JakobOvrum/LuaD">Github Page</a></p>
</div><!--/.nav-collapse -->
</div>
</div>
</div>

<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li id="module-list" class="nav-header sidebar-list-entry">Modules<li>
<noscript>

<li class="sidebar-list-entry tree-leaf"><a href="luad.all.html" title="luad.all"><i class="icon-th"></i>luad.all</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.state.html" title="luad.state"><i class="icon-th"></i>luad.state</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.base.html" title="luad.base"><i class="icon-th"></i>luad.base</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.table.html" title="luad.table"><i class="icon-th"></i>luad.table</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.lfunction.html" title="luad.lfunction"><i class="icon-th"></i>luad.lfunction</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.dynamic.html" title="luad.dynamic"><i class="icon-th"></i>luad.dynamic</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.error.html" title="luad.error"><i class="icon-th"></i>luad.error</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.stack.html" title="luad.stack"><i class="icon-th"></i>luad.stack</a></li>

<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.arrays.html" title="luad.conversions.arrays"><i class="icon-th"></i>luad.conversions.arrays</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.assocarrays.html" title="luad.conversions.assocarrays"><i class="icon-th"></i>luad.conversions.assocarrays</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.classes.html" title="luad.conversions.classes"><i class="icon-th"></i>luad.conversions.classes</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.functions.html" title="luad.conversions.functions"><i class="icon-th"></i>luad.conversions.functions</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.structs.html" title="luad.conversions.structs"><i class="icon-th"></i>luad.conversions.structs</a></li>
<li class="sidebar-list-entry tree-leaf"><a href="luad.conversions.variant.html" title="luad.conversions.variant"><i class="icon-th"></i>luad.conversions.variant</a></li>

<li class="sidebar-list-entry tree-leaf"><a href="luad.c.all.html" title="luad.c.all"><i class="icon-th"></i>luad.c.all</a></li>
</noscript>
<li id="symbol-list" class="nav-header sidebar-list-entry hidden">luad.stack</li>
</ul>
</div><!--/.well -->
</div><!--/span-->

<div class="span10">
<div class="row-fluid">
<div class="span11">
<ul id="module-breadcrumb" class="breadcrumb">
<noscript><h1>luad.stack</h1></noscript>
</ul>

</div>
<div class="span1 offset11">
<a href="index.html"><img src="logo.png" alt="LuaD"/></a>
</div>
</div>
<div id="declaration-list">
<!-- Generated by Ddoc from ..\luad\stack.d -->
<dl><p>This internal module, with the help of the luad.conversions package, takes care of converting between D and Lua types.
</p>

<p>The conversion rules are as follows, where conversion goes both ways:
<dl><dt>boolean
<dd>bool</dd>
</dt>
<dt>number
<dd>lua_Integer (default int)</dd>
<dd>lua_Number (default double)</dd>
</dt>
<dt>string
<dd>string, const(char)[], char[]</dd>
<dd>const(char)*</dd>
<dd>char</dd>
<dd>immutable(void)[], const(void)[], void[] (binary data)</dd>
</dt>
<dt>table
<dd><a href="luad.conversions.assocarrays.html">associative arrays</a></dd>
<dd><a href="luad.conversions.arrays.html">arrays</a></dd>
<dd><a href="luad.conversions.structs.html">structs</a></dd>
<dd><a href="luad.table.html">LuaTable</a>
</dd>
</dt>
<dt>function (see <a href="luad.conversions.functions.html">luad.conversions.functions</a>)
<dd>function pointers</dd>
<dd>delegates</dd>
<dd><a href="luad.lfunction.html">LuaFunction</a>
</dd>
</dt>
<dt>userdata
<dd><a href="luad.conversions.classes.html">classes</a></dd>
</dt>
<dt>nil
<dd>the special identifier nil</dd>
<dd><span class="d_keyword">null</span> class references</dd>
</dt>
<dt>any of the above
<dd><a href="luad.base.html">LuaObject</a>
</dd>
<dd><a href="luad.dynamic.html">LuaDynamic</a>
</dd>
<dd><a href="luad.conversions.variant.html">Algebraic</a> (when given a compatible value)</dd>
</dt>
</dl>
<br><br>

The conversions are checked in the specified order. For example, even though bool is implicitly convertible
to lua_Integer, it will be converted to a boolean because boolean has precedence.
<br><br>

wchar and dchar are explicitly disallowed. Lua strings consist of 8-bit characters, if you want to push UTF-16 or UTF-32 strings, convert to UTF-8 first.
<br><br>

Additionally, the following types are pushable to Lua, but can't be retrieved back:
<dl><dt>function
<dd>lua_CFunction</dd>
</dt>
</dl></p>
</dl>
<hr><div class="row-fluid declaration"><h3>void <a class="symbol symbol-anchor" name="pushValue" href="#pushValue">pushValue</a>(T)(lua_State* <i>L</i>, T <i>value</i>);
</h3></div>
<div class="declaration-content"><dl><p>Push a value of any type to the stack.
</p>

<dt>Parameters</dt><dd><table class="table table-condensed table-bordered"><tr><td>L</td>
<td>stack to push to</td>
</tr>
<tr><td>value</td>
<td>value to push</td>
</tr>
</table></dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>template <a class="symbol symbol-anchor" name="luaTypeOf" href="#luaTypeOf">luaTypeOf</a>(T)</h3></div>
<div class="declaration-content"><dl><p>Get the associated Lua type for T.
</p>

<dt>Returns</dt><dd>Lua type for T</dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T <a class="symbol symbol-anchor" name="getValue" href="#getValue">getValue</a>(T, alias typeMismatchHandler = defaultTypeMismatch)(lua_State* <i>L</i>, int <i>idx</i>);
</h3></div>
<div class="declaration-content"><dl><p>Get a value of any type from the stack.
</p>

<dt>Parameters</dt><dd><table class="table table-condensed table-bordered"><tr><td>T</td>
<td>type of value</td>
</tr>
<tr><td>typeMismatchHandler</td>
<td>function called to produce an error in case of an invalid conversion.</td>
</tr>
<tr><td>L</td>
<td>stack to get from</td>
</tr>
<tr><td>idx</td>
<td>value stack index</td>
</tr>
</table></dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T <a class="symbol symbol-anchor" name="popValue" href="#popValue">popValue</a>(T, alias typeMismatchHandler = defaultTypeMismatch)(lua_State* <i>L</i>);
</h3></div>
<div class="declaration-content"><dl><p>Same as calling getValue!(T, typeMismatchHandler)(L, -1), then popping one value from the stack.
</p>

<dt>See Also</dt><dd>getValue</dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T[] <a class="symbol symbol-anchor" name="popStack" href="#popStack">popStack</a>(T = LuaObject)(lua_State* <i>L</i>, size_t <i>n</i>);
</h3></div>
<div class="declaration-content"><dl><p>Pop a number of elements from the stack.
</p>

<dt>Parameters</dt><dd><table class="table table-condensed table-bordered"><tr><td>T</td>
<td>element type</td>
</tr>
<tr><td>L</td>
<td>stack to pop from</td>
</tr>
<tr><td>n</td>
<td>number of elements to pop</td>
</tr>
</table></dd>
<dt>Returns</dt><dd>array of popped elements, or a <span class="d_keyword">null</span> array if n = 0</dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>auto <a class="symbol symbol-anchor" name="getArgument" href="#getArgument">getArgument</a>(T, int narg)(lua_State* <i>L</i>, int <i>idx</i>);
</h3></div>
<div class="declaration-content"><dl><p>Get a function argument from the stack.</p>

</dl>
</div>
<hr><div class="row-fluid declaration"><h3>template <a class="symbol symbol-anchor" name="returnTypeSize" href="#returnTypeSize">returnTypeSize</a>(T)</h3></div>
<div class="declaration-content"><dl><p>Used for getting a suitable nresults argument to lua_call or lua_pcall.</p>

</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T <a class="symbol symbol-anchor" name="popReturnValues" href="#popReturnValues">popReturnValues</a>(T)(lua_State* <i>L</i>, size_t <i>nret</i>);
</h3></div>
<div class="declaration-content"><dl><p>Pop return values from stack.
 Defaults to popValue, but has special handling for LuaVariableReturn, Tuple!(...), static arrays and void.
</p>

<dt>Parameters</dt><dd><table class="table table-condensed table-bordered"><tr><td>nret</td>
<td>number of return values</td>
</tr>
</table></dd>
<dt>Returns</dt><dd>Return value, collection of return values, or nothing</dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>int <a class="symbol symbol-anchor" name="pushReturnValues" href="#pushReturnValues">pushReturnValues</a>(T)(lua_State* <i>L</i>, T <i>value</i>);
</h3></div>
<div class="declaration-content"><dl><p>Push return values to the stack.
 Defaults to pushValue, but has special handling for LuaVariableReturn, Tuple!(...) and static arrays.</p>

</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T <a class="symbol symbol-anchor" name="popTuple" href="#popTuple">popTuple</a>(T)(lua_State* <i>L</i>);
</h3></div>
<div class="declaration-content"><dl><p>Pops a Tuple from the values at the top of the stack.</p>

</dl>
</div>
<hr><div class="row-fluid declaration"><h3>void <a class="symbol symbol-anchor" name="pushTuple" href="#pushTuple">pushTuple</a>(T)(lua_State* <i>L</i>, ref T <i>tup</i>);
</h3></div>
<div class="declaration-content"><dl><p>Pushes all the values in a Tuple to the stack.</p>

</dl>
</div>
<hr><div class="row-fluid declaration"><h3>T <a class="symbol symbol-anchor" name="callWithRet" href="#callWithRet">callWithRet</a>(T)(lua_State* <i>L</i>, int <i>nargs</i>);
</h3></div>
<div class="declaration-content"><dl><p>Call a Lua function and handle its return values.
</p>

<dt>Parameters</dt><dd><table class="table table-condensed table-bordered"><tr><td>T</td>
<td>type of return value or container of return values</td>
</tr>
<tr><td>nargs</td>
<td>number of arguments</td>
</tr>
</table></dd>
<dt>Returns</dt><dd>Zero, one or all return values as T, taking into account void, LuaVariableReturn and Tuple returns</dd>
</dl>
</div>
<hr><div class="row-fluid declaration"><h3>void <a class="symbol symbol-anchor" name="printStack" href="#printStack">printStack</a>(lua_State* <i>L</i>);
</h3></div>
<div class="declaration-content"><dl><p>Print the Lua stack to stdout.</p>

</dl>
</div>


</div>

<hr>

<footer class="pull-left">
<p>Page generated with <a href="https://github.com/JakobOvrum/bootDoc">bootDoc</a>.</p>
</footer>

<footer class="pull-right">
<p>&copy; Jakob Ovrum 2010-2012
</p>
</footer>
</div>
</div>
</div><!--/.fluid-container-->

<!-- Bootstrap javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="bootDoc/assets/js/jquery.min.js"></script>
<script src="bootDoc/assets/js/bootstrap.min.js"></script>

<!-- bootDoc javascript
================================================== -->
<script src="bootDoc/bootdoc.js"></script>

</body>
</html>
Something went wrong with that request. Please try again.