Documentation ¶
Index ¶
- func IsFunc(fun interface{}) (b bool)
- func Name(fun interface{}) (s string)
- func Signature(fun interface{}, name ...string) (sgn string)
- func Type(fun interface{}) (t reflect.Type)
- type CallerInfo
- type Function
- type FunctionBinding
- type LanguageBinding
- func (lb *LanguageBinding) Add(a *Namespace, b *Namespace) (status bool)
- func (lb *LanguageBinding) External(inter *Namespace) (exter *Namespace)
- func (lb *LanguageBinding) Internal(exter *Namespace) (inter *Namespace)
- func (lb *LanguageBinding) RemoveInternal(ns *Namespace) (status bool)
- func (lb LanguageBinding) String() (s string)
- type Namespace
- type NamespaceDictionary
- func (nsd *NamespaceDictionary) Add(ns Namespace) (status bool)
- func (nsd *NamespaceDictionary) Reference(ns Namespace) (ref *Namespace)
- func (nsd *NamespaceDictionary) Remove(ns Namespace) (status bool)
- func (nsd NamespaceDictionary) String() (s string)
- func (nsd *NamespaceDictionary) Value(ref *Namespace) (ns Namespace)
- type Registry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFunc ¶
func IsFunc(fun interface{}) (b bool)
IsFunc returns true if interface fun is a function or method and false otherwise.
func Name ¶
func Name(fun interface{}) (s string)
Name returns name of the function as a string s. Name will panic if function is not a function or method.
Types ¶
type CallerInfo ¶
CallerInfo is a structure for containing function caller information.
func ExtractCallerInfo ¶
func ExtractCallerInfo(depth int) (ci CallerInfo)
ExtractCallerInfo returns caller info associated to a function call given a depth. ExtractCallerInfo returns unknown caller info if frame unwinding fails.
type FunctionBinding ¶
FunctionBinding maintains a function binding.
func NewFunctionBinding ¶
func NewFunctionBinding() (fb FunctionBinding)
NewFunctionBinding creates a binding between a reference to a namespace and a function.
func (*FunctionBinding) Add ¶
func (fb *FunctionBinding) Add(ref *Namespace, fun *Function) (status bool)
Add a binding to fb between a namespace ref and function fun. Add returns true if the addition of the binding was successful, and false otherwise.
func (*FunctionBinding) Function ¶
func (fb *FunctionBinding) Function(ref *Namespace) (fun *Function)
Function returns a pointer to function fun given a namespace reference ref. Function returns nil if no function is a attached to the namespace reference ref.
func (*FunctionBinding) Remove ¶
func (fb *FunctionBinding) Remove(ref *Namespace) (status bool)
Remove a binding from fb given a namespace reference ref. Remove returns true if the removal of the binding was successful, and false otherwise.
func (FunctionBinding) String ¶
func (fb FunctionBinding) String() (s string)
String returns a print friendly representation of a function binding fb.
type LanguageBinding ¶
type LanguageBinding struct { InternalToExternal *sync.Map // [*Namespace]*Namespace ExternalToInternal *sync.Map // [*Namespace]*Namespace }
LanguageBinding is a structure to maintain a function mapping between two languages.
func NewLanguageBinding ¶
func NewLanguageBinding() (lb LanguageBinding)
NewLanguageBinding creates a two-way binding lb between two namespaces in two different languages.
func (*LanguageBinding) Add ¶
func (lb *LanguageBinding) Add(a *Namespace, b *Namespace) (status bool)
Add will add a new language binding between two namespaces a and b. Add returns true if the addition of namespace ns was successful, and false otherwise.
func (*LanguageBinding) External ¶
func (lb *LanguageBinding) External(inter *Namespace) (exter *Namespace)
External returns the external namespace reference exter given an internal namespace reference inter. External returns nil if the internal namespace reference inter could not be found.
func (*LanguageBinding) Internal ¶
func (lb *LanguageBinding) Internal(exter *Namespace) (inter *Namespace)
Internal returns the internal namespace reference a given an external namespace reference b. Internal returns nil if the internal namespace reference a could not be found.
func (*LanguageBinding) RemoveInternal ¶
func (lb *LanguageBinding) RemoveInternal(ns *Namespace) (status bool)
RemoveInternal removes a binding for the internal namespace ns from the language bindings dictionary lb. RemoveInternal returns true if the removal of the binding namespace ns was successful, and false otherwise.
func (LanguageBinding) String ¶
func (lb LanguageBinding) String() (s string)
String returns a print friendly representation of a language binding lb.
type Namespace ¶
type Namespace string
Namespace is a representation of a location of a function.
func NewNamespace ¶
NewNamespace creates a new namespace from a string.
type NamespaceDictionary ¶
type NamespaceDictionary struct { RefLookUp *sync.Map // [*Namespace]Namespace NameLookUp *sync.Map // [Namespace]*Namespace }
NamespaceDictionary is a representation for looking up namespaces names.
func NewNamespaceDictionary ¶
func NewNamespaceDictionary() (nsd NamespaceDictionary)
NewNamespaceDictionary creates a two-way dictionary for looking up between a reference of a namespace and namespace itself.
func (*NamespaceDictionary) Add ¶
func (nsd *NamespaceDictionary) Add(ns Namespace) (status bool)
Add will add a namespace ns to a namespace dictionary nsd. Add returns true if the addition of namespace ns was successful, and false otherwise.
func (*NamespaceDictionary) Reference ¶
func (nsd *NamespaceDictionary) Reference(ns Namespace) (ref *Namespace)
Reference returns a reference ref for the namespace ns from namespace dictionary nsd.
func (*NamespaceDictionary) Remove ¶
func (nsd *NamespaceDictionary) Remove(ns Namespace) (status bool)
Remove will remove a namespace ns from the namespace dictionary nsd. Remove returns true if the removal of namespace ns, and false otherwise.
func (NamespaceDictionary) String ¶
func (nsd NamespaceDictionary) String() (s string)
String returns a print friendly representation of a namespace dictionary nsd.
func (*NamespaceDictionary) Value ¶
func (nsd *NamespaceDictionary) Value(ref *Namespace) (ns Namespace)
Value returns a namespace value ns from a namespace dictionary nsd given a reference ref.
type Registry ¶
type Registry struct { NameDict NamespaceDictionary FuncBind FunctionBinding LangBind LanguageBinding }
Registry represents the available functions between languages.
var GlobalRegistry *Registry
GlobalRegistry is the global function registry used throughout the library.
func (*Registry) Check ¶
Check performs a check if function fun is registered in function registry fr. Check returns true if function fun is registered, and false otherwise.
func (*Registry) Decode ¶
Decode returns a function fun given an external namespace ns. Decode returns nil if the function could not be found.
func (*Registry) Encode ¶
Encode returns a pointer to an external namespace ns for function fun. Encode returns nil if the function could not be encoded.
func (*Registry) Register ¶
Register performs a registring of function fun to function registry fr. Register returns true if registring of function fun was succesful, and false otherwise.
func (*Registry) Unregister ¶
Unregister performs a unregistring of function fun from function registry fr. Unregister returns true if unregistring of function fun was succesful, and false otherwise.