# Во имя Бога Милостивого, Милосердного!!! # language: ru Функциональность: Обращения к полям Сценарий: Вызов метода * Исходник: ``` package test func foo() { foo.Bar(1,"2") } ``` * Результат: ``` void foo(); void foo() { foo->Bar(1,"2"); } ``` Сценарий: Вызов метода из пакета * Исходник: ``` package test func foo() { x = bar() y = pkg.Bar() z = x + y } ``` * Результат: ``` void foo(); void foo() { x=bar(); y=pkg->Bar(); z=x+y; } ``` Сценарий: Вызов метода из пакета ещё * Исходник: ``` package test func foo() { foo.Bar(1,"2",digital.Low) } ``` * Результат: ``` void foo(); void foo() { foo->Bar(1,"2",LOW); } ``` Сценарий: Обращение к простому полю динамически созданного класса: в фукнции и методе * Исходник: ``` package test type Device struct { v int } func NewDevice() *Device { d := &Device{} d.v = 1 return d } func (d *Device) something() { d2 := &Device{} d2.v = 1 } ``` * Результат: ``` class Device { public: int v; void something(); }; Device* NewDevice(); void Device::something() { auto d2=new Device(); d2->v=1; } Device* NewDevice() { auto d=new Device(); d->v=1; return d; } ``` Сценарий: Обращение к полю-массиву динамически созданного класса: в фукнции и методе * Исходник: ``` package test type Device struct { va []int } func NewDevice() *Device { d := &Device{} d.va[0] = 1 return d } func (d *Device) something() { d2 := &Device{} d2.va[0] = 1 } ``` * Результат: ``` class Device { public: int va[]; void something(); }; Device* NewDevice(); void Device::something() { auto d2=new Device(); d2->va[0]=1; } Device* NewDevice() { auto d=new Device(); d->va[0]=1; return d; } ``` Сценарий: Структура с обращением к полям * Исходник: ``` package test type device struct { g [8]bool } func (dev *device) doSomething(a *int) { if dev.g[0] { a:=1 } } func some(gs *GPIOS) { if gs.g[0] { a:=1 } } ``` * Результат: ``` class device { public: bool g[8]; void doSomething(int* a); }; void some(GPIOS* gs); void device::doSomething(int* a) { if (this->g[0]) { auto a=1; } } void some(GPIOS* gs) { if (gs->g[0]) { auto a=1; } } ``` Сценарий: * Исходник: ``` package test type Device struct { v int } func NewDevice() *Device { d := &Device{} d.v = 1 return d } ``` * Результат: ``` class Device { public: int v; }; Device* NewDevice(); Device* NewDevice() { auto d=new Device(); d->v=1; return d; } ```