Documentation
¶
Overview ¶
Package rt provides the hand-written runtime shared by the generated PHP cgo bindings: a handle registry for live *encxmobile.EncClient values and a JSON response envelope. Generated cgo wrappers call into this package; it contains no cgo itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Default = NewRegistry()
Default is the global registry used by the generated wrappers.
var ErrNilClient = errors.New("rt: cannot register nil client")
ErrNilClient is returned by Add when asked to register a nil client. Registering nil is refused rather than silently accepted, since a nil client stored under a valid handle would panic on first use instead of failing at registration time.
Functions ¶
func Fail ¶
Fail serializes an error envelope from err. A nil err still produces a valid envelope, using a stable placeholder message.
func Failf ¶
Failf serializes an error envelope from a formatted message. The message is JSON-string-escaped normally, so quotes, newlines, and non-ASCII text (e.g. Cyrillic) round-trip intact.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores live clients under integer handles suitable for passing across the C ABI (e.g. as an opaque int64 to PHP).
Handles are monotonically increasing and are never reused after Free, so a handle freed on the PHP side can never be silently reassigned to a different, unrelated client. Handle 0 is reserved and never issued; it always means "invalid handle".
func (*Registry) Add ¶
func (r *Registry) Add(c *encxmobile.EncClient) (int64, error)
Add registers c and returns a new, non-zero handle for it. It returns an error (and a zero handle) if c is nil; nil clients are never registered.
func (*Registry) Free ¶
Free removes the client registered under h. It reports whether h existed. The handle is never reused for a future Add.