commit 74a6a13f2e4bcc49d5441cb447621af8efb87938
parent 44d82d0f15f4165c603a90ef2e5268162b930d16
Author: Morel BĂ©renger <berengermorel76@gmail.com>
Date: Mon, 4 Sep 2023 18:55:06 +0200
uml: simplify relations
Diffstat:
M | uml | | | 18 | ++++++++++-------- |
M | uml.example | | | 35 | +++++++++++++++++------------------ |
2 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/uml b/uml
@@ -13,8 +13,9 @@ function end_class() {
if( class != "" )
{
printf( "}\"\n]\n" );
+ prev_class = class;
+ class = "";
}
- class = "";
class_type = "";
inside = "";
fields_max = 0
@@ -36,8 +37,8 @@ function fun( overload ) {
printf( "): %s %s\l", $2, overload );
}
-function relation( from, to, tail, head, label, multiplicity ) {
- printf( "%s -> %s [ dir = \"both\", arrowtail = \"%s\", arrowhead = \"%s\"", from, to, tail, head );
+function relation( to, tail, head, label, multiplicity ) {
+ printf( "%s -> %s [ dir = \"both\", arrowtail = \"%s\", arrowhead = \"%s\"", prev_class, to, tail, head );
if( label != "" )
{
printf( ", label = \"%s\"", label );
@@ -62,7 +63,7 @@ function close_relation() {
function depends( type ) {
end_class();
- relation( $2, $3, "none", "vee", type );
+ relation( $2, "none", "vee", type );
printf( " style = \"dotted\"" );
close_relation();
}
@@ -70,6 +71,7 @@ function depends( type ) {
BEGIN {
printf( "digraph %s\n{\n", FILENAME );
class = "";
+ prev_class = "";
class_type = "";
scope = "[ ]";
inside = "";
@@ -174,25 +176,25 @@ $1 == "val" {
$1 == "inherit" {
end_class();
- relation( $2, $3, "none", "empty" );
+ relation( $2, "none", "empty" );
close_relation();
}
$1 == "associate" {
end_class();
- relation( $2, $3, "none", "vee", $4, $5 );
+ relation( $2, "none", "vee", $3, $4 );
close_relation();
}
$1 == "aggreg" {
end_class();
- relation( $2, $3, "odiamond", "vee", $4, $5 );
+ relation( $2, "odiamond", "vee", $3, $4 );
close_relation();
}
$1 == "compose" {
end_class();
- relation( $2, $3, "diamond", "vee", $4, $5 );
+ relation( $2, "diamond", "vee", $3, $4 );
close_relation();
}
diff --git a/uml.example b/uml.example
@@ -8,52 +8,51 @@ package comp_tree
class component
var string id
# context help: mouse hover, description, etc
- compose component content helper 0:1
+ compose content helper 0:1
# widget's human-readable name
- compose component content label 0:1
+ compose content label 0:1
# this allows to "lock" widgets to avoid conflicting
# changes
- associate component focus controller 1
+ associate focus controller 1
class group
- inherit group component
- compose group component children
- associate group group parent
+ inherit component
+ compose component children
+ associate parent
class set_widget
- inherit set_widget component
- compose set_widget content allowed 1:n
+ inherit component
+ compose content allowed 1:n
# value[0] is the real current, value[1] is the current
# candidate. This allows for cancelation.
- associate set_widget content value 2
+ associate content value 2
class range_widget
fun content transform bool:forward content&:src_val
- inherit range_widget component
- compose range_widget content range 2
+ inherit component
+ compose content range 2
# value[0] is the real current, value[1] is the current
# candidate. This allows for cancelation.
- compose range_widget content value 2
+ compose content value 2
class edit_widget
var size_t byte_size
- inherit edit_widget component
+ inherit component
# value[0] is the real current, value[1] is the current
# candidate. This allows for cancelation.
- compose edit_widget content value 2
+ compose content value 2
class content
var string mime_type
var blob data
class focus
+ associate component target 1
endpackage
package coco
class Parser
+ associate focus
+ associate Scanner
class Scanner
- associate Parser Scanner
endpackage
-
-associate Parser focus
-associate focus component target 1