ox 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of ox might be problematic. Click here for more details.

@@ -14,7 +14,8 @@
14
14
  #include "sax.h"
15
15
 
16
16
  /* maximum to allocate on the stack, arbitrary limit */
17
- #define SMALL_XML 4096
17
+ #define SMALL_XML 4096
18
+ #define WITH_CACHE_TESTS 0
18
19
 
19
20
  typedef struct _YesNoOpt {
20
21
  VALUE sym;
@@ -74,6 +75,10 @@ ID ox_tv_usec_id;
74
75
  ID ox_value_id;
75
76
 
76
77
  VALUE ox_encoding_sym;
78
+ VALUE ox_version_sym;
79
+ VALUE ox_standalone_sym;
80
+ VALUE ox_indent_sym;
81
+ VALUE ox_size_sym;
77
82
 
78
83
  VALUE ox_empty_string;
79
84
  VALUE ox_zero_fixnum;
@@ -105,7 +110,6 @@ static VALUE circular_sym;
105
110
  static VALUE convert_special_sym;
106
111
  static VALUE effort_sym;
107
112
  static VALUE generic_sym;
108
- static VALUE indent_sym;
109
113
  static VALUE invalid_replace_sym;
110
114
  static VALUE limited_sym;
111
115
  static VALUE mode_sym;
@@ -223,23 +227,23 @@ defuse_bom(char *xml, Options options) {
223
227
  /* call-seq: ox_default_options() => Hash
224
228
  *
225
229
  * Returns the default load and dump options as a Hash. The options are
226
- * - indent: [Fixnum] number of spaces to indent each element in an XML document
227
- * - trace: [Fixnum] trace level where 0 is silent
228
- * - encoding: [String] character encoding for the XML file
229
- * - with_dtd: [true|false|nil] include DTD in the dump
230
- * - with_instruct: [true|false|nil] include instructions in the dump
231
- * - with_xml: [true|false|nil] include XML prolog in the dump
232
- * - circular: [true|false|nil] support circular references while dumping
233
- * - xsd_date: [true|false|nil] use XSD date format instead of decimal format
234
- * - mode: [:object|:generic|:limited|nil] load method to use for XML
235
- * - effort: [:strict|:tolerant|:auto_define] set the tolerance level for loading
236
- * - symbolize_keys: [true|false|nil] symbolize element attribute keys or leave as Strings
237
- * - skip: [:skip_none|:skip_return|:skip_white] determines how to handle white space in text
238
- * - smart: [true|false|nil] flag indicating the SAX parser uses hints if available (use with html)
239
- * - convert_special: [true|false|nil] flag indicating special characters like < are converted with the SAX parser
240
- * - invalid_replace: [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
241
- * - strip_namespace: [String|true|false] false or "" results in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
242
- * @return [Hash] all current option settings.
230
+ * - _:indent_ [Fixnum] number of spaces to indent each element in an XML document
231
+ * - _:trace_ [Fixnum] trace level where 0 is silent
232
+ * - _:encoding_ [String] character encoding for the XML file
233
+ * - _:with_dtd_ [true|false|nil] include DTD in the dump
234
+ * - _:with_instruct_ [true|false|nil] include instructions in the dump
235
+ * - _:with_xml_ [true|false|nil] include XML prolog in the dump
236
+ * - _:circular_ [true|false|nil] support circular references while dumping
237
+ * - _:xsd_date_ [true|false|nil] use XSD date format instead of decimal format
238
+ * - _:mode_ [:object|:generic|:limited|nil] load method to use for XML
239
+ * - _:effort_ [:strict|:tolerant|:auto_define] set the tolerance level for loading
240
+ * - _:symbolize_keys_ [true|false|nil] symbolize element attribute keys or leave as Strings
241
+ * - _:skip_ [:skip_none|:skip_return|:skip_white] determines how to handle white space in text
242
+ * - _:smart_ [true|false|nil] flag indicating the SAX parser uses hints if available (use with html)
243
+ * - _:convert_special_ [true|false|nil] flag indicating special characters like < are converted with the SAX parser
244
+ * - _:invalid_replace_ [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
245
+ * - _:strip_namespace_ [String|true|false] false or "" results in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
246
+ * *return* [Hash] all current option settings.
243
247
  *
244
248
  * Note that an indent of less than zero will result in a tight one line output
245
249
  * unless the text in the XML fields contain new line characters.
@@ -250,7 +254,7 @@ get_def_opts(VALUE self) {
250
254
  int elen = (int)strlen(ox_default_options.encoding);
251
255
 
252
256
  rb_hash_aset(opts, ox_encoding_sym, (0 == elen) ? Qnil : rb_str_new(ox_default_options.encoding, elen));
253
- rb_hash_aset(opts, indent_sym, INT2FIX(ox_default_options.indent));
257
+ rb_hash_aset(opts, ox_indent_sym, INT2FIX(ox_default_options.indent));
254
258
  rb_hash_aset(opts, trace_sym, INT2FIX(ox_default_options.trace));
255
259
  rb_hash_aset(opts, with_dtd_sym, (Yes == ox_default_options.with_dtd) ? Qtrue : ((No == ox_default_options.with_dtd) ? Qfalse : Qnil));
256
260
  rb_hash_aset(opts, with_xml_sym, (Yes == ox_default_options.with_xml) ? Qtrue : ((No == ox_default_options.with_xml) ? Qfalse : Qnil));
@@ -298,22 +302,22 @@ get_def_opts(VALUE self) {
298
302
  /* call-seq: ox_default_options=(opts)
299
303
  *
300
304
  * Sets the default options for load and dump.
301
- * @param [Hash] opts options to change
302
- * @param [Fixnum] :indent number of spaces to indent each element in an XML document
303
- * @param [Fixnum] :trace trace level where 0 is silent
304
- * @param [String] :encoding character encoding for the XML file
305
- * @param [true|false|nil] :with_dtd include DTD in the dump
306
- * @param [true|false|nil] :with_instruct include instructions in the dump
307
- * @param [true|false|nil] :with_xml include XML prolog in the dump
308
- * @param [true|false|nil] :circular support circular references while dumping
309
- * @param [true|false|nil] :xsd_date use XSD date format instead of decimal format
310
- * @param [:object|:generic|:limited|nil] :mode load method to use for XML
311
- * @param [:strict|:tolerant|:auto_define] :effort set the tolerance level for loading
312
- * @param [true|false|nil] :symbolize_keys symbolize element attribute keys or leave as Strings
313
- * @param [:skip_none|:skip_return|:skip_white] determines how to handle white space in text
314
- * @param [nil|String] :invalid_replace replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
315
- * @param [nil|String|true|false] :strip_namespace "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
316
- * @return [nil]
305
+ * - +opts+ [Hash] opts options to change
306
+ * - _:indent_ [Fixnum] number of spaces to indent each element in an XML document
307
+ * - _:trace_ [Fixnum] trace level where 0 is silent
308
+ * - _:encoding_ [String] character encoding for the XML file
309
+ * - _:with_dtd_ [true|false|nil] include DTD in the dump
310
+ * - _:with_instruct_ [true|false|nil] include instructions in the dump
311
+ * - _:with_xml_ [true|false|nil] include XML prolog in the dump
312
+ * - _:circular_ [true|false|nil] support circular references while dumping
313
+ * - _:xsd_date_ [true|false|nil] use XSD date format instead of decimal format
314
+ * - _:mode_ [:object|:generic|:limited|nil] load method to use for XML
315
+ * - _:effort_ [:strict|:tolerant|:auto_define] set the tolerance level for loading
316
+ * - _:symbolize_keys_ [true|false|nil] symbolize element attribute keys or leave as Strings
317
+ * - _skip_ [:skip_none|:skip_return|:skip_white] determines how to handle white space in text
318
+ * - _:invalid_replace_ [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
319
+ * - _:strip_namespace_ [nil|String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
320
+ * *return* [nil]
317
321
  */
318
322
  static VALUE
319
323
  set_def_opts(VALUE self, VALUE opts) {
@@ -346,7 +350,7 @@ set_def_opts(VALUE self, VALUE opts) {
346
350
  #endif
347
351
  }
348
352
 
349
- v = rb_hash_aref(opts, indent_sym);
353
+ v = rb_hash_aref(opts, ox_indent_sym);
350
354
  if (Qnil != v) {
351
355
  Check_Type(v, T_FIXNUM);
352
356
  ox_default_options.indent = FIX2INT(v);
@@ -467,8 +471,8 @@ set_def_opts(VALUE self, VALUE opts) {
467
471
  * optimized XML formated String. For other formats use the more generic
468
472
  * Ox.load() method. Raises an exception if the XML is malformed or the
469
473
  * classes specified in the file are not valid.
470
- * @param [String] xml XML String in optimized Object format.
471
- * @return [Object] deserialized Object.
474
+ * - +xml+ [String] XML String in optimized Object format.
475
+ * *return* [Object] deserialized Object.
472
476
  */
473
477
  static VALUE
474
478
  to_obj(VALUE self, VALUE ruby_xml) {
@@ -509,9 +513,10 @@ to_obj(VALUE self, VALUE ruby_xml) {
509
513
  /* call-seq: parse(xml) => Ox::Document or Ox::Element
510
514
  *
511
515
  * Parses and XML document String into an Ox::Document or Ox::Element.
512
- * @param [String] xml XML String
513
- * @return [Ox::Document or Ox::Element] parsed XML document.
514
- * @raise [Exception] if the XML is malformed.
516
+ * - +xml+ [String] xml XML String
517
+ * *return* [Ox::Document or Ox::Element] parsed XML document.
518
+ *
519
+ * _raise_ [Exception] if the XML is malformed.
515
520
  */
516
521
  static VALUE
517
522
  to_gen(VALUE self, VALUE ruby_xml) {
@@ -694,20 +699,20 @@ load(char *xml, int argc, VALUE *argv, VALUE self, VALUE encoding, Err err) {
694
699
  * on the completion of each complete top level entity with that entity as it's
695
700
  * only argument.
696
701
  *
697
- * @param [String] xml XML String
698
- * @param [Hash] options load options
699
- * @param [:object|:generic|:limited] :mode format expected
700
- * - *:object* - object format
701
- * - *:generic* - read as a generic XML file
702
- * - *:limited* - read as a generic XML file but with callbacks on text and elements events only
703
- * @param [:strict|:tolerant|:auto_define] :effort effort to use when an undefined class is encountered, default: :strict
704
- * - *:strict* - raise an NameError for missing classes and modules
705
- * - *:tolerant* - return nil for missing classes and modules
706
- * - *:auto_define* - auto define missing classes and modules
707
- * @param [Fixnum] :trace trace level as a Fixnum, default: 0 (silent)
708
- * @param [true|false|nil] :symbolize_keys symbolize element attribute keys or leave as Strings
709
- * @param [nil|String] :invalid_replace replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
710
- * @param [String|true|false] :strip_namespace "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
702
+ * - +xml+ [String] XML String
703
+ * - +options+ [Hash] load options
704
+ * - *:mode* [:object|:generic|:limited] format expected
705
+ * - _:object_ - object format
706
+ * - _:generic_ - read as a generic XML file
707
+ * - _:limited_ - read as a generic XML file but with callbacks on text and elements events only
708
+ * - *:effort* [:strict|:tolerant|:auto_define] effort to use when an undefined class is encountered, default: :strict
709
+ * - _:strict_ - raise an NameError for missing classes and modules
710
+ * - _:tolerant_ - return nil for missing classes and modules
711
+ * - _:auto_define_ - auto define missing classes and modules
712
+ * - *:trace* [Fixnum] trace level as a Fixnum, default: 0 (silent)
713
+ * - *:symbolize_keys* [true|false|nil] symbolize element attribute keys or leave as Strings
714
+ * - *:invalid_replace* [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
715
+ * - *:strip_namespace* [String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
711
716
  */
712
717
  static VALUE
713
718
  load_str(int argc, VALUE *argv, VALUE self) {
@@ -753,20 +758,20 @@ load_str(int argc, VALUE *argv, VALUE self) {
753
758
  * Parses and XML document from a file into an Ox::Document, or Ox::Element,
754
759
  * or Object depending on the options. Raises an exception if the XML is
755
760
  * malformed or the classes specified are not valid.
756
- * @param [String] file_path file path to read the XML document from
757
- * @param [Hash] options load options
758
- * @param [:object|:generic|:limited] :mode format expected
759
- * - *:object* - object format
760
- * - *:generic* - read as a generic XML file
761
- * - *:limited* - read as a generic XML file but with callbacks on text and elements events only
762
- * @param [:strict|:tolerant|:auto_define] :effort effort to use when an undefined class is encountered, default: :strict
763
- * - *:strict* - raise an NameError for missing classes and modules
764
- * - *:tolerant* - return nil for missing classes and modules
765
- * - *:auto_define* - auto define missing classes and modules
766
- * @param [Fixnum] :trace trace level as a Fixnum, default: 0 (silent)
767
- * @param [true|false|nil] :symbolize_keys symbolize element attribute keys or leave as Strings
768
- * @param [nil|String] :invalid_replace replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
769
- * @param [String|true|false] :strip_namespace "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
761
+ * - +file_path+ [String] file path to read the XML document from
762
+ * - +options+ [Hash] load options
763
+ * - *:mode* [:object|:generic|:limited] format expected
764
+ * - _:object_ - object format
765
+ * - _:generic_ - read as a generic XML file
766
+ * - _:limited_ - read as a generic XML file but with callbacks on text and elements events only
767
+ * - *:effort* [:strict|:tolerant|:auto_define] effort to use when an undefined class is encountered, default: :strict
768
+ * - _:strict_ - raise an NameError for missing classes and modules
769
+ * - _:tolerant_ - return nil for missing classes and modules
770
+ * - _:auto_define_ - auto define missing classes and modules
771
+ * - *:trace* [Fixnum] trace level as a Fixnum, default: 0 (silent)
772
+ * - *:symbolize_keys* [true|false|nil] symbolize element attribute keys or leave as Strings
773
+ * - *:invalid_replace* [nil|String] replacement string for invalid XML characters on dump. nil indicates include anyway as hex. A string, limited to 10 characters will replace the invalid character with the replace.
774
+ * - *:strip_namespace* [String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
770
775
  */
771
776
  static VALUE
772
777
  load_file(int argc, VALUE *argv, VALUE self) {
@@ -812,14 +817,14 @@ load_file(int argc, VALUE *argv, VALUE self) {
812
817
  *
813
818
  * Parses an IO stream or file containing an XML document. Raises an exception
814
819
  * if the XML is malformed or the classes specified are not valid.
815
- * @param [Ox::Sax] handler SAX (responds to OX::Sax methods) like handler
816
- * @param [IO|String] io IO Object to read from
817
- * @param [Hash] options parse options
818
- * @param [true|false] :convert_special flag indicating special characters like < are converted
819
- * @param [true|false] :symbolize flag indicating the parser symbolize element and attribute names
820
- * @param [true|false] :smart flag indicating the parser uses hints if available (use with html)
821
- * @param [:skip_return|:skip_white] :skip flag indicating the parser skips \r or collpase white space into a single space. Default (skip nothing)
822
- * @param [nil|String|true|false] :strip_namespace "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
820
+ * - +handler+ [Ox::Sax] SAX (responds to OX::Sax methods) like handler
821
+ * - +io+ [IO|String] IO Object to read from
822
+ * - +options+ [Hash] options parse options
823
+ * - *:convert_special* [true|false] flag indicating special characters like < are converted
824
+ * - *:symbolize* [true|false] flag indicating the parser symbolize element and attribute names
825
+ * - *:smart* [true|false] flag indicating the parser uses hints if available (use with html)
826
+ * - *:skip* [:skip_return|:skip_white] flag indicating the parser skips \r or collpase white space into a single space. Default (skip nothing)
827
+ * - *:strip_namespace* [nil|String|true|false] "" or false result in no namespace stripping. A string of "*" or true will strip all namespaces. Any other non-empty string indicates that matching namespaces will be stripped.
823
828
  */
824
829
  static VALUE
825
830
  sax_parse(int argc, VALUE *argv, VALUE self) {
@@ -896,7 +901,7 @@ parse_dump_options(VALUE ropts, Options copts) {
896
901
  if (rb_cHash == rb_obj_class(ropts)) {
897
902
  VALUE v;
898
903
 
899
- if (Qnil != (v = rb_hash_lookup(ropts, indent_sym))) {
904
+ if (Qnil != (v = rb_hash_lookup(ropts, ox_indent_sym))) {
900
905
  if (rb_cFixnum != rb_obj_class(v)) {
901
906
  rb_raise(ox_parse_error_class, ":indent must be a Fixnum.\n");
902
907
  }
@@ -964,14 +969,14 @@ parse_dump_options(VALUE ropts, Options copts) {
964
969
  /* call-seq: dump(obj, options) => xml-string
965
970
  *
966
971
  * Dumps an Object (obj) to a string.
967
- * @param [Object] obj Object to serialize as an XML document String
968
- * @param [Hash] options formating options
969
- * @param [Fixnum] :indent format expected
970
- * @param [true|false] :xsd_date use XSD date format if true, default: false
971
- * @param [true|false] :circular allow circular references, default: false
972
- * @param [:strict|:tolerant] :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
973
- * - *:strict* - raise an NotImplementedError if an undumpable object is encountered
974
- * - *:tolerant* - replaces undumplable objects with nil
972
+ * - +obj+ [Object] Object to serialize as an XML document String
973
+ * - +options+ [Hash] formating options
974
+ * - *:indent* [Fixnum] format expected
975
+ * - *:xsd_date* [true|false] use XSD date format if true, default: false
976
+ * - *:circular* [true|false] allow circular references, default: false
977
+ * - *:strict|:tolerant]* [ :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
978
+ * - _:strict_ - raise an NotImplementedError if an undumpable object is encountered
979
+ * - _:tolerant_ - replaces undumplable objects with nil
975
980
  *
976
981
  * Note that an indent of less than zero will result in a tight one line output
977
982
  * unless the text in the XML fields contain new line characters.
@@ -1006,15 +1011,15 @@ dump(int argc, VALUE *argv, VALUE self) {
1006
1011
  /* call-seq: to_file(file_path, obj, options)
1007
1012
  *
1008
1013
  * Dumps an Object to the specified file.
1009
- * @param [String] file_path file path to write the XML document to
1010
- * @param [Object] obj Object to serialize as an XML document String
1011
- * @param [Hash] options formating options
1012
- * @param [Fixnum] :indent format expected
1013
- * @param [true|false] :xsd_date use XSD date format if true, default: false
1014
- * @param [true|false] :circular allow circular references, default: false
1015
- * @param [:strict|:tolerant] :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
1016
- * - *:strict* - raise an NotImplementedError if an undumpable object is encountered
1017
- * - *:tolerant* - replaces undumplable objects with nil
1014
+ * - +file_path+ [String] file path to write the XML document to
1015
+ * - +obj+ [Object] Object to serialize as an XML document String
1016
+ * - +options+ [Hash] formating options
1017
+ * - *:indent* [Fixnum] format expected
1018
+ * - *:xsd_date* [true|false] use XSD date format if true, default: false
1019
+ * - *:circular* [true|false] allow circular references, default: false
1020
+ * - *:strict|:tolerant]* [ :effort effort to use when an undumpable object (e.g., IO) is encountered, default: :strict
1021
+ * - _:strict_ - raise an NotImplementedError if an undumpable object is encountered
1022
+ * - _:tolerant_ - replaces undumplable objects with nil
1018
1023
  *
1019
1024
  * Note that an indent of less than zero will result in a tight one line output
1020
1025
  * unless the text in the XML fields contain new line characters.
@@ -1032,6 +1037,7 @@ to_file(int argc, VALUE *argv, VALUE self) {
1032
1037
  return Qnil;
1033
1038
  }
1034
1039
 
1040
+ #if WITH_CACHE_TESTS
1035
1041
  extern void ox_cache_test(void);
1036
1042
 
1037
1043
  static VALUE
@@ -1047,6 +1053,7 @@ cache8_test(VALUE self) {
1047
1053
  ox_cache8_test();
1048
1054
  return Qnil;
1049
1055
  }
1056
+ #endif
1050
1057
 
1051
1058
  void Init_ox() {
1052
1059
  Ox = rb_define_module("Ox");
@@ -1065,6 +1072,8 @@ void Init_ox() {
1065
1072
  rb_define_module_function(Ox, "load_file", load_file, -1);
1066
1073
  rb_define_module_function(Ox, "to_file", to_file, -1);
1067
1074
 
1075
+ ox_init_builder(Ox);
1076
+
1068
1077
  rb_require("time");
1069
1078
  rb_require("date");
1070
1079
  rb_require("bigdecimal");
@@ -1148,7 +1157,8 @@ void Init_ox() {
1148
1157
  convert_special_sym = ID2SYM(rb_intern("convert_special")); rb_gc_register_address(&convert_special_sym);
1149
1158
  effort_sym = ID2SYM(rb_intern("effort")); rb_gc_register_address(&effort_sym);
1150
1159
  generic_sym = ID2SYM(rb_intern("generic")); rb_gc_register_address(&generic_sym);
1151
- indent_sym = ID2SYM(rb_intern("indent")); rb_gc_register_address(&indent_sym);
1160
+ ox_indent_sym = ID2SYM(rb_intern("indent")); rb_gc_register_address(&ox_indent_sym);
1161
+ ox_size_sym = ID2SYM(rb_intern("size")); rb_gc_register_address(&ox_size_sym);
1152
1162
  invalid_replace_sym = ID2SYM(rb_intern("invalid_replace")); rb_gc_register_address(&invalid_replace_sym);
1153
1163
  limited_sym = ID2SYM(rb_intern("limited")); rb_gc_register_address(&limited_sym);
1154
1164
  mode_sym = ID2SYM(rb_intern("mode")); rb_gc_register_address(&mode_sym);
@@ -1156,6 +1166,8 @@ void Init_ox() {
1156
1166
  opt_format_sym = ID2SYM(rb_intern("opt_format")); rb_gc_register_address(&opt_format_sym);
1157
1167
  optimized_sym = ID2SYM(rb_intern("optimized")); rb_gc_register_address(&optimized_sym);
1158
1168
  ox_encoding_sym = ID2SYM(rb_intern("encoding")); rb_gc_register_address(&ox_encoding_sym);
1169
+ ox_version_sym = ID2SYM(rb_intern("version")); rb_gc_register_address(&ox_version_sym);
1170
+ ox_standalone_sym = ID2SYM(rb_intern("standalone")); rb_gc_register_address(&ox_standalone_sym);
1159
1171
  skip_none_sym = ID2SYM(rb_intern("skip_none")); rb_gc_register_address(&skip_none_sym);
1160
1172
  skip_return_sym = ID2SYM(rb_intern("skip_return")); rb_gc_register_address(&skip_return_sym);
1161
1173
  skip_sym = ID2SYM(rb_intern("skip")); rb_gc_register_address(&skip_sym);
@@ -1191,12 +1203,17 @@ void Init_ox() {
1191
1203
 
1192
1204
  ox_sax_define();
1193
1205
 
1194
- rb_define_module_function(Ox, "cache_test", cache_test, 0);
1195
- rb_define_module_function(Ox, "cache8_test", cache8_test, 0);
1206
+ #if WITH_CACHE_TESTS
1207
+ // space added to stop yardoc from trying to document
1208
+ rb_define _module_function(Ox, "cache_test", cache_test, 0);
1209
+ rb_define _module_function(Ox, "cache8_test", cache8_test, 0);
1210
+ #endif
1211
+
1196
1212
  #if HAS_ENCODING_SUPPORT
1197
1213
  ox_utf8_encoding = rb_enc_find("UTF-8");
1198
1214
  #elif HAS_PRIVATE_ENCODING
1199
- ox_utf8_encoding = rb_str_new2("UTF-8"); rb_gc_register_address(&ox_utf8_encoding);
1215
+ ox_utf8_encoding = rb_str_new2("UTF-8");
1216
+ rb_gc_register_address(&ox_utf8_encoding);
1200
1217
  #endif
1201
1218
  }
1202
1219
 
@@ -227,15 +227,20 @@ extern VALUE ox_utf8_encoding;
227
227
  extern void *ox_utf8_encoding;
228
228
  #endif
229
229
 
230
- extern VALUE ox_bigdecimal_class;
231
- extern VALUE ox_date_class;
232
230
  extern VALUE ox_empty_string;
233
231
  extern VALUE ox_encoding_sym;
232
+ extern VALUE ox_indent_sym;
233
+ extern VALUE ox_size_sym;
234
+ extern VALUE ox_standalone_sym;
235
+ extern VALUE ox_sym_bank; // Array
236
+ extern VALUE ox_version_sym;
237
+ extern VALUE ox_zero_fixnum;
238
+
239
+ extern VALUE ox_bigdecimal_class;
240
+ extern VALUE ox_date_class;
234
241
  extern VALUE ox_stringio_class;
235
242
  extern VALUE ox_struct_class;
236
243
  extern VALUE ox_time_class;
237
- extern VALUE ox_zero_fixnum;
238
- extern VALUE ox_sym_bank; // Array
239
244
 
240
245
  extern VALUE ox_document_clas;
241
246
  extern VALUE ox_element_clas;
@@ -250,6 +255,8 @@ extern Cache ox_symbol_cache;
250
255
  extern Cache ox_class_cache;
251
256
  extern Cache ox_attr_cache;
252
257
 
258
+ extern void ox_init_builder(VALUE ox);
259
+
253
260
  #if defined(__cplusplus)
254
261
  #if 0
255
262
  { /* satisfy cc-mode */
@@ -110,6 +110,10 @@ parse_xsd_time(const char *text) {
110
110
  #endif
111
111
  }
112
112
 
113
+ /* call-seq: as_s()
114
+ *
115
+ * *return* value as an String.
116
+ */
113
117
  static VALUE
114
118
  sax_value_as_s(VALUE self) {
115
119
  SaxDrive dr = DATA_PTR(self);
@@ -144,6 +148,10 @@ sax_value_as_s(VALUE self) {
144
148
  return rs;
145
149
  }
146
150
 
151
+ /* call-seq: as_sym()
152
+ *
153
+ * *return* value as an Symbol.
154
+ */
147
155
  static VALUE
148
156
  sax_value_as_sym(VALUE self) {
149
157
  SaxDrive dr = DATA_PTR(self);
@@ -154,6 +162,10 @@ sax_value_as_sym(VALUE self) {
154
162
  return str2sym(dr, dr->buf.str, 0);
155
163
  }
156
164
 
165
+ /* call-seq: as_f()
166
+ *
167
+ * *return* value as an Float.
168
+ */
157
169
  static VALUE
158
170
  sax_value_as_f(VALUE self) {
159
171
  SaxDrive dr = DATA_PTR(self);
@@ -164,6 +176,10 @@ sax_value_as_f(VALUE self) {
164
176
  return rb_float_new(strtod(dr->buf.str, 0));
165
177
  }
166
178
 
179
+ /* call-seq: as_i()
180
+ *
181
+ * *return* value as an Fixnum.
182
+ */
167
183
  static VALUE
168
184
  sax_value_as_i(VALUE self) {
169
185
  SaxDrive dr = DATA_PTR(self);
@@ -193,6 +209,10 @@ sax_value_as_i(VALUE self) {
193
209
  return LONG2NUM(n);
194
210
  }
195
211
 
212
+ /* call-seq: as_time()
213
+ *
214
+ * *return* value as an Time.
215
+ */
196
216
  static VALUE
197
217
  sax_value_as_time(VALUE self) {
198
218
  SaxDrive dr = DATA_PTR(self);
@@ -213,18 +233,35 @@ sax_value_as_time(VALUE self) {
213
233
  return t;
214
234
  }
215
235
 
236
+ /* call-seq: as_bool()
237
+ *
238
+ * *return* value as an boolean.
239
+ */
216
240
  static VALUE
217
241
  sax_value_as_bool(VALUE self) {
218
242
  return (0 == strcasecmp("true", ((SaxDrive)DATA_PTR(self))->buf.str)) ? Qtrue : Qfalse;
219
243
  }
220
244
 
245
+ /* call-seq: empty()
246
+ *
247
+ * *return* true if the value is empty.
248
+ */
221
249
  static VALUE
222
250
  sax_value_empty(VALUE self) {
223
251
  return ('\0' == *((SaxDrive)DATA_PTR(self))->buf.str) ? Qtrue : Qfalse;
224
252
  }
225
253
 
254
+ /* Document-class: Ox::Sax::Value
255
+ *
256
+ * Values in the SAX callbacks. They can be converted to various different
257
+ * types. with the _as_x()_ methods.
258
+ */
226
259
  void
227
260
  ox_sax_define() {
261
+ #if 0
262
+ ox = rb_define_module("Ox");
263
+ sax_module = rb_define_class_under(ox, "Sax", rb_cObject);
264
+ #endif
228
265
  VALUE sax_module = rb_const_get_at(Ox, rb_intern("Sax"));
229
266
 
230
267
  ox_sax_value_class = rb_define_class_under(sax_module, "Value", rb_cObject);