Skip to content

baobab.code #

Parser

Parser is used to parse actor code into a generator.Actor struct, so that OpenRPC can be generated from custom actor code.

  • Default actor methods: CRUD+list+filter methods for base objects

Conventions

Actor Methods

All default actor methods must be defined in files that follow the naming convention <actor_name>_<base_object_name>.v

Base Objects

  • Base Objects should be defined in separate files named model_<object_name>.v.
  • All children objects and methods defined on the base object should be in the same file.

fn module_to_actor #

fn module_to_actor(mod Module) !Actor

fn read #

fn read(actor_path string) !Actor

read reads an actor from a given v module

struct Actor #

struct Actor {
pub mut:
	name        string
	description string
	structure   Struct
	mod         Module
	methods     []ActorMethod
	objects     []BaseObject
}

fn (Actor) export_command #

fn (mut a Actor) export_command(path string) !

fn (Actor) export_playground #

fn (mut a Actor) export_playground(path string, openrpc_path string) !

fn (Actor) generate_openrpc #

fn (actor Actor) generate_openrpc() OpenRPC

fn (Actor) generate_openrpc_code #

fn (actor Actor) generate_openrpc_code() !Module

fn (Actor) to_module #

fn (actor Actor) to_module() !Module

fn (Actor) write #

fn (actor Actor) write(actor_path string) !

read reads an actor from a given v module

struct ActorGenerator #

struct ActorGenerator {
	model_name string
}

struct ActorMethod #

struct ActorMethod {
pub:
	name string
	func Function
}

struct BaseObject #

struct BaseObject {
pub:
	structure Struct
	methods   []Function
	children  []Struct
}