To answer the original question a bit,
The purpose of the above code snippet in a Lua API wrapper for an API provided by the Java is to put the native Java functions into a subtable (under the identifier native).
The functionality of or means that "term.native or term" will evaluate to term.native unless it is false or nil, in which case it will evaluate to term. That is a quick was of making sure that the native functions are backed up if the native subtable doesn't exist yet, and that it isn't overwritten with the (already modified) functions if it does already exist (the native functions wouldn't be lost, but they'd be under term.native.native if you were to just set native = term without checking for the native subtable).
Now, to understand what the native functions do, they mostly just do what the native functions do…this code here is copying all functions in the native table into term, except for those that are already in term.
for k,v in pairs( native ) do
if type( k ) == "string" and type( v ) == "function" then
if term[k] == nil then
term[k] = wrap( k )
end
end
end
The exceptions are redirect and restore, which are defined so as to allow term functions to be redirected or restored, using the original functions in native as the base and a stack to keep track of the redirects. As mentioned, redirect exists to prevent you from having to fiddle with the functions too much, restore makes it easy to undo redirect.