Disassemble class

来自MudWiki

名称

   disassemble_class() - given an instantiated class, returns a mixed* array with elements comprised of the values of each member of the class.

语法

   mixed *disassemble_class( mixed instantiated_class );

描述

   这是 FluffOS 2.0 新增的外部函数,返回一个包含已实例化的结构体 `instantiated_class` 所有成员的值的 mixed 类型的数组。

示例

class person
{
    string name;
    int age;
    string city;
}

void fun()
{
    mixed *result;
    class person me = new (class person);

    me->name = "Foo";
    me->age = 42;
    me->city = "Fooville";

    result = disassemble_class(me);

    write(sprintf("%O\n", result));

    // ({ /* sizeof() == 3 */
    //   "Foo",
    //   42,
    //   "Fooville"
    // })
}

参考

   assemble_class(3)