Attribute Macro pbni_codegen::visualobject[][src]

#[visualobject]
Expand description

生成可视对象

Parameters

  • name: 映射的PB对象类名 (默认为Rust对象名)
  • inherit: 继承的对象 (此对象的字段)

Notice

继承模式不支持覆盖(override)方法实现,并且在PB端需要将父类的方法声明在子类中重新声明,参见nonvisualobject说明

Examples

struct RustObject {
    session: Session,
    ctx: ContextObject
}

#[visualobject(name = "u_canvas")]
impl RustObject {
    #[constructor]
    fn new(session: Session, ctx: ContextObject) -> RustObject {
        RustObject {
            session,
            ctx
        }
    }
    #[method(name="of_Hello")]
    fn hello(&self, world: String) -> String {
        format!("hello {}!",world)
    }
}