Comments (5)
@rbukovansky , something like this?:
source "$( cd "${BASH_SOURCE[0]%/*}" && cd .. && pwd )/lib/oo-bootstrap.sh"
import util/class
class:Location() {
public string x
public string y
}
Type::Initialize Location
class:Vehicle() {
public Location location
public string name
Vehicle.getter() {
@return:value $(this location toString)
}
Vehicle.Set() {
[reference] toSet
this location x = $($var:toSet x)
this location y = $($var:toSet y)
}
}
Type::Initialize Vehicle
string xSample=33
string ySample=55
Location locationSample
$var:locationSample x = $xSample
$var:locationSample y = $ySample
echo '--------------'
$var:locationSample
Vehicle vehicleSample
$var:vehicleSample Set locationSample
echo '--------------'
$var:vehicleSample
Results:
([__object_type]="Location" [x]="33" [y]="55" )
([location]="([0]=\"([__object_type]=\\\"Location\\\" [x]=\\\"33\\\" [y]=\\\"55\\\" )\")" [__object_type]="Vehicle" )
from bash-oo-framework.
@constrict0r Holy crackers! 😮 Thanks a lot! 👍
from bash-oo-framework.
Maybe you could check the option class I created, it has an Options collection:
https://github.com/niieani/bash-oo-framework/blob/d71a74aad77a1bfcdaff032b81090dfd1507e221/lib/util/option.sh
from bash-oo-framework.
@constrict0r, that's some hefty work indeed. Pretty cool!
@rbukovansky to answer your questions:
- creating collections of class instances is a bit tricky for now, but you can capture the definitions of instances (result of
declare -p YOUR_VARIABLE
and store them in a normal Array). The instance is sort of "serialized" that way. - second is possible and should just work as long as you initialize your type before defining the other class. If it doesn't happen, feel free to open an issue, as it's a bug.
from bash-oo-framework.
@constrict0r Thanks, but I'm not sure, which question your answer answers. 🤷🏻♂️ Could you please elaborate a little bit more? Thank you!
@niieani So, you mean I need to:
- Create Class Location
- Create an object of class Location
- Set its properties
- Create Class Vehicle
- Create an object of class Vehicle
from bash-oo-framework.
Related Issues (20)
- Is the project dead? HOT 3
- Sorry, a bit cheeky/impolite... HOT 2
- error handling with throw / command_not_found_handle HOT 3
- Unbound variables cause a crash when running examples with 'set -u' HOT 3
- [bug?] `throw` is said to be 'undefined command' when `import` fail HOT 5
- Catch exception from Classes doesn't work HOT 7
- Inconsistent array assignments HOT 3
- Translating README into Japanese
- for people who want to use Bpkg to install this framework HOT 1
- example/trycatch.sh doesn't work as expected
- Make wiki page
- [Question] Does value of '__primitive_extension_fingerprint' have special meaning?
- update readme instructions for namedParameters
- util/exception.sh shows stack trace as expected but don't exit on Ctrl+C HOT 2
- False boolean not working HOT 1
- Referring this in Human example class doesn't work as described HOT 1
- Exception messages are invisible in light theme mode in Shell console.
- [Question] Is this project still alive? HOT 6
- [Discussion] Log API
- Using a variable for an Object name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bash-oo-framework.