Skip to content

baobab.generator #

ModelGenerator

  • a tool which takes dir as input
  • is just some v files which define models
  • outputs a generated code dir with
  • heroscript to memory for the model
  • supporting v script for manipulated model
  • name of actor e.g. ProjectManager, module would be project_manager

how does the actor work

  • is a global e.g. projectmanager_factory

  • with double map

  • key1: cid

  • object: ProjectManager Object

  • Object: Project Manager

  • has as properties:

  • db_$rootobjectname which is map

  • key: oid

  • val: the Model which represents the rootobject

  • on factory

  • actions_process

  • process heroscript through path or text (params)

  • action_process

  • take 1 action as input

  • ${rootobjectname}_export

  • export all known objects as heroscript in chosen dir

  • name of heroscript would be ${rootobjectname}_define.md

  • ${rootobjectname}_get(oid)

  • returns rootobject as copy

  • ${rootobjectname}_list()!

  • returns list as copy

  • ${rootobjectname}_set(oid,obj)!

  • ${rootobjectname}_delete(oid)!

  • ${rootobjectname}_new()!

  • in action we have

  • define

  • export/import

  • get

  • list

fn generate_actor #

fn generate_actor(name string, object_names []string, code []CodeItem) !Actor

fn generate_actor_factory #

fn generate_actor_factory(actor Struct) Function

generate_actor_factory generates the factory function for an actor

fn generate_actor_module #

fn generate_actor_module(name string, objects []BaseObject) !Module

fn generate_actor_struct #

fn generate_actor_struct(name string) Struct

fn generate_factory_file #

fn generate_factory_file(name string) CodeFile

fn generate_object_code #

fn generate_object_code(actor Struct, object BaseObject) CodeFile

fn generate_object_test_code #

fn generate_object_test_code(actor Struct, object BaseObject) !CodeFile

generate_object_methods generates CRUD actor methods for a provided structure

fn parse_actor #

fn parse_actor(path string) !Actor

fn parse_config #

fn parse_config(path string) !ActorConfig

fn parse_readme #

fn parse_readme(path string) !Actor

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_methods #

fn (actor Actor) generate_methods() ![]ActorMethod

fn (Actor) generate_model_files #

fn (a Actor) generate_model_files() ![]CodeFile

fn (Actor) generate_module #

fn (a Actor) generate_module() !Module

fn (Actor) generate_openrpc #

fn (actor Actor) generate_openrpc() OpenRPC

fn (Actor) generate_openrpc_code #

fn (actor Actor) generate_openrpc_code() !Module

fn (Actor) generate_openrpc_specification #

fn (a Actor) generate_openrpc_specification() !File

struct ActorConfig #

struct ActorConfig {
pub mut:
	name string
}

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
}

struct GenerateActorParams #

struct GenerateActorParams {
	model_path string
}