Skip to content

Commit

Permalink
Merge branch 'v2.1' into v2.1-agentzh
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuizhuhaomeng committed Aug 30, 2022
2 parents aa7a722 + 03080b7 commit 5f8d225
Show file tree
Hide file tree
Showing 45 changed files with 542 additions and 225 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ DPREFIX= $(DESTDIR)$(PREFIX)
INSTALL_BIN= $(DPREFIX)/bin
INSTALL_LIB= $(DPREFIX)/$(MULTILIB)
INSTALL_SHARE= $(DPREFIX)/share
INSTALL_INC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
INSTALL_DEFINC= $(DPREFIX)/include/luajit-$(MAJVER).$(MINVER)
INSTALL_INC= $(INSTALL_DEFINC)

INSTALL_LJLIBD= $(INSTALL_SHARE)/luajit-$(VERSION)
INSTALL_JITLIB= $(INSTALL_LJLIBD)/jit
Expand Down Expand Up @@ -78,6 +79,9 @@ UNINSTALL= $(RM)
LDCONFIG= ldconfig -n 2>/dev/null
SED_PC= sed -e "s|^prefix=.*|prefix=$(PREFIX)|" \
-e "s|^multilib=.*|multilib=$(MULTILIB)|"
ifneq ($(INSTALL_DEFINC),$(INSTALL_INC))
SED_PC+= -e "s|^includedir=.*|includedir=$(INSTALL_INC)|"
endif

FILE_T= luajit
FILE_A= libluajit.a
Expand Down
14 changes: 7 additions & 7 deletions doc/ext_buffer.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1>String Buffer Library</h1>
operations.
</p>
<p>
The string buffer libary also includes a high-performance
The string buffer library also includes a high-performance
<a href="serialize">serializer</a> for Lua objects.
</p>

Expand Down Expand Up @@ -434,8 +434,8 @@ <h3 id="buffer_encode"><tt>str = buffer.encode(obj)<br>
<h3 id="buffer_decode"><tt>obj = buffer.decode(str)<br>
obj = buf:decode()</tt></h3>
<p>
The stand-alone function de-serializes (decodes) the string
<tt>str</tt>, the buffer method de-serializes one object from the
The stand-alone function deserializes (decodes) the string
<tt>str</tt>, the buffer method deserializes one object from the
buffer. Both return a Lua object <tt>obj</tt>.
</p>
<p>
Expand All @@ -449,7 +449,7 @@ <h3 id="buffer_decode"><tt>obj = buffer.decode(str)<br>
any left-over data in the buffer.
</p>
<p>
Attempting to de-serialize an FFI type will throw an error, if the FFI
Attempting to deserialize an FFI type will throw an error, if the FFI
library is not built-in or has not been loaded, yet.
</p>

Expand All @@ -462,7 +462,7 @@ <h3 id="serialize_options">Serialization Options</h3>
<li>
<tt>dict</tt> is a Lua table holding a <b>dictionary of strings</b> that
commonly occur as table keys of objects you are serializing. These keys
are compactly encoded as indexes during serialization. A well chosen
are compactly encoded as indexes during serialization. A well-chosen
dictionary saves space and improves serialization performance.
</li>
<li>
Expand All @@ -473,7 +473,7 @@ <h3 id="serialize_options">Serialization Options</h3>
<p>
<tt>dict</tt> needs to be an array of strings and <tt>metatable</tt> needs
to be an array of tables. Both starting at index 1 and without holes (no
<tt>nil</tt> inbetween). The tables are anchored in the buffer object and
<tt>nil</tt> in between). The tables are anchored in the buffer object and
internally modified into a two-way index (don't do this yourself, just pass
a plain array). The tables must not be modified after they have been passed
to <tt>buffer.new()</tt>.
Expand Down Expand Up @@ -624,7 +624,7 @@ <h2 id="error">Error handling</h2>
There's not much one can do after that, anyway.
</p>
<p>
OTOH you may want to catch some errors individually. Buffer methods need
OTOH, you may want to catch some errors individually. Buffer methods need
to receive the buffer object as the first argument. The Lua colon-syntax
<tt>obj:method()</tt> does that implicitly. But to wrap a method with
<tt>pcall()</tt>, the arguments need to be passed like this:
Expand Down
4 changes: 2 additions & 2 deletions doc/ext_c_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h3 id="mode_func"><tt>luaJIT_setmode(L, idx, LUAJIT_MODE_FUNC|flag)</tt><br>
This sets the mode for the function at the stack index <tt>idx</tt> or
the parent of the calling function (<tt>idx = 0</tt>). It either
enables JIT compilation for a function, disables it and flushes any
already compiled code or only flushes already compiled code. This
already compiled code, or only flushes already compiled code. This
applies recursively to all sub-functions of the function with
<tt>LUAJIT_MODE_ALLFUNC</tt> or only to the sub-functions with
<tt>LUAJIT_MODE_ALLSUBFUNC</tt>.
Expand All @@ -126,7 +126,7 @@ <h3 id="mode_wrapcfunc"><tt>luaJIT_setmode(L, idx, LUAJIT_MODE_WRAPCFUNC|flag)</
This mode defines a wrapper function for calls to C functions. If
called with <tt>LUAJIT_MODE_ON</tt>, the stack index at <tt>idx</tt>
must be a <tt>lightuserdata</tt> object holding a pointer to the wrapper
function. From now on all C functions are called through the wrapper
function. From now on, all C functions are called through the wrapper
function. If called with <tt>LUAJIT_MODE_OFF</tt> this mode is turned
off and all C functions are directly called.
</p>
Expand Down
14 changes: 7 additions & 7 deletions doc/ext_ffi.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h2 id="call">Motivating Example: Calling External C Functions</h2>
<h2 id="cdata">Motivating Example: Using C Data Structures</h2>
<p>
The FFI library allows you to create and access C&nbsp;data
structures. Of course the main use for this is for interfacing with
structures. Of course, the main use for this is for interfacing with
C&nbsp;functions. But they can be used stand-alone, too.
</p>
<p>
Expand All @@ -169,7 +169,7 @@ <h2 id="cdata">Motivating Example: Using C Data Structures</h2>
both a substantial memory overhead as well as a performance overhead.
</p>
<p>
Here's a sketch of a library that operates on color images plus a
Here's a sketch of a library that operates on color images, plus a
simple benchmark. First, the plain Lua version:
</p>
<pre class="code">
Expand All @@ -184,7 +184,7 @@ <h2 id="cdata">Motivating Example: Using C Data Structures</h2>
return img
end

