person.meta (15 lines, 278 bytes) in Python (4 files, 119 lines, 2313 bytes)

oopl/python/demo/BUILD

py_library(
  name = "demo",
  srcs = ['__init__.py'],
  deps = ['//metax/root:root'],
  visibility = ['//visibility:public'],
)
oopl/python/demo/__init__.py
# -*- coding: utf-8 -*-
"""A namespace for our demo classes."""
import demo
import metax.root
import sys


class PersonMeta(metax.root.ObjectMeta):
  """Auto-generated meta class for demo.Person."""

  def __init__(cls, name, bases, symbols):
    """No comment provided.

    Args:
      name: &str
      bases: &#vec
      symbols: &#map
    """
    super(PersonMeta, cls).__init__(name, bases, symbols)
    # User-provided code follows.


class Person(metax.root.Object):
  """Undocumented."""
  __metaclass__ = PersonMeta

  # field name : str
  #   The name of the person.

  def name(self):
    return self._name

  def nameIs(self, value):
    """No comment provided.

    Args:
      value: str
    """
    self._name = value

  def __init__(self, name):
    """No comment provided.

    Args:
      name: str
        The name of the person.
    """
    super(Person, self).__init__()
    # User-provided code follows.
    self.nameIs(name)

  def meta(self):
    result = self.__class__
    assert issubclass(result, Person)
    assert issubclass(result, MetaPerson)
    return result

  def printMeta(self, fp=sys.stdout, indent=''):
    """Auto-generated human-readable summary of this object.

    Args:
      fp: ostream
      indent: str
    """
    subindent = indent + "  "
    fp.write('Person %x:\n' % id(self))
    fp.write('%s  name = %s\n' % (indent, self.name()))

MetaPerson = Person

# Class initialization methods
oopl/python/demo_test/BUILD

py_test(
  name = "demo_test",
  main = "__init__.py",
  srcs = ['__init__.py'],
  deps = [
    "//demo:demo",
    "//metax/test:test",
  ],
  size = "small",
  visibility = ['//visibility:public'],
)
oopl/python/demo_test/__init__.py
# -*- coding: utf-8 -*-
"""Auto-generated test namespace for demo."""
import demo
import metax.test


class PersonTest(metax.test.TestCase):
  """Auto-generated test class for demo.Person"""

  def __init__(self, meta__name=""):
    """No comment provided.

    Args:
      meta__name: &str
    """
    super(PersonTest, self).__init__(meta__name)
    # User-provided code follows.

  def test_Person(self):
    pass

  def test_printMeta(self):
    pass

# Class initialization methods


if __name__ == '__main__':
  metax.test.main()