| 1 |
% Copyright 2005 2015 Ovidiu Gheorghies |
| 2 |
% Licensed under the Apache License, Version 2.0. |
| 3 |
|
| 4 |
if known _util_infrastructure_mp: |
| 5 |
expandafter endinput |
| 6 |
fi; |
| 7 |
_util_infrastructure_mp:=1; |
| 8 |
|
| 9 |
% Sadly, this copy of the macro is needed to prevent multiple file loads being shown by MetaPost. |
| 10 |
% The guard values (such as _metauml_mp) do ensure that the file isn't loaded multiple times, |
| 11 |
% but this macro makes sure that MetaPost won't try to load the file and display a message for that. |
| 12 |
def inputonce text libraryFile= |
| 13 |
if not known scantokens ("_" & str libraryFile & "_mp"): |
| 14 |
%includeonce% show "Loading " & str libraryFile; |
| 15 |
scantokens ("input " & str libraryFile); |
| 16 |
else: |
| 17 |
%includeonce% show str libraryFile & " already loaded."; |
| 18 |
fi; |
| 19 |
enddef; |
| 20 |
|
| 21 |
inputonce util_log; |
| 22 |
|
| 23 |
vardef attributes(text objectName)= |
| 24 |
_n_ := str objectName |
| 25 |
enddef; |
| 26 |
|
| 27 |
vardef variables_ext text variables= |
| 28 |
save ret, firstVar; |
| 29 |
string ret; |
| 30 |
ret := ""; |
| 31 |
|
| 32 |
numeric firstVar; |
| 33 |
firstVar := 1; |
| 34 |
|
| 35 |
forsuffixes v = variables: |
| 36 |
if firstVar = 0: |
| 37 |
ret := ret & ","; |
| 38 |
else: |
| 39 |
firstVar := 0; |
| 40 |
fi; |
| 41 |
|
| 42 |
ret := ret & " _n." & (str v); |
| 43 |
endfor; |
| 44 |
|
| 45 |
ret |
| 46 |
enddef; |
| 47 |
|
| 48 |
vardef var(text type) text variables = |
| 49 |
save _variables; |
| 50 |
string _variables; |
| 51 |
_variables := variables_ext variables; |
| 52 |
|
| 53 |
generic_declare(type) scantokens _variables; |
| 54 |
enddef; |
| 55 |
|
| 56 |
|