Skip to content

baobab.generator #

Generator

The Generator synchronizes actor code and specifications, allowing bidirectional transformation between the two.

This a

Development Workflow

A sample development workflow using the generator would be like:1. generating actor specification from an actor openrpc / openapi specification (see specification reflection)2. generating actor code from the actor specification3. updating actor code by filling in method prototypes4. adding methods to the actor to develop actor further5. parsing specification back from actor

  1. regenerating actor from the specificationthis allows for
  • 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_folder #

fn generate_actor_folder(spec ActorSpecification, params Params) !Folder

fn generate_actor_module #

fn generate_actor_module(spec ActorSpecification, params Params) !Module

fn generate_client_file #

fn generate_client_file(spec ActorSpecification) !VFile

fn generate_client_method #

fn generate_client_method(method ActorMethod) !Function

fn generate_cmd_function #

fn generate_cmd_function(spec ActorSpecification) string

fn generate_command_file #

fn generate_command_file(spec ActorSpecification) !VFile

fn generate_example_client_file #

fn generate_example_client_file(spec ActorSpecification) !VFile

fn generate_example_method_handle #

fn generate_example_method_handle(actor_name string, method ActorMethod) !Function

fn generate_examples_folder #

fn generate_examples_folder() !Folder

fn generate_handle_function #

fn generate_handle_function(spec ActorSpecification) string

fn generate_method_cmd #

fn generate_method_cmd(method ActorMethod) string

fn generate_method_cmd_function #

fn generate_method_cmd_function(actor_name string, method ActorMethod) string

fn generate_method_code #

fn generate_method_code(receiver Param, method ActorMethod) ![]CodeItem

returns bodyless method prototype

fn generate_method_example_code #

fn generate_method_example_code(receiver Param, method ActorMethod) ![]CodeItem

returns bodyless method prototype

fn generate_method_handle #

fn generate_method_handle(actor_name string, method ActorMethod) !Function

fn generate_method_prototype #

fn generate_method_prototype(receiver Param, method ActorMethod) !Function

returns bodyless method prototype

fn generate_methods_example_file #

fn generate_methods_example_file(spec ActorSpecification) !VFile

fn generate_methods_example_file_str #

fn generate_methods_example_file_str(source Source) !string

fn generate_methods_file #

fn generate_methods_file(spec ActorSpecification) !VFile

fn generate_methods_file_str #

fn generate_methods_file_str(source Source) !string

fn generate_methods_interface_declaration #

fn generate_methods_interface_declaration(spec ActorSpecification) !code.Interface

returns bodyless method prototype

fn generate_methods_interface_file #

fn generate_methods_interface_file(spec ActorSpecification) !VFile

fn generate_methods_interface_file_str #

fn generate_methods_interface_file_str(source Source) !string

fn generate_model_file #

fn generate_model_file(spec ActorSpecification) !VFile

fn generate_model_file_str #

fn generate_model_file_str(source Source) !string

fn generate_module_from_openapi #

fn generate_module_from_openapi(openapi_path string) !string

fn generate_openapi_file #

fn generate_openapi_file(specification OpenAPI) !File

fn generate_openapi_ts_client #

fn generate_openapi_ts_client(specification OpenAPI) !Folder

fn generate_openrpc_client_file #

fn generate_openrpc_client_file(spec OpenRPC) !VFile

fn generate_openrpc_client_test_file #

fn generate_openrpc_client_test_file(spec OpenRPC) !VFile

fn generate_openrpc_file #

fn generate_openrpc_file(spec OpenRPC) !File

fn generate_scripts_folder #

fn generate_scripts_folder(name string, example bool) Folder

generates the folder with runnable scripts of the actor

struct Params #

@[params]
struct Params {
pub:
	interfaces []ActorInterface // the interfaces to be supported
}

struct Source #

struct Source {
	openapi_path ?string
	openrpc_path ?string
}