person.metacc (15 lines, 259 bytes) in C++ (8 files, 159 lines, 3397 bytes)

oopl/cpp/demo/BUILD

cc_library(
  name = "PersonMeta",
  srcs = ['PersonMeta.cc'],
  hdrs = ['PersonMeta.h'],
  deps = [
    "//metastrap:__Meta__",
    "//metax/root:ObjectMeta",
  ],
  copts = ['-Iexternal/gtest/include'],
  visibility = ['//visibility:public'],
)

cc_library(
  name = "Person",
  srcs = ['Person.cc'],
  hdrs = ['Person.h'],
  deps = [
    "//demo:PersonMeta",
    "//metastrap:__Meta__",
    "//metax/root:Object",
    "//metax/root:ObjectMeta",
  ],
  copts = ['-Iexternal/gtest/include'],
  visibility = ['//visibility:public'],
)
oopl/cpp/demo/Person.cc
#include "demo/Person.h"

namespace demo {

Person::Person(meta::strview name) {
  this->nameIs(name);
}

metax::root::ObjectMetaRoot* Person::meta() {
  return MetaPerson;
}

}  // demo
oopl/cpp/demo/Person.h
#ifndef demo_Person_h
#define demo_Person_h 1

#include "demo/PersonMeta.h"
#include "metastrap/__Meta__.h"
#include "metax/root/Object.h"
#include "metax/root/ObjectMeta.h"

namespace demo {

class Person : public metax::root::Object {

  // field name : str
  //   The name of the person.
  private: meta::str _name;

  public: virtual meta::strview name() const { return this->_name; }

  public: virtual void nameIs(meta::strview value) { this->_name = value; }

  public: Person(meta::strview name);

  public: virtual metax::root::ObjectMetaRoot* meta();
};

}  // demo

#endif // demo_Person_h
oopl/cpp/demo/PersonMeta.cc
#include "demo/PersonMeta.h"

namespace demo {

PersonMeta::PersonMeta(meta::strview name, const std::vector& bases, const std::map& symbols) : metax::root::ObjectMeta(name, bases, symbols) {
}

// Create the singleton instance of the metaclass.
static std::vector _bases;
static std::map _symbols;
PersonMeta* MetaPerson = new PersonMeta("demo.PersonMeta", _bases, _symbols);

}  // demo
oopl/cpp/demo/PersonMeta.h
#ifndef demo_PersonMeta_h
#define demo_PersonMeta_h 1

#include "metastrap/__Meta__.h"
#include "metax/root/ObjectMeta.h"

namespace demo {

// Auto-generated meta class for demo.Person.
class PersonMeta : public metax::root::ObjectMeta {

  public: PersonMeta(meta::strview name, const std::vector& bases, const std::map& symbols);
};

// The singleton instance of the metaclass.
extern PersonMeta* MetaPerson;

}  // demo

#endif // demo_PersonMeta_h
oopl/cpp/demo_test/BUILD

cc_test(
  name = "PersonTest",
  srcs = [
    "PersonTest.cc",
    "PersonTest.h",
  ],
  deps = [
    "//demo:Person",
    "//metastrap:__Meta__",
    "//metax/test:TestCase",
  ],
  copts = ['-Iexternal/gtest/include'],
  size = "small",
  visibility = ['//visibility:public'],
)

test_suite(
  name = "demo_test",
  tests = [':PersonTest'],
)
oopl/cpp/demo_test/PersonTest.cc
#include "demo_test/PersonTest.h"

namespace demo_test {


PersonTest::PersonTest(meta::strview meta__name) : metax::test::TestCase(meta__name) {
}

TEST_F(PersonTest, test_Person) {
}


}  // demo_test


int main(int argc, char* argv[]) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
oopl/cpp/demo_test/PersonTest.h
#ifndef demo_test_PersonTest_h
#define demo_test_PersonTest_h 1

#include "demo/Person.h"
#include "metastrap/__Meta__.h"
#include "metax/test/TestCase.h"

namespace demo_test {

// Auto-generated test class for demo.Person
class PersonTest : public metax::test::TestCase {

  public: PersonTest(meta::strview meta__name = "");
  // No decl code needed for test_Person
};

}  // demo_test

#endif // demo_test_PersonTest_h