dyndoc-ruby-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/dyndoc/.DS_Store +0 -0
  3. data/dyndoc/Dyn/.postload +1 -0
  4. data/dyndoc/Dyn/.preload +1 -0
  5. data/dyndoc/Dyn/After.dyn +3 -0
  6. data/dyndoc/Dyn/Base.dyn +18 -0
  7. data/dyndoc/Dyn/Minimum.dyn +20 -0
  8. data/dyndoc/Model/Html/DefaultPost_html.dyn +5 -0
  9. data/dyndoc/Model/Html/DefaultPre_html.dyn +15 -0
  10. data/dyndoc/Model/Odt/DefaultPost_content.xml +3 -0
  11. data/dyndoc/Model/Odt/DefaultPost_tmpl_content.xml +3 -0
  12. data/dyndoc/Model/Odt/DefaultPre_content.xml +8 -0
  13. data/dyndoc/Model/Odt/DefaultPre_tmpl_content.xml +8 -0
  14. data/dyndoc/Model/Tex/ContentPost_tmpl.tex +1 -0
  15. data/dyndoc/Model/Tex/ContentPre_tmpl.tex +6 -0
  16. data/dyndoc/Model/Tex/DefaultPost_tmpl.tex +73 -0
  17. data/dyndoc/Model/Tex/DefaultPre_tmpl.tex +16 -0
  18. data/dyndoc/Model/Ttm/DefaultPost_tmpl.ttm +3 -0
  19. data/dyndoc/Model/Ttm/DefaultPre_tmpl.ttm +16 -0
  20. data/dyndoc/Std/Array.dyn +96 -0
  21. data/dyndoc/Std/Composer.dyn +38 -0
  22. data/dyndoc/Std/DevTag.dyn +101 -0
  23. data/dyndoc/Std/DynVar.dyn +23 -0
  24. data/dyndoc/Std/File.dyn +55 -0
  25. data/dyndoc/Std/Git.dyn +34 -0
  26. data/dyndoc/Std/List.dyn +46 -0
  27. data/dyndoc/Std/OOP.dyn +32 -0
  28. data/dyndoc/Std/Signal.dyn +18 -0
  29. data/dyndoc/Std/String.dyn +22 -0
  30. data/dyndoc/Std/Styles.dyn +1 -0
  31. data/dyndoc/Std/Test.dyn +282 -0
  32. data/dyndoc/Std/Utils.dyn +42 -0
  33. data/dyndoc/Std/Verb.dyn +5 -0
  34. data/dyndoc/Style/Notation/Math.dyn +7 -0
  35. data/dyndoc/Style/Notation/Stat/Classic.dyn +8 -0
  36. data/dyndoc/Style/Notation/Stat/Cqls.dyn +44 -0
  37. data/dyndoc/Style/Text/Std.dyn +5 -0
  38. data/dyndoc/Style/Text/StdAlias.dyn +3 -0
  39. data/dyndoc/Style/Text/StdTex.dyn +17 -0
  40. data/dyndoc/Style/Text/Txt.dyn +1 -0
  41. data/dyndoc/Tex/.postload +1 -0
  42. data/dyndoc/Tex/.preload +1 -0
  43. data/dyndoc/Tex/10pt_tmpl.tex +1 -0
  44. data/dyndoc/Tex/11pt_tmpl.tex +1 -0
  45. data/dyndoc/Tex/12pt_tmpl.tex +1 -0
  46. data/dyndoc/Tex/Article_tmpl.tex +1 -0
  47. data/dyndoc/Tex/Beamer.dyn_tex +35 -0
  48. data/dyndoc/Tex/BeamerHandout_tmpl.tex +2 -0
  49. data/dyndoc/Tex/Book_tmpl.tex +1 -0
  50. data/dyndoc/Tex/DefaultFirst_tmpl.tex +1 -0
  51. data/dyndoc/Tex/DefaultLast_tmpl.tex +8 -0
  52. data/dyndoc/Tex/Default_tmpl.tex +9 -0
  53. data/dyndoc/Tex/First_tmpl.tex +8 -0
  54. data/dyndoc/Tex/Fr_tmpl.tex +17 -0
  55. data/dyndoc/Tex/Header_tmpl.tex +3 -0
  56. data/dyndoc/Tex/InclGraph_tmpl.tex +19 -0
  57. data/dyndoc/Tex/InclSpatProc_tmpl.tex +70 -0
  58. data/dyndoc/Tex/InclSumMI_tmpl.tex +4 -0
  59. data/dyndoc/Tex/LargeA4_tmpl.tex +5 -0
  60. data/dyndoc/Tex/Last_tmpl.tex +1 -0
  61. data/dyndoc/Tex/Option_tmpl.tex +8 -0
  62. data/dyndoc/Tex/Png_tmpl.tex +1 -0
  63. data/dyndoc/Tex/RefCite2_tmpl.tex +16 -0
  64. data/dyndoc/Tex/RefCite_tmpl.tex +16 -0
  65. data/dyndoc/Tex/Report_tmpl.tex +1 -0
  66. data/dyndoc/Tex/Theorem_tmpl.tex +14 -0
  67. data/dyndoc/Tools/.DS_Store +0 -0
  68. data/dyndoc/Tools/Atom.dyn/index.dyn +42 -0
  69. data/dyndoc/Tools/AtomDyndocker.dyn/index.dyn +43 -0
  70. data/dyndoc/Tools/R/Fig.dyn +144 -0
  71. data/dyndoc/Tools/R/Tools.dyn +344 -0
  72. data/dyndoc/Tools/Tex/Beamer.dyn +204 -0
  73. data/dyndoc/Tools/Tex/BeamerSlide.dyn_tex +199 -0
  74. data/dyndoc/Tools/Tex/Pgf.dyn +115 -0
  75. data/dyndoc/Tools/Tex/Table.dyn +278 -0
  76. data/dyndoc/Tools/Tex/Tools.dyn +37 -0
  77. data/dyndoc/Tools/Tex/Verb.dyn +77 -0
  78. data/dyndoc/Tools/Web/.DS_Store +0 -0
  79. data/dyndoc/Tools/Web/Ace.dyn +54 -0
  80. data/dyndoc/Tools/Web/Code.dyn +129 -0
  81. data/dyndoc/Tools/Web/DHtmlX.dyn +39 -0
  82. data/dyndoc/Tools/Web/DataTable.dyn_html +354 -0
  83. data/dyndoc/Tools/Web/Html.dyn +286 -0
  84. data/dyndoc/Tools/Web/Html/JQuery.dyn +123 -0
  85. data/dyndoc/Tools/Web/Html/Styles.dyn +4 -0
  86. data/dyndoc/Tools/Web/JQueryTools.dyn +87 -0
  87. data/dyndoc/Tools/Web/Layout.dyn +86 -0
  88. data/dyndoc/Tools/Web/Layout/CQLS.dyn +6 -0
  89. data/dyndoc/Tools/Web/Layout/LJK.dyn +41 -0
  90. data/dyndoc/Tools/Web/TabBar.dyn +37 -0
  91. data/dyndoc/Tools/Web/Ttm.dyn +20 -0
  92. data/dyndoc/Tools/Web/Txtl.dyn +14 -0
  93. data/lib/dyndoc-core.rb +59 -0
  94. data/lib/dyndoc/base/envir.rb +541 -0
  95. data/lib/dyndoc/base/filter/call.rb +127 -0
  96. data/lib/dyndoc/base/filter/filter_mngr.rb +637 -0
  97. data/lib/dyndoc/base/filter/server.rb +882 -0
  98. data/lib/dyndoc/base/filters.rb +3 -0
  99. data/lib/dyndoc/base/helpers.rb +9 -0
  100. data/lib/dyndoc/base/helpers/core.rb +32 -0
  101. data/lib/dyndoc/base/helpers/parser.rb +188 -0
  102. data/lib/dyndoc/base/scanner.rb +886 -0
  103. data/lib/dyndoc/base/tags.rb +4 -0
  104. data/lib/dyndoc/base/tags/keys_mngr.rb +401 -0
  105. data/lib/dyndoc/base/tags/part_tag.rb +194 -0
  106. data/lib/dyndoc/base/tags/tag_mngr.rb +125 -0
  107. data/lib/dyndoc/base/tags/user_tag.rb +216 -0
  108. data/lib/dyndoc/base/tmpl.rb +6 -0
  109. data/lib/dyndoc/base/tmpl/eval.rb +581 -0
  110. data/lib/dyndoc/base/tmpl/extension.rb +337 -0
  111. data/lib/dyndoc/base/tmpl/manager.rb +450 -0
  112. data/lib/dyndoc/base/tmpl/oop.rb +57 -0
  113. data/lib/dyndoc/base/tmpl/parse_do.rb +2446 -0
  114. data/lib/dyndoc/base/tmpl/rbenvir.rb +54 -0
  115. data/lib/dyndoc/base/utils.rb +367 -0
  116. data/lib/dyndoc/common/dynArray.rb +234 -0
  117. data/lib/dyndoc/common/file.rb +52 -0
  118. data/lib/dyndoc/common/init.rb +2 -0
  119. data/lib/dyndoc/common/tilt.rb +149 -0
  120. data/lib/dyndoc/common/utils.rb +61 -0
  121. data/lib/dyndoc/common/uv.rb +163 -0
  122. data/lib/dyndoc/init/config.rb +296 -0
  123. data/lib/dyndoc/init/home.rb +9 -0
  124. data/lib/dyndoc/plugins/tex.rb +4 -0
  125. data/lib/dyndoc/plugins/tex/beamer.rb +208 -0
  126. data/lib/dyndoc/plugins/tex/tex_eval.rb +69 -0
  127. data/lib/dyndoc/plugins/tex/tex_parse_do.rb +25 -0
  128. data/lib/dyndoc/plugins/tex/tex_user_tag.rb +32 -0
  129. data/share/R/dyndocMsys2.R +5 -0
  130. data/share/R/dyndocTools.R +9 -0
  131. data/share/R/test.R +14 -0
  132. data/share/R/tools/dynArray.R +34 -0
  133. data/share/R/tools/dynCapture.R +84 -0
  134. data/share/R/tools/dynMsys2.R +54 -0
  135. data/share/julia/dynArray.jl +93 -0
  136. data/share/julia/dyndoc.jl +110 -0
  137. data/share/julia/ruby.jl +37 -0
  138. metadata +202 -0
