pub fn define_class(
name: &str,
descriptor_json: &[u8],
env: &ClassEnv,
) -> Result<ClassDescriptor>Expand description
Defines a class (16.2): checks descriptor_json, the descriptor as the author wrote it,
flattens it onto its parent and checks the result. Returns the flattened descriptor;
its hash is the class hash. Checks in this order and reports the
first failure:
nameis a full name (2.3,E_CANON_NAME) underenv.definer(), its namespace being the definer’s or below it (E_CLASS_OWNER);- the descriptor as written (
ClassDescriptor::from_json); - the parent, when there is one: known to
env(E_CLASS_PARENT), no parent key declared again (E_CLASS_INHERIT); then flattening (keys: the parent’s then the class’s own;order: the parent’s then the class’s own;methods: the parent’s overlaid by the class’s own;implements: the union; every other member the class’s own;parentstays); - overrides (
E_CLASS_FINAL, thenE_CLASS_OVERRIDE); - the flattened descriptor, by 16.1;
- the methods in JCS order of names (
E_CLASS_METHOD; the lookup method’s own rule isE_CLASS_MEMBER); extentfunctions (E_CLASS_MEMBER);implements(E_CLASS_INTERFACE).