local function image_to_grey(img, n)
local function image_to_gray(img, n)
for i=1,n do
local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
img[i].red = y; img[i].green = y; img[i].blue = y
Expand All @@ -194,14 +194,14 @@ <h2 id="cdata">Motivating Example: Using C Data Structures</h2>
local N = 400*400
local img = image_ramp_green(N)
for i=1,1000 do
image_to_grey(img, N)
image_to_gray(img, N)
end
</pre>
<p>
This creates a table with 160.000 pixels, each of which is a table
holding four number values in the range of 0-255. First an image with
holding four number values in the range of 0-255. First, an image with
a green ramp is created (1D for simplicity), then the image is
converted to greyscale 1000 times. Yes, that's silly, but I was in
converted to grayscale 1000 times. Yes, that's silly, but I was in
need of a simple example ...
</p>
<p>
Expand Down Expand Up @@ -308,7 +308,7 @@ <h2 id="cdata">Motivating Example: Using C Data Structures</h2>
~1.7x). Switching to a struct-of-arrays would help, too.
</p>
<p style="font-size: 8pt;">
However the resulting code would be less idiomatic and rather
However, the resulting code would be less idiomatic and rather
error-prone. And it still doesn't get even close to the performance of
the FFI version of the code. Also, high-level data structures cannot
be easily passed to other C&nbsp;functions, especially I/O functions,
Expand Down
10 changes: 5 additions & 5 deletions doc/ext_ffi_api.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ <h3 id="ffi_cdef"><tt>ffi.cdef(def)</tt></h3>
declaration may be omitted.
</p>
<p>
Please note that external symbols are only <em>declared</em>, but they
Please note, that external symbols are only <em>declared</em>, but they
are <em>not bound</em> to any specific address, yet. Binding is
achieved with C&nbsp;library namespaces (see below).
</p>
Expand Down Expand Up @@ -209,7 +209,7 @@ <h3 id="ffi_new"><tt>cdata = ffi.new(ct [,nelem] [,init...])<br>
<tt>ffi.typeof()</tt>. Then use the ctype as a constructor repeatedly.
</p>
<p style="font-size: 8pt;">
Please note that an anonymous <tt>struct</tt> declaration implicitly
Please note, that an anonymous <tt>struct</tt> declaration implicitly
creates a new and distinguished ctype every time you use it for
<tt>ffi.new()</tt>. This is probably <b>not</b> what you want,
especially if you create more than one cdata object. Different anonymous
Expand Down Expand Up @@ -256,12 +256,12 @@ <h3 id="ffi_metatype"><tt>ctype = ffi.metatype(ct, metatable)</tt></h3>
contents of an <tt>__index</tt> table (if any) may be modified
afterwards. The associated metatable automatically applies to all uses
of this type, no matter how the objects are created or where they
originate from. Note that pre-defined operations on types have
originate from. Note that predefined operations on types have
precedence (e.g. declared field names cannot be overridden).
</p>
<p>
All standard Lua metamethods are implemented. These are called directly,
without shortcuts and on any mix of types. For binary operations, the
without shortcuts, and on any mix of types. For binary operations, the
left operand is checked first for a valid ctype metamethod. The
<tt>__gc</tt> metamethod only applies to <tt>struct</tt>/<tt>union</tt>
types and performs an implicit <a href="#ffi_gc"><tt>ffi.gc()</tt></a>
Expand Down Expand Up @@ -492,7 +492,7 @@ <h3 id="callback_free"><tt>cb:free()</tt></h3>
<p>
Free the resources associated with a callback. The associated Lua
function is unanchored and may be garbage collected. The callback
function pointer is no longer valid and must not be called anymore
function pointer is no longer valid and must not be called again
(it may be reused by a subsequently created callback).
</p>

Expand Down
Loading

0 comments on commit 5f8d225

Please sign in to comment.