diff options
-rw-r--r-- | metapost/context/base/mp-mlib.mpiv | 181 | ||||
-rw-r--r-- | tex/context/base/cont-new.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/context-version.pdf | bin | 4110 -> 4130 bytes | |||
-rw-r--r-- | tex/context/base/context.mkiv | 2 | ||||
-rw-r--r-- | tex/context/base/meta-tex.lua | 2 | ||||
-rw-r--r-- | tex/context/base/mlib-pdf.lua | 51 | ||||
-rw-r--r-- | tex/context/base/status-files.pdf | bin | 24612 -> 24632 bytes | |||
-rw-r--r-- | tex/context/base/status-lua.pdf | bin | 228104 -> 228251 bytes | |||
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 2 |
9 files changed, 210 insertions, 30 deletions
diff --git a/metapost/context/base/mp-mlib.mpiv b/metapost/context/base/mp-mlib.mpiv index dfb3f7102..9395cac8c 100644 --- a/metapost/context/base/mp-mlib.mpiv +++ b/metapost/context/base/mp-mlib.mpiv @@ -808,7 +808,7 @@ vardef mfun_pair_to_string(expr p) = decimal ypart p enddef ; -vardef mfun_rbgcolor_to_string(expr c) = +vardef mfun_rgbcolor_to_string(expr c) = decimal redpart c & " " & decimal greenpart c & " " & decimal bluepart c @@ -829,18 +829,18 @@ vardef mfun_boolean_to_string(expr b) = if b : "true" else : "false" fi enddef ; -def passvariable(expr key, value) = - special - if numeric value : "1:" & key & "=" & mfun_numeric_to_string(value) - elseif pair value : "4:" & key & "=" & mfun_pair_to_string(value) - elseif rgbcolor value : "5:" & key & "=" & mfun_rgbcolor_to_string(value) - elseif cmykcolor value : "6:" & key & "=" & mfun_cmykcolor_to_string(value) - elseif boolean value : "3:" & key & "=" & mfun_boolean_to_string(value) - elseif path value : "7:" & key & "=" & mfun_path_to_string(value) - elseif transform value : "8:" & key & "=" & mfun_transform_to_string(value) - else : "2:" & key & "=" & value - fi ; -enddef ; +% def passvariable(expr key, value) = +% special +% if numeric value : "1:" & key & "=" & mfun_numeric_to_string(value) +% elseif pair value : "4:" & key & "=" & mfun_pair_to_string(value) +% elseif rgbcolor value : "5:" & key & "=" & mfun_rgbcolor_to_string(value) +% elseif cmykcolor value : "6:" & key & "=" & mfun_cmykcolor_to_string(value) +% elseif boolean value : "3:" & key & "=" & mfun_boolean_to_string(value) +% elseif path value : "7:" & key & "=" & mfun_path_to_string(value) +% elseif transform value : "8:" & key & "=" & mfun_transform_to_string(value) +% else : "2:" & key & "=" & value +% fi ; +% enddef ; vardef tostring(expr value) = if numeric value : mfun_numeric_to_string(value) @@ -866,6 +866,161 @@ vardef mfun_tagged_string(expr value) = fi enddef ; +% amore flexible variant for passing data to context + +vardef mfun_point_to_lua(expr p,i) = + "{" & + decimal xpart (point i of p) & "," & + decimal ypart (point i of p) & "," & + decimal xpart (precontrol i of p) & "," & + decimal ypart (precontrol i of p) & "," & + decimal xpart (postcontrol i of p) & "," & + decimal ypart (postcontrol i of p) + & "}" +enddef ; + +vardef mfun_transform_to_lua(expr t) = + "{" & + decimal xxpart t & "," & % rx + decimal xypart t & "," & % sx + decimal yxpart t & "," & % sy + decimal yypart t & "," & % ry + decimal xpart t & "," & % tx + decimal ypart t % ty + & "}" +enddef ; + +vardef mfun_numeric_to_lua(expr n) = + decimal n +enddef ; + +vardef mfun_pair_to_lua(expr p) = + "{" & + decimal xpart p & "," & + decimal ypart p + & "}" +enddef ; + +vardef mfun_rgbcolor_to_lua(expr c) = + "{" & + decimal redpart c & "," & + decimal greenpart c & "," & + decimal bluepart c + & "}" +enddef ; + +vardef mfun_cmykcolor_to_lua(expr c) = + "{" & + decimal cyanpart c & "," & + decimal magentapart c & "," & + decimal yellowpart c & "," & + decimal blackpart c + & "}" +enddef ; + +vardef mfun_path_to_lua(expr p) = + "{" & + mfun_point_to_lua(p,0) for i=1 upto length(p) : & "," & mfun_point_to_lua(p,i) endfor + & "}" +enddef ; + +vardef mfun_boolean_to_lua(expr b) = + if b : "true" else : "false" fi +enddef ; + +vardef mfun_string_to_lua(expr s) = + "[==[" & s & "]==]" +enddef ; + +def mfun_to_lua(expr key)(expr value)(text t) = + special "metapost.variables['" & key & "']=" & t(value) ; +enddef ; + +def mfun_array_to_lua(expr key)(suffix value)(expr first, last, stp)(text t) = + special + "metapost.variables['" & key & "']={" + for i=first step stp until last : + & t(value[i]) & "," + endfor + & "}" ; +enddef ; + +def passvariable(expr key, value) = + if numeric value : mfun_to_lua(key,value,mfun_numeric_to_lua) + elseif pair value : mfun_to_lua(key,value,mfun_pair_to_lua) + elseif string value : mfun_to_lua(key,value,mfun_string_to_lua) + elseif boolean value : mfun_to_lua(key,value,mfun_boolean_to_lua) + elseif path value : mfun_to_lua(key,value,mfun_path_to_lua) + elseif rgbcolor value : mfun_to_lua(key,value,mfun_rgbcolor_to_lua) + elseif cmykcolor value : mfun_to_lua(key,value,mfun_cmykcolor_to_lua) + elseif transform value : mfun_to_lua(key,value,mfun_transform_to_lua) + fi ; +enddef ; + +def passarrayvariable(expr key)(suffix values)(expr first, last, stp) = + if numeric values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_numeric_to_lua) + elseif pair values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_pair_to_lua) + elseif string values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_string_to_lua) + elseif boolean values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_boolean_to_lua) + elseif path values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_path_to_lua) + elseif rgbcolor values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_rgbcolor_to_lua) + elseif cmykcolor values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_cmykcolor_to_lua) + elseif transform values[first] : mfun_array_to_lua(key,values,first,last,stp,mfun_transform_to_lua) + fi ; +enddef ; + +def startpassingvariable(expr k) = + begingroup ; + save stoppassingvariable, startarray, stoparray, starthash, stophash, key, value ; + let stoppassingvariable = mfun_stop_lua_variable ; + let startarray = mfun_start_lua_array ; + let stoparray = mfun_stop_lua_array ; + let starthash = mfun_start_lua_hash ; + let stophash = mfun_stop_lua_hash ; + let key = mfun_lua_key ; + let value = mfun_lua_value ; + save s ; string s ; + s := "metapost.variables['" & k & "']=" +enddef ; + +def mfun_stop_lua_variable = + ; + special substring(0,length(s)-1) of s ; + endgroup ; +enddef ; + +def mfun_start_lua_array = + & "{" +enddef ; + +def mfun_stop_lua_array = + & "}," +enddef ; + +def mfun_start_lua_hash = + & "{" +enddef ; + +def mfun_stop_lua_hash = + & "}," +enddef ; + +def mfun_lua_key(expr k) = + & "['" & k & "']=" +enddef ; + +def mfun_lua_value(expr v) = + if numeric v : & mfun_numeric_to_lua(v) & "," + elseif pair v : & mfun_pair_to_lua(v) & "," + elseif string v : & mfun_string_to_lua(v) & "," + elseif boolean v : & mfun_boolean_to_lua(v) & "," + elseif path v : & mfun_path_to_lua(v) & "," + elseif rgbcolor v : & mfun_rgbcolor_to_lua(v) & "," + elseif cmykcolor v : & mfun_cmykcolor_to_lua(v) & "," + elseif transform v : & mfun_transform_to_lua(v) & "," + fi +enddef ; + % moved here from mp-grap.mpiv vardef escaped_format(expr s) = diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv index 12841a278..fd4d7d417 100644 --- a/tex/context/base/cont-new.mkiv +++ b/tex/context/base/cont-new.mkiv @@ -11,7 +11,7 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -\newcontextversion{2013.12.20 00:55} +\newcontextversion{2013.12.22 15:54} %D This file is loaded at runtime, thereby providing an excellent place for %D hacks, patches, extensions and new features. diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf Binary files differindex a690bcfec..93b162f8d 100644 --- a/tex/context/base/context-version.pdf +++ b/tex/context/base/context-version.pdf diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv index 976760be7..193177d14 100644 --- a/tex/context/base/context.mkiv +++ b/tex/context/base/context.mkiv @@ -28,7 +28,7 @@ %D up and the dependencies are more consistent. \edef\contextformat {\jobname} -\edef\contextversion{2013.12.20 00:55} +\edef\contextversion{2013.12.22 15:54} \edef\contextkind {beta} %D For those who want to use this: diff --git a/tex/context/base/meta-tex.lua b/tex/context/base/meta-tex.lua index e1398e7ed..7a4123abb 100644 --- a/tex/context/base/meta-tex.lua +++ b/tex/context/base/meta-tex.lua @@ -132,6 +132,8 @@ function metapost.format_number(fmt,num) end end +-- This is experimental and will change! + function metapost.svformat(fmt,str) metapost.format_string(fmt,metapost.untagvariable(str,false)) end diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua index 1f37223a7..f10d28bf8 100644 --- a/tex/context/base/mlib-pdf.lua +++ b/tex/context/base/mlib-pdf.lua @@ -275,28 +275,35 @@ local equal = P("=") local key = C((1-equal)^1) * equal local newline = S("\n\r")^1 local number = (((1-space-newline)^1) / tonumber) * (space^0) + +local p_number = number +local p_string = C((1-newline)^0) +local p_boolean = P("false") * Cc(false) + P("true") * Cc(true) +local p_set = Ct(number^1) +local p_path = Ct(Ct(number * number^-5)^1) + local variable = - P("1:") * key * number - + P("2:") * key * C((1-newline)^0) - + P("3:") * key * (P("false") * Cc(false) + P("true") * Cc(true)) - + S("4568") * P(":") * key * Ct(number^1) - + P("7:") * key * Ct(Ct(number * number^-5)^1) + P("1:") * key * p_number + + P("2:") * key * p_string + + P("3:") * key * p_boolean + + S("4568") * P(":") * key * p_set + + P("7:") * key * p_path local pattern_key = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset) local variable = - P("1:") * number - + P("2:") * C((1-newline)^0) - + P("3:") * (P("false") * Cc(false) + P("true") * Cc(true)) - + S("4568") * P(":") * Ct(number^1) - + P("7:") * Ct(Ct(number * number^-5)^1) + P("1:") * p_number + + P("2:") * p_string + + P("3:") * p_boolean + + S("4568") * P(":") * p_set + + P("7:") * p_path local pattern_tab = Cf ( Carg(1) * (Cg(variable * newline^0)^0), rawset) local variable = - P("1:") * number - + P("2:") * C((1-newline)^0) - + P("3:") * (P("false") * Cc(false) + P("true") * Cc(true)) + P("1:") * p_number + + P("2:") * p_string + + P("3:") * p_boolean + S("4568") * P(":") * number^1 + P("7:") * (number * number^-5)^1 @@ -337,6 +344,19 @@ function metapost.untagvariable(str,variables) end end +-- function metapost.processspecial(str) +-- lpegmatch(pattern_key,object.prescript,1,variables) +-- end + +function metapost.processspecial(str) + local code = loadstring(str) + if code then + code() + else + report_metapost("invalid special: %s",str) + end +end + function metapost.flush(result,flusher,askedfig) if result then local figures = result.fig @@ -350,6 +370,7 @@ function metapost.flush(result,flusher,askedfig) local stopfigure = flusher.stopfigure local flushfigure = flusher.flushfigure local textfigure = flusher.textfigure + local processspecial = flusher.processspecial or metapost.processspecial for f=1,#figures do local figure = figures[f] local objects = getobjects(result,figure,f) @@ -392,7 +413,9 @@ function metapost.flush(result,flusher,askedfig) if objecttype == "start_bounds" or objecttype == "stop_bounds" then -- skip elseif objecttype == "special" then - lpegmatch(pattern_key,object.prescript,1,variables) + if processspecial then + processspecial(object.prescript) + end elseif objecttype == "start_clip" then t[#t+1] = "q" flushnormalpath(object.path,t,false) diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf Binary files differindex cb9c68b5d..d89b1518c 100644 --- a/tex/context/base/status-files.pdf +++ b/tex/context/base/status-files.pdf diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf Binary files differindex 270d2ec65..3f518e547 100644 --- a/tex/context/base/status-lua.pdf +++ b/tex/context/base/status-lua.pdf diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index 228b9727c..268282011 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 12/20/13 23:45:10 +-- merge date : 12/22/13 15:54:26 do -- begin closure to overcome local limits and interference |