Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kam-printing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wizards
kam-printing
Commits
13ee309a
Commit
13ee309a
authored
13 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
PPD: Constraints
parent
25f0dc8b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ppd/PPD.pm
+52
-2
52 additions, 2 deletions
ppd/PPD.pm
ppd/gen-hp
+11
-0
11 additions, 0 deletions
ppd/gen-hp
with
63 additions
and
2 deletions
ppd/PPD.pm
+
52
−
2
View file @
13ee309a
...
...
@@ -4,10 +4,11 @@ use strict;
use
warnings
;
use
Exporter
'
import
';
our
@EXPORT
=
qw(define_group define_ui_group switch_group declare get set maybe_set option gen_values generate)
;
our
@EXPORT
=
qw(define_group define_ui_group switch_group declare get set maybe_set option
constrain
gen_values generate)
;
### PPD data model ###
### Keywords ###
# Key => {
# Key => key,
# Name => name, # descriptive name (default: same as Key)
...
...
@@ -36,6 +37,7 @@ our @EXPORT = qw(define_group define_ui_group switch_group declare get set maybe
# }
my
%keywords
=
();
### Groups ###
# Key => {
# Key => key,
# UI => 1, # if a UI group
...
...
@@ -48,6 +50,18 @@ my @ui_groups = ();
my
@nonui_groups
=
();
my
$current_group_key
;
### Constraints ###
# {
# Name => name,
# Pairs => [{
# K1 => key,
# V1 => value,
# K2 => key,
# V2 => value,
# }],
# ]
my
@constraints
=
();
sub
define_group
($$)
{
my
(
$key
,
$g
)
=
@_
;
!
defined
$groups
{
$key
}
or
die
"
Group
$key
already exists
\n
";
...
...
@@ -137,6 +151,26 @@ sub option($) {
push
@
{
$g
->
{
Keywords
}},
$o
;
}
sub
constrain
($$$$)
{
my
(
$name
,
$k1
,
$k2
,
$condition
)
=
@_
;
$name
//
=
"
$k1
vs.
$k2
";
my
$kw1
=
$keywords
{
$k1
}
or
die
"
Want to create constraint for unknown keyword
$k1
\n
";
my
$kw2
=
$keywords
{
$k2
}
or
die
"
Want to create constraint for unknown keyword
$k2
\n
";
$kw1
->
{
Type
}
eq
'
o
'
&&
$kw2
->
{
Type
}
eq
'
o
'
or
die
"
Want to create constraint between non-option keywords
$k1
and
$k2
\n
";
my
@c
=
();
for
my
$vv1
(
@
{
$kw1
->
{
Values
}})
{
for
my
$vv2
(
@
{
$kw2
->
{
Values
}})
{
my
$v1
=
$vv1
->
{
Key
};
my
$v2
=
$vv2
->
{
Key
};
if
(
!
&
{
$condition
}(
$v1
,
$v2
))
{
push
@c
,
{
K1
=>
$k1
,
V1
=>
$v1
,
K2
=>
$k2
,
V2
=>
$v2
};
push
@c
,
{
K1
=>
$k2
,
V1
=>
$v2
,
K2
=>
$k1
,
V2
=>
$v1
};
}
}
}
push
@constraints
,
{
Name
=>
$name
,
Pairs
=>
[
@c
]
}
if
@c
;
}
### Auxiliary functions ###
sub
gen_values
($@)
{
...
...
@@ -291,7 +325,21 @@ sub emit_group($) {
for
my
$k
(
@$keywords
)
{
emit_keyword
(
$k
);
}
if
(
$g
->
{
UI
})
{
print
"
\n
",
'
*CloseGroup:
',
$g
->
{
Key
},
"
\n
";
}
if
(
$g
->
{
UI
})
{
print
'
*CloseGroup:
',
$g
->
{
Key
},
"
\n
";
}
}
sub
emit_constraints
()
{
for
my
$cc
(
@constraints
)
{
heading
(
$cc
->
{
Name
});
for
my
$c
(
@
{
$cc
->
{
Pairs
}})
{
printf
"
*%sUIConstraints: *%s %s *%s %s
\n
",
((
!
$keywords
{
$c
->
{
K1
}}
->
{
Choice
}
||
!
$keywords
{
$c
->
{
K2
}}
->
{
Choice
}))
?
"
Non
"
:
"",
$c
->
{
K1
},
$c
->
{
V1
},
$c
->
{
K2
},
$c
->
{
V2
};
}
}
}
sub
fill_defaults
()
{
...
...
@@ -331,6 +379,8 @@ sub generate() {
for
my
$g
(
@head_groups
,
@ui_groups
,
@nonui_groups
)
{
emit_group
(
$groups
{
$g
});
}
emit_constraints
();
}
42
;
This diff is collapsed.
Click to expand it.
ppd/gen-hp
+
11
−
0
View file @
13ee309a
...
...
@@ -122,4 +122,15 @@ option({
],
});
constrain
(
undef
,
'
InputSlot
',
'
MediaType
',
sub
{
my
(
$is
,
$mt
)
=
@_
;
return
!
((
$is
eq
'
Tray2
'
||
$is
eq
'
Tray3
')
&&
(
$mt
eq
'
Labels
'
||
$mt
eq
'
Envelope
'));
});
constrain
(
undef
,
'
Duplex
',
'
MediaType
',
sub
{
my
(
$dp
,
$mt
)
=
@_
;
return
!
(
$dp
ne
'
None
'
&&
$mt
=~
/^(Labels|Transparency|Bond)$/
);
});
generate
();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment