ext_ffi_tutorial.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title>FFI Tutorial</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <meta name="Author" content="Mike Pall">
  7. <meta name="Copyright" content="Copyright (C) 2005-2011, Mike Pall">
  8. <meta name="Language" content="en">
  9. <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
  10. <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
  11. </head>
  12. <body>
  13. <div id="site">
  14. <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
  15. </div>
  16. <div id="head">
  17. <h1>FFI Tutorial</h1>
  18. </div>
  19. <div id="nav">
  20. <ul><li>
  21. <a href="luajit.html">LuaJIT</a>
  22. <ul><li>
  23. <a href="install.html">Installation</a>
  24. </li><li>
  25. <a href="running.html">Running</a>
  26. </li></ul>
  27. </li><li>
  28. <a href="extensions.html">Extensions</a>
  29. <ul><li>
  30. <a href="ext_ffi.html">FFI Library</a>
  31. <ul><li>
  32. <a class="current" href="ext_ffi_tutorial.html">FFI Tutorial</a>
  33. </li><li>
  34. <a href="ext_ffi_api.html">ffi.* API</a>
  35. </li><li>
  36. <a href="ext_ffi_int64.html">64 bit Integers</a>
  37. </li><li>
  38. <a href="ext_ffi_semantics.html">FFI Semantics</a>
  39. </li></ul>
  40. </li><li>
  41. <a href="ext_jit.html">jit.* Library</a>
  42. </li><li>
  43. <a href="ext_c_api.html">Lua/C API</a>
  44. </li></ul>
  45. </li><li>
  46. <a href="status.html">Status</a>
  47. <ul><li>
  48. <a href="changes.html">Changes</a>
  49. </li></ul>
  50. </li><li>
  51. <a href="faq.html">FAQ</a>
  52. </li><li>
  53. <a href="http://luajit.org/performance.html">Performance <span class="ext">&raquo;</span></a>
  54. </li><li>
  55. <a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
  56. </li></ul>
  57. </div>
  58. <div id="main">
  59. <p>
  60. TODO
  61. </p>
  62. <h2 id="load">Loading the FFI Library</h2>
  63. <p>
  64. The FFI library is built into LuaJIT by default, but it's not loaded
  65. and initialized by default. The suggested way to use the FFI library
  66. is to add the following to the start of every Lua file that needs one
  67. of its functions:
  68. </p>
  69. <pre class="code">
  70. local ffi = require("ffi")
  71. </pre>
  72. <p>
  73. Please note this doesn't define an <tt>ffi</tt> variable in the table
  74. of globals &mdash; you really need to use the local variable. The
  75. <tt>require</tt> function ensures the library is only loaded once.
  76. </p>
  77. <h2>TODO</h2>
  78. <br class="flush">
  79. </div>
  80. <div id="foot">
  81. <hr class="hide">
  82. Copyright &copy; 2005-2011 Mike Pall
  83. <span class="noprint">
  84. &middot;
  85. <a href="contact.html">Contact</a>
  86. </span>
  87. </div>
  88. </body>
  89. </html>