Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
kazoo
Commits
177402f6
Commit
177402f6
authored
Jan 27, 2018
by
Maxime Perrotin
Browse files
Simplify templates with custom strip filter
parent
831f29d0
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/taste-backend-skeletons.adb
View file @
177402f6
...
...
@@ -231,4 +231,39 @@ package body TASTE.Backend.Skeletons is
return
Result
;
end
Interface_View_Template
;
end
TASTe
.
Backend
.
Skeletons
;
-- Define a custom "Strip" filter for the templates
function
Custom_Strip_Filter
(
Value
:
String
;
Context
:
Filter_Context
)
return
String
is
pragma
Unreferenced
(
Context
);
Pre_Count
,
Post_Count
:
Natural
:=
0
;
Index
:
Natural
:=
0
;
Discard
:
Boolean
:=
True
;
Result
:
String
(
1
..
Value
'
Length
);
begin
for
Each
of
Value
loop
exit
when
Discard
=
False
;
if
Is_Line_Terminator
(
Each
)
or
Is_Space
(
Each
)
then
Pre_Count
:=
Pre_Count
+
1
;
else
Discard
:=
False
;
end
if
;
end
loop
;
Discard
:=
True
;
for
Each
of
reverse
Value
loop
exit
when
Discard
=
False
;
if
Is_Line_Terminator
(
Each
)
or
Is_Space
(
Each
)
then
Post_Count
:=
Post_Count
+
1
;
else
Discard
:=
False
;
end
if
;
end
loop
;
for
I
in
Value
'
First
+
Pre_Count
..
Value
'
Last
-
Post_Count
loop
Index
:=
Index
+
1
;
Result
(
Index
)
:=
Value
(
I
);
end
loop
;
return
Result
(
1
..
Index
);
end
Custom_Strip_Filter
;
begin
Register_Filter
(
"STRIP"
,
Custom_Strip_Filter
'
Access
);
end
TASTE
.
Backend
.
Skeletons
;
src/taste-backend-skeletons.ads
View file @
177402f6
...
...
@@ -44,4 +44,8 @@ private
return
Func_As_Template
;
function
Interface_View_Template
(
IV
:
Complete_Interface_View
)
return
IV_As_Template
;
function
Custom_Strip_Filter
(
Value
:
String
;
Context
:
Filter_Context
)
return
String
;
end
TASTE
.
Backend
.
Skeletons
;
templates/skeletons/ada/header.tmplt
View file @
177402f6
...
...
@@ -28,16 +28,16 @@ package @_CAPITALIZE:Name_@ is
--
PROVIDED
INTERFACES
---------------------------------------------------
@@
TABLE
@@
procedure
@
_
REPLACE_ALL
((\
n
)/)
:
Provided_Interfaces_
@
with
Export
,
Convention
=>
C
,
Link_Name
=>
"@_LOWER:Name_@_PI_@_
REPLACE_ALL((
\n
)/)
:LOWER:REPLACE(^(\S+)\s+.*/
\1)
:Provided_Interfaces_@"
;
procedure
@
_
STRIP
:
Provided_Interfaces_
@
with
Export
,
Convention
=>
C
,
Link_Name
=>
"@_LOWER:Name_@_PI_@_
STRIP
:LOWER:REPLACE(^(\S+)\s+.*/
\1)
:Provided_Interfaces_@"
;
@@
END_TABLE
@@
--
REQUIRED
INTERFACES
---------------------------------------------------
@@
TABLE
@@
procedure
@
_
REPLACE_ALL
((\
n
)/)
:
Required_Interfaces_
@
with
Import
,
Convention
=>
C
,
Link_Name
=>
"@_LOWER:Name_@_RI_@_
REPLACE_ALL((
\n
)/)
:LOWER:REPLACE(^(\S+)\s+.*/
\1)
:Required_Interfaces_@"
;
procedure
RI
Ü
@
_
REPLACE_ALL
((\
n
)/)
:
Required_Interfaces_
@
renames
@
_
REPLACE_ALL
((\
n
)/)
:
CAPITALIZE
:
REPLACE
(^(\
S
+)\
s
+.*/\
1
):
Required_Interfaces_
@;
procedure
@
_
STRIP
:
Required_Interfaces_
@
with
Import
,
Convention
=>
C
,
Link_Name
=>
"@_LOWER:Name_@_RI_@_
STRIP
:LOWER:REPLACE(^(\S+)\s+.*/
\1)
:Required_Interfaces_@"
;
procedure
RI
Ü
@
_
STRIP
:
Required_Interfaces_
@
renames
@
_
STRIP
:
CAPITALIZE
:
REPLACE
(^(\
S
+)\
s
+.*/\
1
):
Required_Interfaces_
@;
@@
END_TABLE
@@
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment