--- /dev/null
+### -*-python-*-
+###
+### Setup for mLib bindings
+###
+### (c) 2019 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the Python interface to mLib.
+###
+### mLib/Python is free software: you can redistribute it and/or modify it
+### under the terms of the GNU General Public License as published by the
+### Free Software Foundation; either version 2 of the License, or (at your
+### option) any later version.
+###
+### mLib/Python is distributed in the hope that it will be useful, but
+### WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+### General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with mLib/Python. If not, write to the Free Software
+### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+### USA.
+
+import sys as _sys
+import types as _types
+
+###--------------------------------------------------------------------------
+### Import the main C extension module.
+
+if _sys.version_info >= (3,): from . import _base
+else: import _base
+
+###--------------------------------------------------------------------------
+### Basic stuff.
+
+## Register our module.
+_base._ready(_sys.modules[__name__])
+def default_lostexchook(why, ty, val, tb):
+ """`mLib.lostexchook(WHY, TY, VAL, TB)' reports lost exceptions."""
+ _sys.stderr.write("\n\n!!! LOST EXCEPTION: %s\n" % why)
+ _sys.excepthook(ty, val, tb)
+ _sys.stderr.write("\n")
+lostexchook = default_lostexchook
+
+## For the benefit of the reporter functions, we need the program name.
+_base.ego(_sys.argv[0])
+
+## Initialize the module.
+def _init():
+ d = globals()
+ b = _base.__dict__;
+ for i in b:
+ if i[0] != '_': d[i] = b[i];
+_init()
+
+## A handy function for our work: add the methods of a named class to an
+## existing class. This is how we write the Python-implemented parts of our
+## mostly-C types.
+def _augment(c, cc):
+ for i in cc.__dict__:
+ a = cc.__dict__[i]
+ if type(a) is _types.MethodType:
+ a = a.im_func
+ elif type(a) not in (_types.FunctionType, staticmethod, classmethod):
+ continue
+ setattr(c, i, a)
+
+###--------------------------------------------------------------------------
+### Atoms.
+
+DEFAULT_ATOMTABLE = AtomTable()
+
+if _sys.version_info >= (3,):
+ def atoms(): return iter(DEFAULT_ATOMTABLE.values())
+else:
+ def atoms(): return DEFAULT_ATOMTABLE.itervalues()
+
+class _tmp:
+ def __repr__(me): return "Atom(%r)" % me.name
+ __str__ = __repr__
+_augment(Atom, _tmp)
+
+###--------------------------------------------------------------------------
+### User-interface funtions.
+
+def pquis(msg, file = _sys.stdout):
+ "pquis(MSG, [file = sys.stdout]): write MSG, replacing `$' by program name"
+ file.write(msg.replace("$", quis))
+
+###----- That's all, folks --------------------------------------------------