@@ -0,0 +1,9 @@
1
+ module Dyndoc
2
+ def Dyndoc.home
3
+ dyndoc_home = File.join(ENV['HOME'],'dyndoc')
4
+ dyndoc_home = File.read(File.join(ENV['HOME'],'.dyndoc_home')).strip if File.exists? File.join(ENV['HOME'],'.dyndoc_home')
5
+ dyndoc_home = File.expand_path(dyndoc_home)
6
+ #puts "dyndoc_home: "+ dyndoc_home
7
+ dyndoc_home
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ require "dyndoc/plugins/tex/tex_eval"
2
+ require "dyndoc/plugins/tex/tex_parse_do"
3
+ #require "dyndoc/plugins/tex/beamer"
4
+ #require "dyndoc/plugins/tex/tex_user_tag"
@@ -0,0 +1,208 @@
1
+ def When(actor,dec)
2
+ from=CqlsBeamer::Actor[actor.to_s]
3
+ from=( from ? from.when : eval(actor.to_s) ).to_i
4
+ dec.gsub(/(\d*)/){|e| (e.to_i+from-1).to_s unless e.empty?}
5
+ end
6
+
7
+ module CqlsBeamer
8
+
9
+ def CqlsBeamer.defCpt
10
+ @@defCpt
11
+ end
12
+
13
+ def CqlsBeamer.defCpt=(val)
14
+ @@defCpt=val
15
+ end
16
+
17
+ def CqlsBeamer.when(quand,scene=CqlsBeamer::Scene.current)
18
+ from,from2=quand.split(":")
19
+ from=nil unless from2
20
+ #puts "quand";p quand
21
+ if from
22
+ from,quand=( (from.empty? and scene) ? scene.cpt[0] : CqlsBeamer::Actor[from].when),from2
23
+ quand=quand.gsub!(/[0-9]+/){|e| e.to_i+from-1}
24
+ end
25
+ quand
26
+ end
27
+
28
+ def CqlsBeamer.where(where,scene=nil)
29
+ #Dyndoc.warn "xy",where
30
+ from,ou=where.split(":")
31
+ ou,from=from,ou unless ou
32
+ if from
33
+ from,scene=from.split("$") unless scene
34
+ from,scene=scene,from unless scene
35
+ end
36
+ ou.gsub!(/\([^\(]*\)/){|elt| eval(elt) }
37
+ if from
38
+ fromKey=from.strip
39
+ actorFrom=CqlsBeamer::Actor[fromKey]
40
+ from=eval("["+actorFrom.where+"]")
41
+ #puts "xy";p ou
42
+ ou ="0.0,0.0" if !ou #and ou.empty?
43
+ if actorFrom.isR
44
+ # R4rb.eval("ou<-xyPercent(c("+ou+"),'#{fromKey}')")
45
+ # ou=[] < :ou
46
+ # Replacement of previous 2 lines failing now!
47
+ ou = "xyPercent(c("+ou+"),'#{fromKey}')"
48
+ ou = ou.to_R
49
+ zoom=actorFrom.isR.dup
50
+ dim=CqlsBeamer::Scene[scene].dim
51
+ ou[0] /= dim[2].to_f
52
+ ou[1] /= dim[3].to_f
53
+ else
54
+ ou=eval("["+ou+"]")
55
+ end
56
+ ou="#{from[0]+ou[0]*zoom[0]},#{from[1]+ou[1]*zoom[1]}"
57
+ end
58
+ #puts "last in xy";p ou
59
+ ou
60
+ end
61
+
62
+ class Scene
63
+ attr_accessor :name, :scene, :dim, :txt, :unit, :fg, :bg, :rounded, :framed, :cpt
64
+ #default values for actors in its scene
65
+ attr_accessor :minipage, :align
66
+
67
+ @@scenes={}
68
+ @@curScene=nil
69
+
70
+ def Scene.[]=(key,val)
71
+ @@scenes[key]=val
72
+ end
73
+
74
+ def Scene.[](key)
75
+ @@scenes[key]
76
+ end
77
+
78
+ def Scene.current
79
+ @@curScene
80
+ end
81
+
82
+ def initialize(name,dim)
83
+ @name=name
84
+ @scene=Group.new
85
+ @unit="cm"
86
+ @dim=dim.map{|e| e.to_s}
87
+ @txt=""
88
+ #default values
89
+ @align="left,top"
90
+ @minipage=""
91
+ Scene[name]=self
92
+ @@curScene=self
93
+ end
94
+
95
+ def init
96
+ @scene.init
97
+ @txt=""
98
+ @cpt[0]=1
99
+ end
100
+
101
+ def append(obj)
102
+ @@curScene=self
103
+ @scene.append(obj)
104
+ end
105
+
106
+ alias << append
107
+
108
+ def first
109
+ txt=""
110
+ txt += "\\setbeamercolor{#{@name}color}{fg=#{fg},bg=#{@bg}}\n\\begin{beamercolorbox}[wd=#{dim[2]+@unit},ht=#{dim[3]+@unit},rounded=#{@rounded}]{#{@name}color}" if @framed
111
+ txt+="\\pgfsetxvec{\\pgfpoint{#{dim[2]+@unit}}{0cm}}\n\\pgfsetyvec{\\pgfpoint{0cm}{#{dim[3]+@unit}}}\n\\begin{pgfpicture}{#{dim[0]+@unit}}{#{dim[1]+@unit}}{#{dim[2]+@unit}}{#{dim[3]+@unit}}\n"
112
+ return txt
113
+ end
114
+
115
+ def last
116
+ txt="\\end{pgfpicture}\n"
117
+ txt += "\\end{beamercolorbox}" if @framed
118
+ return txt
119
+ end
120
+
121
+ def output
122
+ @scene.output(@txt)
123
+ return @txt
124
+ end
125
+
126
+ end
127
+
128
+ class Actor
129
+ attr_accessor :what, :when, :where, :align, :mode, :minipage, :isR, :isRaw
130
+ @@actors={}
131
+
132
+ def Actor.[]=(key,val)
133
+ @@actors[key]=val
134
+ end
135
+
136
+ def Actor.[](key)
137
+ @@actors[key]
138
+ end
139
+
140
+ def initialize(qui,quoi,quand,ou,align="left,top",mode=:only) #align=(left-center-right,bottom-base-center-top)
141
+ quoi=quoi.join("\n") if quoi.is_a? Array
142
+ @what,@when,@where,@align,@mode=quoi,quand,ou,align,mode
143
+ @minipage=""
144
+ Actor[qui]=self
145
+ end
146
+
147
+ def output(txt,local={})
148
+ local[:where]=@where unless local[:where]
149
+ local[:when]=@when unless local[:when]
150
+ local[:align]=@align unless local[:align]
151
+ local[:what]=@what unless local[:what]
152
+ local[:mode]=@mode unless local[:mode]
153
+ local[:minipage]=@minipage unless local[:minipage]
154
+ #Dyndoc.warn :outputInRuby, local[:what]
155
+ local[:what]='\begin{minipage}{'+local[:minipage]+'}'+local[:what]+'\end{minipage}' unless local[:minipage].empty?
156
+ #Dyndoc.warn :outputInRuby2, local[:what]
157
+ if @isRaw or !local[:where]
158
+ txt << "\\#{local[:mode]}<#{local[:when]}>{\n #{local[:what]}}\n"
159
+ else
160
+ txt << "\\#{local[:mode]}<#{local[:when]}>{\n\\pgfputat{\\pgfxy(#{local[:where]})}{\\pgfbox[#{local[:align]}]{#{local[:what]}}}}\n"
161
+ end
162
+ end
163
+
164
+ end
165
+
166
+ class Group
167
+ attr_accessor :list
168
+
169
+ def initialize
170
+ @list=[]
171
+ end
172
+
173
+ def init
174
+ @list=[]
175
+ end
176
+
177
+ def append(actor)
178
+ @list << ( (actor.is_a? Array) ? [Actor[actor[0]],actor[1]] : Actor[actor] )
179
+ end
180
+
181
+ alias << append
182
+
183
+ def insert(actor,i=-1)
184
+ if i<0
185
+ append(actor)
186
+ else
187
+ @list=@list[0...i]+Actor[actor]+@list[i..-1]
188
+ end
189
+ end
190
+
191
+ def move_last(actor)
192
+ elt=@list.delete( (actor.is_a? String) ? Actor[actor] : actor)
193
+ @list << elt if elt
194
+ end
195
+
196
+ def output(txt)
197
+ @list.each{|e|
198
+ if e.is_a? Array
199
+ e[0].output(txt,e[1])
200
+ else
201
+ e.output(txt)
202
+ end
203
+ }
204
+ end
205
+
206
+ end
207
+
208
+ end
@@ -0,0 +1,69 @@
1
+
2
+ BEGINVERB="\\begin{Verbatim}[frame=leftline,fontfamily=tt,fontshape=n,numbers=left]"
3
+ ENDVERB="\\end{Verbatim}"
4
+
5
+ module Dyndoc
6
+
7
+ @@mode=:tex
8
+
9
+ module Ruby
10
+ class TemplateManager
11
+
12
+ def echo_verb(txt,verbatim=true,env="Global")
13
+ txtout=Dyndoc::RServer.echo(txt,env)
14
+ header= verbatim and txtout.length>0
15
+ out=""
16
+ out << BEGINVERB << "\n" if header
17
+ out << txtout
18
+ out << ENDVERB << "\n" if header
19
+ out
20
+ end
21
+
22
+ def make_outR(tex,b,i,splitter,filter,header=true)
23
+ normal= splitter.key[i].nil?
24
+ if !normal
25
+ filename=filter.apply(splitter.key[i]).strip
26
+ normal = ["#","%"].include? filename[0,1]
27
+ end
28
+ if normal
29
+ txt=filter.apply(b[1...-1].map{|l| l.strip}.join("\n"))
30
+ txt=echo_verb(txt,header)
31
+ else
32
+ filename=File.expand_path(filename)
33
+ if (!File.exists?(filename))
34
+ require 'fileutils'
35
+ tmp=File.dirname(filename)
36
+ FileUtils.mkdir_p(tmp) unless File.exists? tmp
37
+ f=File.open(filename,"w")
38
+ txt=filter.apply(b[1...-1].join("\n"))
39
+ txt=echo_verb(txt,header)
40
+ f << txt
41
+ f.close
42
+ else
43
+ txt=File.read(filename)
44
+ end
45
+ end
46
+ tex << "%%" << b[0] << "\n" if @echo>0
47
+ tex << txt unless @echo<0
48
+ tex << "%%" << b[-1] << "\n" if @echo>0
49
+ end
50
+
51
+ def eval_TEX_TITLE(filter)
52
+ ## _BEGINDOC_ already declared in DefaultPre_tmpl.tex
53
+ if filter.envir.global["_BEGINDOC_"] and filter.envir.global["_BEGINDOC_"][:val][0].scan(/\\maketitle/).empty?
54
+ filter.envir.global["_BEGINDOC_"][:val][0] << "\n" unless filter.envir.global["_BEGINDOC_"][:val][0].empty?
55
+ filter.envir.global["_BEGINDOC_"][:val][0] << "\\maketitle"
56
+ end
57
+ end
58
+
59
+ def append_to_begin_document(filter,content)
60
+ ## _BEGINDOC_ already declared in DefaultPre_tmpl.tex
61
+ if filter.envir.global["_BEGINDOC_"]
62
+ filter.envir.global["_BEGINDOC_"][:val][0] << "\n" unless filter.envir.global["_BEGINDOC_"][:val][0].empty?
63
+ filter.envir.global["_BEGINDOC_"][:val][0] << content
64
+ end
65
+ end
66
+
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,25 @@
1
+
2
+ module Dyndoc
3
+ module Ruby
4
+ class TemplateManager
5
+
6
+ @@cmd=["title",""]+@@cmd
7
+
8
+ def do_title(tex,blck,filter)
9
+ =begin
10
+ mode=""
11
+ mode=filter.apply(splitter.key[i].strip).downcase if splitter.key[i]
12
+ ## apply R filtering
13
+ txt=filter.apply(b[1...-1].join("\n"))
14
+ ## _TITLE_ is redefined!
15
+ eval_TITLE(txt,filter,mode)
16
+ =end
17
+ end
18
+
19
+ def do_list(tex,blck,filter)
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+
2
+ module Dyndoc
3
+
4
+ class UserTag
5
+
6
+ @@tags_tex=["rtex","rverb","title","preamble","usepackage","postamble","begindoc","enddoc"]
7
+ ## update @@tags
8
+ @@tags += @@tags_tex
9
+ @@tex_vars={"usepackage"=>"_USEPACKAGE_","preamble"=>"_PREAMBLE_","postamble"=>"_POSTAMBLE_","begindoc"=>"_BEGINDOC_","enddoc"=>"_ENDDOC_"}
10
+
11
+
12
+ def parseUserTexTags(tex,code,filter)
13
+ case @type
14
+ when "rverb","rtex"
15
+ @out_type="#r"
16
+ header= @type=="rverb"
17
+ tex << @tmpl.echo_verb(filter.apply(code.strip),header).lstrip
18
+ when "title"
19
+ mode= (@modifier=="!" ? "" : "+")
20
+ @tmpl.eval_TITLE(filter.apply(code.strip),filter,mode)
21
+ when "preamble","usepackage","postamble","begindoc","enddoc"
22
+ mode= "+"
23
+ if @modifier=="!"
24
+ mode = ""
25
+ end
26
+ @tmpl.eval_TEXVAR(@@tex_vars[@type],filter.apply(code.strip),filter,mode)
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,5 @@
1
+ .dyndocMsys2 <- new.env()
2
+
3
+ source("tools/dynMsys2.R",local=.dyndocMsys2)
4
+
5
+ attach(.dyndocMsys2,name="dyndoc:msys2",pos=length(search())-1)
@@ -0,0 +1,9 @@
1
+ require(rb4R)
2
+
3
+
4
+ .dyndocEnvir <- new.env()
5
+
6
+ source("tools/dynArray.R",local=.dyndocEnvir)
7
+ source("tools/dynCapture.R",local=.dyndocEnvir)
8
+
9
+ attach(.dyndocEnvir,name="dyndoc:tools")
data/share/R/test.R ADDED
@@ -0,0 +1,14 @@
1
+ toto <-list(vars=list())
2
+ class(toto)<-'TOTO'
3
+ "[[<-.TOTO" <- function(obj,key,value) {
4
+ obj$vars[[key]] <- value
5
+ cat("inside []<-\n")
6
+ obj
7
+ }
8
+
9
+ "[[.TOTO" <- function(obj,key) {
10
+ cat("inside []\n")
11
+ obj$vars[[key]]
12
+ }
13
+
14
+ toto[["titi"]] <- "TUTU"
@@ -0,0 +1,34 @@
1
+ # stuff specific to dyndoc
2
+ ## Not supposed to be used by the user
3
+
4
+ require(rb4R)
5
+
6
+ init.dynArray <- function() {
7
+ local({
8
+ # envir and not list to immediate sync in "[[<-.dynArray"
9
+ Dyndoc.Vec<-list(vars=new.env())
10
+ class(Dyndoc.Vec)<-"dynArray"
11
+ },globalenv())
12
+ }
13
+
14
+ #<- "[.dynArray" <- "$.dynArray"
15
+ "[.dynArray" <- function(obj,key) {
16
+ if(inherits(key,"formula")) key<-as.character(key)[[2]]
17
+ .rb(paste("Dyndoc::Vector[\"",key,"\"].sync(:r)",sep=""))
18
+ obj$vars[[key]]
19
+ }
20
+
21
+ # <- "[<-.dynArray" <- "$<-.dynArray"
22
+ "[<-.dynArray" <-function(obj,key,value) {
23
+ if(inherits(key,"formula")) key<-as.character(key)[[2]]
24
+ obj$vars[[key]] <- value
25
+ #if(sync) { # Easily convertible to Julia!
26
+ # Clever: no need to convert ruby object in R object (done in the ruby part!)
27
+ ##cat("sync",key,"\n")
28
+ .rb(paste("Dyndoc::Vector[\"",key,"\"].sync(:r)",sep=""))
29
+ #cat("sync",key,"\n")
30
+ #}
31
+ obj
32
+ }
33
+
34
+ init.dynArray()
@@ -0,0 +1,84 @@
1
+
2
+ capture.output.cqls<-function(code) {
3
+ res2<-try.cqls(res<-capture.output(code),TRUE)
4
+ if(inherits(res2,"try-error")) {
5
+ res2
6
+ } else res
7
+ }
8
+
9
+ capture.output.protected<-function(code) {
10
+ res2<-try(res<-capture.output(code),TRUE)
11
+ if(inherits(res2,"try-error")) {
12
+ res2
13
+ } else res
14
+ }
15
+
16
+ try.cqls<-function (expr, silent = FALSE)
17
+ {
18
+ tryCatch(expr, error = function(e) {
19
+ call <- conditionCall(e)
20
+ if (!is.null(call)) {
21
+ if (identical(call[[1]], quote(doTryCatch)))
22
+ call <- sys.call(-4)
23
+ dcall <- deparse(call)[1]
24
+ if( (substr(dcall,1,7)=="try.cqls(") || dcall=="eval.with.vis(expr, pf, baseenv())" || dcall=="eval(expr, envir, enclos)" ) prefix <-
25
+ "Erreur : "
26
+ else prefix <- paste("Erreur dans", dcall, ": ")
27
+ LONG <- 75
28
+ msg <- conditionMessage(e)
29
+ sm <- strsplit(msg, "\n")[[1]]
30
+ if (14 + nchar(dcall, type = "w") + nchar(sm[1],
31
+ type = "w") > LONG)
32
+ prefix <- paste(prefix, "\n ", sep = "")
33
+ }
34
+ else prefix <- "Erreur : "
35
+ msg <- paste(prefix, conditionMessage(e), "\n", sep = "")
36
+ .Internal(seterrmessage(msg[1]))
37
+ if (!silent && identical(getOption("show.error.messages"),
38
+ TRUE)) {
39
+ cat(msg, file = stderr())
40
+ .Internal(printDeferredWarnings())
41
+ }
42
+ invisible(structure(msg, class = "try-error"))
43
+ })
44
+ }
45
+
46
+ init.filter.capture<-function(in.filter,out.filter) {
47
+ if(!missing(in.filter)) .filter.capture[[1]]<<-in.filter
48
+ if(!missing(out.filter)) .filter.capture[[2]]<<-out.filter
49
+ #print(.filter.capture)
50
+ return(invisible())
51
+ }
52
+
53
+ filter.capture.output<-function (...,filter=.filter.capture) {
54
+ args <- substitute(list(...))[-1]
55
+ file <- textConnection("res.val","w",local=TRUE)
56
+ sink(file)
57
+ pf <- parent.frame()
58
+ evalVis <- function(expr) .Internal(eval.with.vis(expr, pf, baseenv()))
59
+ expr <- args[[1]]
60
+ if (mode(expr) == "expression")
61
+ tmp <- lapply(expr, evalVis)
62
+ else if (mode(expr) == "call")
63
+ tmp <- list(evalVis(expr))
64
+ else if (mode(expr) == "name")
65
+ tmp <- list(evalVis(expr))
66
+ else stop("bad argument")
67
+ for (item in tmp) {if(item$visible) res<-item$value}
68
+ print(res)
69
+ sink()
70
+ close(file)
71
+ if(!is.null(filter[[1]])) {
72
+ res.in<-if(is.function(filter[[1]])) sapply(res,filter[[1]]) else filter[[1]]
73
+ tmp<-strsplit(paste(res.val,collapse=" [LiNe]")," ")[[1]]
74
+ tmp2<-(regexpr('^\\[.*\\]$',tmp)!=1 & tmp!="" )
75
+ new<-tmp[tmp2]
76
+ new[res.in]<-sapply(new[res.in],filter[[2]])
77
+ tmp[tmp2]<-new
78
+ return(paste(strsplit(paste(tmp,collapse=" "), " \\[LiNe\\]" )[[1]],collapse="\n"))
79
+ } else return(res.val)
80
+ }
81
+
82
+ local({
83
+ if(!exists(".filter.capture")) .filter.capture <-list(NULL,function(x) paste("\\textcolor{blue}{",x,"}",sep=""))
84
+ },.GlobalEnv)