foo

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Button

type Button struct {
	Shape
	Tag
	B c.Int
}

Case 4: multiple base classes; an earlier base has no virtual methods, while a later one does. The polymorphic base (Shape) is the primary base, so the class reuses its vptr and introduces no new one; the primary base is laid out first (before the non-polymorphic Tag) to keep the shared vptr at offset 0. Shape's inherited slots (area, the two destructor slots, the private-method placeholder) precede the new click slot.

func (*Button) Click

func (this *Button) Click() c.Int

llgo:link (*Button).Click C._ZN6Button5clickEv

func (*Button) XGo_vptr

func (p *Button) XGo_vptr() *X_vtable_Button

type Circle

type Circle struct {
	Shape
	R c.Int
}

Case 3: single base class, and the base class has virtual methods. The derived class reuses the base's vptr, so it introduces no new vptr. It does not declare its own destructor, so Shape's destructor and private-method slots are inherited unchanged (with this re-typed to *Circle).

func (*Circle) Area

func (this *Circle) Area() c.Int

llgo:link (*Circle).Area C._ZN6Circle4areaEv

func (*Circle) XGo_vptr

func (p *Circle) XGo_vptr() *X_vtable_Circle

type Shape

type Shape struct {
	Id c.Int
	// contains filtered or unexported fields
}

Case 1: no base class; the class itself has virtual methods.

It also declares a virtual destructor and a private virtual method to exercise the two extra vtable slot rules:

  • a virtual destructor takes two consecutive Itanium slots, XGo_dtor (complete object) then XGo_dtor_deleting, both func(this *Shape);
  • a private virtual method still occupies a slot, emitted as an unexported placeholder so later slots keep their index.

Declaration order fixes the vtable order: area, ~Shape (two slots), reset.

func (*Shape) Area

func (this *Shape) Area() c.Int

llgo:link (*Shape).Area C._ZN5Shape4areaEv

func (*Shape) XGo_Dtor

func (this *Shape) XGo_Dtor()

llgo:link (*Shape).XGo_Dtor C._ZN5ShapeD1Ev

func (*Shape) XGo_vptr

func (p *Shape) XGo_vptr() *X_vtable_Shape

type Tag

type Tag struct {
	Tag c.Int
}

A plain base class without any virtual methods.

type Widget

type Widget struct {
	Tag
	W c.Int
	// contains filtered or unexported fields
}

Case 2: has a base class, but the base has no virtual methods; the class itself has virtual methods. It also declares a virtual destructor, so its own vtable holds paint plus the two destructor slots.

func (*Widget) Paint

func (this *Widget) Paint() c.Int

llgo:link (*Widget).Paint C._ZN6Widget5paintEv

func (*Widget) XGo_Dtor

func (this *Widget) XGo_Dtor()

llgo:link (*Widget).XGo_Dtor C._ZN6WidgetD1Ev

func (*Widget) XGo_vptr

func (p *Widget) XGo_vptr() *X_vtable_Widget

type X_vtable_Button added in v0.9.3

type X_vtable_Button struct {
	Area              func(this *Button) c.Int
	XGo_dtor          func(this *Button)
	XGo_dtor_deleting func(this *Button)

	Click func(this *Button) c.Int
	// contains filtered or unexported fields
}

llgo:type C

type X_vtable_Circle added in v0.9.3

type X_vtable_Circle struct {
	Area              func(this *Circle) c.Int
	XGo_dtor          func(this *Circle)
	XGo_dtor_deleting func(this *Circle)
	// contains filtered or unexported fields
}

llgo:type C

type X_vtable_Shape added in v0.9.3

type X_vtable_Shape struct {
	Area              func(this *Shape) c.Int
	XGo_dtor          func(this *Shape)
	XGo_dtor_deleting func(this *Shape)
	// contains filtered or unexported fields
}

llgo:type C

type X_vtable_Widget added in v0.9.3

type X_vtable_Widget struct {
	Paint             func(this *Widget) c.Int
	XGo_dtor          func(this *Widget)
	XGo_dtor_deleting func(this *Widget)
}

llgo:type C

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL