sassc 0.0.10 → 0.0.11

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 (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/libsass/.gitignore +6 -0
  4. data/ext/libsass/.travis.yml +5 -1
  5. data/ext/libsass/Makefile +12 -3
  6. data/ext/libsass/Makefile.am +16 -28
  7. data/ext/libsass/Readme.md +1 -0
  8. data/ext/libsass/appveyor.yml +1 -2
  9. data/ext/libsass/ast.cpp +9 -0
  10. data/ext/libsass/ast.hpp +152 -55
  11. data/ext/libsass/ast_factory.hpp +2 -0
  12. data/ext/libsass/ast_fwd_decl.hpp +1 -0
  13. data/ext/libsass/backtrace.hpp +2 -2
  14. data/ext/libsass/bind.cpp +15 -13
  15. data/ext/libsass/configure.ac +17 -5
  16. data/ext/libsass/constants.cpp +22 -2
  17. data/ext/libsass/constants.hpp +21 -2
  18. data/ext/libsass/context.cpp +79 -57
  19. data/ext/libsass/context.hpp +23 -9
  20. data/ext/libsass/contextualize.cpp +2 -28
  21. data/ext/libsass/contextualize.hpp +6 -10
  22. data/ext/libsass/contextualize_eval.cpp +93 -0
  23. data/ext/libsass/contextualize_eval.hpp +44 -0
  24. data/ext/libsass/contrib/plugin.cpp +57 -0
  25. data/ext/libsass/cssize.cpp +3 -1
  26. data/ext/libsass/debugger.hpp +242 -83
  27. data/ext/libsass/emitter.cpp +1 -1
  28. data/ext/libsass/emitter.hpp +1 -1
  29. data/ext/libsass/environment.hpp +109 -25
  30. data/ext/libsass/error_handling.cpp +3 -3
  31. data/ext/libsass/error_handling.hpp +0 -1
  32. data/ext/libsass/eval.cpp +145 -61
  33. data/ext/libsass/eval.hpp +9 -1
  34. data/ext/libsass/expand.cpp +134 -60
  35. data/ext/libsass/expand.hpp +5 -2
  36. data/ext/libsass/extend.cpp +7 -5
  37. data/ext/libsass/file.cpp +176 -123
  38. data/ext/libsass/file.hpp +44 -7
  39. data/ext/libsass/functions.cpp +36 -17
  40. data/ext/libsass/functions.hpp +2 -2
  41. data/ext/libsass/inspect.cpp +23 -14
  42. data/ext/libsass/inspect.hpp +1 -0
  43. data/ext/libsass/json.cpp +132 -135
  44. data/ext/libsass/lexer.cpp +133 -0
  45. data/ext/libsass/lexer.hpp +239 -0
  46. data/ext/libsass/listize.cpp +83 -0
  47. data/ext/libsass/listize.hpp +41 -0
  48. data/ext/libsass/operation.hpp +2 -0
  49. data/ext/libsass/output.cpp +5 -6
  50. data/ext/libsass/parser.cpp +426 -388
  51. data/ext/libsass/parser.hpp +97 -109
  52. data/ext/libsass/plugins.cpp +15 -2
  53. data/ext/libsass/plugins.hpp +6 -4
  54. data/ext/libsass/position.cpp +52 -17
  55. data/ext/libsass/position.hpp +19 -17
  56. data/ext/libsass/prelexer.cpp +202 -235
  57. data/ext/libsass/prelexer.hpp +73 -333
  58. data/ext/libsass/sass.cpp +21 -11
  59. data/ext/libsass/sass.h +6 -6
  60. data/ext/libsass/sass_context.cpp +167 -81
  61. data/ext/libsass/sass_context.h +26 -6
  62. data/ext/libsass/sass_functions.cpp +49 -40
  63. data/ext/libsass/sass_functions.h +55 -43
  64. data/ext/libsass/sass_interface.cpp +9 -8
  65. data/ext/libsass/sass_interface.h +3 -3
  66. data/ext/libsass/sass_version.h +8 -0
  67. data/ext/libsass/sass_version.h.in +8 -0
  68. data/ext/libsass/script/ci-build-libsass +3 -3
  69. data/ext/libsass/script/ci-report-coverage +2 -1
  70. data/ext/libsass/source_map.cpp +2 -2
  71. data/ext/libsass/util.cpp +60 -11
  72. data/ext/libsass/util.hpp +6 -1
  73. data/ext/libsass/win/libsass.filters +12 -0
  74. data/ext/libsass/win/libsass.vcxproj +10 -0
  75. data/lib/sassc.rb +3 -1
  76. data/lib/sassc/cache_stores/base.rb +2 -0
  77. data/lib/sassc/dependency.rb +3 -1
  78. data/lib/sassc/engine.rb +31 -16
  79. data/lib/sassc/error.rb +3 -2
  80. data/lib/sassc/functions_handler.rb +54 -0
  81. data/lib/sassc/import_handler.rb +41 -0
  82. data/lib/sassc/importer.rb +4 -31
  83. data/lib/sassc/native.rb +1 -1
  84. data/lib/sassc/native/native_context_api.rb +3 -2
  85. data/lib/sassc/script.rb +0 -51
  86. data/lib/sassc/version.rb +1 -1
  87. data/sassc.gemspec +1 -0
  88. data/test/custom_importer_test.rb +72 -69
  89. data/test/engine_test.rb +53 -54
  90. data/test/functions_test.rb +40 -39
  91. data/test/native_test.rb +145 -149
  92. data/test/output_style_test.rb +98 -0
  93. data/test/test_helper.rb +21 -7
  94. metadata +28 -2
@@ -0,0 +1,8 @@
1
+ #ifndef SASS_VERSION_H
2
+ #define SASS_VERSION_H
3
+
4
+ #ifndef LIBSASS_VERSION
5
+ #define LIBSASS_VERSION "[NA]"
6
+ #endif
7
+
8
+ #endif
@@ -0,0 +1,8 @@
1
+ #ifndef SASS_VERSION_H
2
+ #define SASS_VERSION_H
3
+
4
+ #ifndef LIBSASS_VERSION
5
+ #define LIBSASS_VERSION "@PACKAGE_VERSION@"
6
+ #endif
7
+
8
+ #endif
@@ -14,9 +14,9 @@ if [ "x$SASS_SPEC_PATH" == "x" ]; then export SASS_SPEC_PATH=$(pwd)/sass-spec; f
14
14
 
15
15
  if [ "x$COVERAGE" == "xyes" ]; then
16
16
  COVERAGE_OPT="--enable-coverage"
17
- export EXTRA_CFLAGS="-O0 --coverage"
18
- export EXTRA_CXXFLAGS="-O0 --coverage"
19
- export EXTRA_LDFLAGS="-O0 --coverage"
17
+ export EXTRA_CFLAGS="--coverage"
18
+ export EXTRA_CXXFLAGS="--coverage"
19
+ export EXTRA_LDFLAGS="--coverage"
20
20
  else
21
21
  COVERAGE_OPT="--disable-coverage"
22
22
  fi
@@ -10,7 +10,8 @@ if [ "x$COVERAGE" = "xyes" ]; then
10
10
  --exclude utf8 --exclude utf8_string.hpp
11
11
  --exclude utf8.h --exclude utf8_string.cpp
12
12
  --exclude sass2scss.h --exclude sass2scss.cpp
13
- --exclude test --exclude posix"
13
+ --exclude test --exclude posix
14
+ --exclude debugger.hpp"
14
15
  # debug via gcovr
15
16
  gcov -v
16
17
  gcovr -r .
@@ -175,9 +175,9 @@ namespace Sass {
175
175
  mappings[i].generated_position.file == pstate.file &&
176
176
  mappings[i].generated_position.line == pstate.line &&
177
177
  mappings[i].generated_position.column == pstate.column
178
- ) return ParserState(pstate.path, mappings[i].original_position, pstate.offset);
178
+ ) return ParserState(pstate.path, pstate.src, mappings[i].original_position, pstate.offset);
179
179
  }
180
- return ParserState(pstate.path, Position(-1, -1, -1), Offset(0, 0));
180
+ return ParserState(pstate.path, pstate.src, Position(-1, -1, -1), Offset(0, 0));
181
181
 
182
182
  }
183
183
 
@@ -27,7 +27,7 @@ namespace Sass {
27
27
  char separator = *(localeconv()->decimal_point);
28
28
  if(separator != '.'){
29
29
  // The current locale specifies another
30
- // separator. convert the separator to the
30
+ // separator. convert the separator to the
31
31
  // one understood by the locale if needed
32
32
  const char *found = strchr(str, '.');
33
33
  if(found != NULL){
@@ -79,6 +79,29 @@ namespace Sass {
79
79
  return out;
80
80
  }
81
81
 
82
+ // read css string (handle multiline DELIM)
83
+ string read_css_string(const string& str)
84
+ {
85
+ string out("");
86
+ bool esc = false;
87
+ for (auto i : str) {
88
+ if (i == '\\') {
89
+ esc = ! esc;
90
+ } else if (esc && i == '\r') {
91
+ continue;
92
+ } else if (esc && i == '\n') {
93
+ out.resize (out.size () - 1);
94
+ esc = false;
95
+ continue;
96
+ } else {
97
+ esc = false;
98
+ }
99
+ out.push_back(i);
100
+ }
101
+ if (esc) out += '\\';
102
+ return out;
103
+ }
104
+
82
105
  // evacuate unescaped quoted
83
106
  // leave everything else untouched
84
107
  string evacuate_quotes(const string& str)
@@ -308,7 +331,7 @@ namespace Sass {
308
331
  // don't be that strict
309
332
  return s;
310
333
  // this basically always means an internal error and not users fault
311
- error("Unescaped delimiter in string to unquote found. [" + s + "]", ParserState("[UNQUOTE]", -1));
334
+ error("Unescaped delimiter in string to unquote found. [" + s + "]", ParserState("[UNQUOTE]"));
312
335
  }
313
336
  else {
314
337
  skipped = false;
@@ -325,12 +348,12 @@ namespace Sass {
325
348
  string quote(const string& s, char q)
326
349
  {
327
350
 
328
- // return an empty quoted string
329
- if (s.empty()) return string(2, q ? q : '"');
330
-
331
351
  // autodetect with fallback to given quote
332
352
  q = detect_best_quotemark(s.c_str(), q);
333
353
 
354
+ // return an empty quoted string
355
+ if (s.empty()) return string(2, q ? q : '"');
356
+
334
357
  string quoted;
335
358
  quoted.reserve(s.length()+2);
336
359
  quoted.push_back(q);
@@ -380,10 +403,12 @@ namespace Sass {
380
403
 
381
404
  bool peek_linefeed(const char* start)
382
405
  {
383
- if(*start == '\n' || *start == '\r') return true;;
384
- const char* linefeed = Prelexer::wspaces(start);
385
- if (linefeed == 0) return false;
386
- return *linefeed == '\n' || *linefeed == '\r';
406
+ while (*start) {
407
+ if (*start == '\n' || *start == '\r') return true;
408
+ if (*start != ' ' && *start != '\t') return false;
409
+ ++ start;
410
+ }
411
+ return false;
387
412
  }
388
413
 
389
414
  namespace Util {
@@ -450,6 +475,8 @@ namespace Sass {
450
475
  } else {
451
476
  hasDeclarations = true;
452
477
  }
478
+ } else if (Declaration* d = dynamic_cast<Declaration*>(stm)) {
479
+ return isPrintable(d, style);
453
480
  } else {
454
481
  hasDeclarations = true;
455
482
  }
@@ -462,6 +489,28 @@ namespace Sass {
462
489
  return false;
463
490
  }
464
491
 
492
+ bool isPrintable(String_Constant* s, Output_Style style)
493
+ {
494
+ return ! s->value().empty();
495
+ }
496
+
497
+ bool isPrintable(String_Quoted* s, Output_Style style)
498
+ {
499
+ return true;
500
+ }
501
+
502
+ bool isPrintable(Declaration* d, Output_Style style)
503
+ {
504
+ Expression* val = d->value();
505
+ if (String_Quoted* sq = dynamic_cast<String_Quoted*>(val)) return isPrintable(sq, style);
506
+ if (String_Constant* sc = dynamic_cast<String_Constant*>(val)) return isPrintable(sc, style);
507
+ return true;
508
+ }
509
+
510
+ bool isPrintable(Expression* e, Output_Style style) {
511
+ return isPrintable(e, style);
512
+ }
513
+
465
514
  bool isPrintable(Feature_Block* f, Output_Style style) {
466
515
  if (f == NULL) {
467
516
  return false;
@@ -593,8 +642,8 @@ namespace Sass {
593
642
  }
594
643
  }
595
644
 
596
- bool isAscii(int ch) {
597
- return ch >= 0 && ch < 128;
645
+ bool isAscii(const char chr) {
646
+ return unsigned(chr) < 128;
598
647
  }
599
648
 
600
649
  }
@@ -12,6 +12,7 @@ namespace Sass {
12
12
  double sass_atof(const char* str);
13
13
  string string_escape(const string& str);
14
14
  string string_unescape(const string& str);
15
+ string read_css_string(const string& str);
15
16
  string evacuate_quotes(const string& str);
16
17
  string evacuate_escapes(const string& str);
17
18
  string string_to_output(const string& str);
@@ -40,7 +41,11 @@ namespace Sass {
40
41
  bool isPrintable(Feature_Block* r, Output_Style style = NESTED);
41
42
  bool isPrintable(Media_Block* r, Output_Style style = NESTED);
42
43
  bool isPrintable(Block* b, Output_Style style = NESTED);
43
- bool isAscii(int ch);
44
+ bool isPrintable(String_Constant* s, Output_Style style = NESTED);
45
+ bool isPrintable(String_Quoted* s, Output_Style style = NESTED);
46
+ bool isPrintable(Declaration* d, Output_Style style = NESTED);
47
+ bool isPrintable(Expression* e, Output_Style style = NESTED);
48
+ bool isAscii(const char chr);
44
49
 
45
50
  }
46
51
  }
@@ -51,6 +51,9 @@
51
51
  <ClCompile Include="..\cssize.cpp">
52
52
  <Filter>Source Files</Filter>
53
53
  </ClCompile>
54
+ <ClCompile Include="..\listize.cpp">
55
+ <Filter>Source Files</Filter>
56
+ </ClCompile>
54
57
  <ClCompile Include="..\extend.cpp">
55
58
  <Filter>Source Files</Filter>
56
59
  </ClCompile>
@@ -81,6 +84,9 @@
81
84
  <ClCompile Include="..\position.cpp">
82
85
  <Filter>Source Files</Filter>
83
86
  </ClCompile>
87
+ <ClCompile Include="..\lexer.cpp">
88
+ <Filter>Source Files</Filter>
89
+ </ClCompile>
84
90
  <ClCompile Include="..\prelexer.cpp">
85
91
  <Filter>Source Files</Filter>
86
92
  </ClCompile>
@@ -194,6 +200,9 @@
194
200
  <ClInclude Include="..\cssize.hpp">
195
201
  <Filter>Header Files</Filter>
196
202
  </ClInclude>
203
+ <ClInclude Include="..\listize.hpp">
204
+ <Filter>Header Files</Filter>
205
+ </ClInclude>
197
206
  <ClInclude Include="..\extend.hpp">
198
207
  <Filter>Header Files</Filter>
199
208
  </ClInclude>
@@ -239,6 +248,9 @@
239
248
  <ClInclude Include="..\position.hpp">
240
249
  <Filter>Header Files</Filter>
241
250
  </ClInclude>
251
+ <ClInclude Include="..\lexer.hpp">
252
+ <Filter>Header Files</Filter>
253
+ </ClInclude>
242
254
  <ClInclude Include="..\prelexer.hpp">
243
255
  <Filter>Header Files</Filter>
244
256
  </ClInclude>
@@ -102,6 +102,7 @@
102
102
  <WarningLevel>Level3</WarningLevel>
103
103
  <Optimization>Disabled</Optimization>
104
104
  <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
105
+ <ExceptionHandling>SyncCThrow</ExceptionHandling>
105
106
  </ClCompile>
106
107
  <Link>
107
108
  <SubSystem>Console</SubSystem>
@@ -115,6 +116,7 @@
115
116
  <WarningLevel>Level3</WarningLevel>
116
117
  <Optimization>Disabled</Optimization>
117
118
  <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119
+ <ExceptionHandling>SyncCThrow</ExceptionHandling>
118
120
  </ClCompile>
119
121
  <Link>
120
122
  <SubSystem>Console</SubSystem>
@@ -130,6 +132,7 @@
130
132
  <FunctionLevelLinking>true</FunctionLevelLinking>
131
133
  <IntrinsicFunctions>true</IntrinsicFunctions>
132
134
  <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
135
+ <ExceptionHandling>SyncCThrow</ExceptionHandling>
133
136
  </ClCompile>
134
137
  <Link>
135
138
  <SubSystem>Console</SubSystem>
@@ -147,6 +150,7 @@
147
150
  <FunctionLevelLinking>true</FunctionLevelLinking>
148
151
  <IntrinsicFunctions>true</IntrinsicFunctions>
149
152
  <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
153
+ <ExceptionHandling>SyncCThrow</ExceptionHandling>
150
154
  </ClCompile>
151
155
  <Link>
152
156
  <SubSystem>Console</SubSystem>
@@ -164,10 +168,12 @@
164
168
  <ClCompile Include="..\constants.cpp" />
165
169
  <ClCompile Include="..\context.cpp" />
166
170
  <ClCompile Include="..\contextualize.cpp" />
171
+ <ClCompile Include="..\contextualize_eval.cpp" />
167
172
  <ClCompile Include="..\error_handling.cpp" />
168
173
  <ClCompile Include="..\eval.cpp" />
169
174
  <ClCompile Include="..\expand.cpp" />
170
175
  <ClCompile Include="..\cssize.cpp" />
176
+ <ClCompile Include="..\listize.cpp" />
171
177
  <ClCompile Include="..\extend.cpp" />
172
178
  <ClCompile Include="..\file.cpp" />
173
179
  <ClCompile Include="..\functions.cpp" />
@@ -179,6 +185,7 @@
179
185
  <ClCompile Include="..\parser.cpp" />
180
186
  <ClCompile Include="..\plugins.cpp" />
181
187
  <ClCompile Include="..\position.cpp" />
188
+ <ClCompile Include="..\lexer.cpp" />
182
189
  <ClCompile Include="..\prelexer.cpp" />
183
190
  <ClCompile Include="..\remove_placeholders.cpp" />
184
191
  <ClCompile Include="..\sass.cpp" />
@@ -208,12 +215,14 @@
208
215
  <ClInclude Include="..\constants.hpp" />
209
216
  <ClInclude Include="..\context.hpp" />
210
217
  <ClInclude Include="..\contextualize.hpp" />
218
+ <ClInclude Include="..\contextualize_eval.hpp" />
211
219
  <ClInclude Include="..\debug.hpp" />
212
220
  <ClInclude Include="..\environment.hpp" />
213
221
  <ClInclude Include="..\error_handling.hpp" />
214
222
  <ClInclude Include="..\eval.hpp" />
215
223
  <ClInclude Include="..\expand.hpp" />
216
224
  <ClInclude Include="..\cssize.hpp" />
225
+ <ClInclude Include="..\listize.hpp" />
217
226
  <ClInclude Include="..\extend.hpp" />
218
227
  <ClInclude Include="..\file.hpp" />
219
228
  <ClInclude Include="..\functions.hpp" />
@@ -230,6 +239,7 @@
230
239
  <ClInclude Include="..\plugins.hpp" />
231
240
  <ClInclude Include="..\paths.hpp" />
232
241
  <ClInclude Include="..\position.hpp" />
242
+ <ClInclude Include="..\lexer.hpp" />
233
243
  <ClInclude Include="..\prelexer.hpp" />
234
244
  <ClInclude Include="..\remove_placeholders.hpp" />
235
245
  <ClInclude Include="..\sass.h" />
@@ -3,9 +3,11 @@ end
3
3
 
4
4
  require_relative "sassc/version"
5
5
  require_relative "sassc/native"
6
- require_relative "sassc/engine"
6
+ require_relative "sassc/import_handler"
7
7
  require_relative "sassc/importer"
8
8
  require_relative "sassc/script"
9
+ require_relative "sassc/functions_handler"
9
10
  require_relative "sassc/cache_stores"
10
11
  require_relative "sassc/dependency"
11
12
  require_relative "sassc/error"
13
+ require_relative "sassc/engine"
@@ -1,6 +1,8 @@
1
1
  module SassC
2
2
  module CacheStores
3
3
  class Base
4
+ # we don't actually cache anything yet,
5
+ # this is just for API compatibility
4
6
  end
5
7
  end
6
8
  end
@@ -1,9 +1,11 @@
1
1
  module SassC
2
2
  class Dependency
3
+ attr_reader :filename
3
4
  attr_reader :options
4
5
 
5
6
  def initialize(filename)
6
- @options = { filename: filename }
7
+ @filename = filename
8
+ @options = { filename: @filename }
7
9
  end
8
10
 
9
11
  def self.from_filenames(filenames)
@@ -1,6 +1,13 @@
1
+ require_relative "error"
2
+
1
3
  module SassC
2
4
  class Engine
3
- class NotRenderedError < StandardError; end
5
+ OUTPUT_STYLES = %i[
6
+ sass_style_nested
7
+ sass_style_expanded
8
+ sass_style_compact
9
+ sass_style_compressed
10
+ ]
4
11
 
5
12
  def initialize(template, options = {})
6
13
  @template = template
@@ -15,20 +22,20 @@ module SassC
15
22
  Native.option_set_is_indented_syntax_src(native_options, true) if sass?
16
23
  Native.option_set_input_path(native_options, filename) if filename
17
24
  Native.option_set_include_path(native_options, load_paths)
25
+ Native.option_set_output_style(native_options, output_style_enum)
18
26
 
19
- importer.setup(native_options) if importer
20
-
21
- status = Script.setup_custom_functions(native_options, @options) do
22
- Native.compile_data_context(data_context)
23
- end
27
+ import_handler.setup(native_options)
28
+ functions_handler.setup(native_options)
24
29
 
25
- css = Native.context_get_output_string(context)
30
+ status = Native.compile_data_context(data_context)
26
31
 
27
32
  if status != 0
28
- message = SassC::Native.context_get_error_message(context)
33
+ message = Native.context_get_error_message(context)
29
34
  raise SyntaxError.new(message)
30
35
  end
31
36
 
37
+ css = Native.context_get_output_string(context)
38
+
32
39
  @dependencies = Native.context_get_included_files(context)
33
40
 
34
41
  Native.delete_data_context(data_context)
@@ -55,14 +62,22 @@ module SassC
55
62
  @options[:syntax] && @options[:syntax].to_sym == :sass
56
63
  end
57
64
 
58
- def importer
59
- @importer ||= begin
60
- if @options[:importer]
61
- @options[:importer].new(@options)
62
- else
63
- nil
64
- end
65
- end
65
+ def import_handler
66
+ @import_handler ||= ImportHandler.new(@options)
67
+ end
68
+
69
+ def functions_handler
70
+ @functions_handler = FunctionsHandler.new(@options)
71
+ end
72
+
73
+ def output_style_enum
74
+ @output_style_enum ||= Native::SassOutputStyle[output_style]
75
+ end
76
+
77
+ def output_style
78
+ style = @options.fetch(:style, :sass_style_nested).to_sym
79
+ raise InvalidStyleError unless Native::SassOutputStyle.symbols.include?(style)
80
+ style
66
81
  end
67
82
 
68
83
  def load_paths
@@ -1,4 +1,5 @@
1
1
  module SassC
2
- class SyntaxError < StandardError
3
- end
2
+ class SyntaxError < StandardError; end
3
+ class NotRenderedError < StandardError; end
4
+ class InvalidStyleError < StandardError; end
4
5
  end
@@ -0,0 +1,54 @@
1
+ module SassC
2
+ class FunctionsHandler
3
+ def initialize(options)
4
+ @options = options
5
+ end
6
+
7
+ def setup(native_options)
8
+ callbacks = {}
9
+
10
+ list = Native.make_function_list(Script.custom_functions.count)
11
+
12
+ functs = FunctionWrapper.extend(Script::Functions)
13
+ functs.options = @options
14
+
15
+ Script.custom_functions.each_with_index do |custom_function, i|
16
+ callbacks[custom_function] = FFI::Function.new(:pointer, [:pointer, :pointer]) do |s_args, cookie|
17
+ length = Native.list_get_length(s_args)
18
+
19
+ v = Native.list_get_value(s_args, 0)
20
+ v = Native.string_get_value(v).dup
21
+
22
+ s = Script::String.new(Script::String.unquote(v), Script::String.type(v))
23
+
24
+ value = functs.send(custom_function, s)
25
+
26
+ if value
27
+ value = Script::String.new(Script::String.unquote(value.to_s), value.type)
28
+ value.to_native
29
+ else
30
+ Script::String.new("").to_native
31
+ end
32
+ end
33
+
34
+ callback = Native.make_function(
35
+ Script.formatted_function_name(custom_function),
36
+ callbacks[custom_function],
37
+ nil
38
+ )
39
+
40
+ Native::function_set_list_entry(list, i, callback)
41
+ end
42
+
43
+ Native::option_set_c_functions(native_options, list)
44
+ end
45
+
46
+ private
47
+
48
+ class FunctionWrapper
49
+ class << self
50
+ attr_accessor :options
51
+ end
52
+ end
53
+ end
54
+ end