ndtypes 0.2.0dev6 → 0.2.0dev8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/ext/ruby_ndtypes/GRTAGS +0 -0
  3. data/ext/ruby_ndtypes/GTAGS +0 -0
  4. data/ext/ruby_ndtypes/include/ruby_ndtypes.h +90 -0
  5. data/ext/ruby_ndtypes/lib/libndtypes.a +0 -0
  6. data/ext/ruby_ndtypes/lib/libndtypes.so.0.2.0dev3 +0 -0
  7. data/ext/ruby_ndtypes/ndtypes/config.log +3 -3
  8. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.c +756 -807
  9. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.o +0 -0
  10. data/ext/ruby_ndtypes/ndtypes/libndtypes/grammar.y +3 -13
  11. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.c +2 -2
  12. data/ext/ruby_ndtypes/ndtypes/libndtypes/io.o +0 -0
  13. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.a +0 -0
  14. data/ext/ruby_ndtypes/ndtypes/libndtypes/libndtypes.so.0.2.0dev3 +0 -0
  15. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_match.c +5 -5
  16. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse.c +12 -12
  17. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_error.c +8 -8
  18. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_parse_roundtrip.c +6 -6
  19. data/ext/ruby_ndtypes/ndtypes/libndtypes/tests/test_typecheck.c +6 -6
  20. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/_ndtypes.c +2 -2
  21. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.a +0 -0
  22. data/ext/ruby_ndtypes/ndtypes/python/ndtypes/libndtypes.so.0.2.0dev3 +0 -0
  23. data/ext/ruby_ndtypes/ndtypes/python/test_ndtypes.py +22 -4
  24. data/ext/ruby_ndtypes/ruby_ndtypes.c +0 -20
  25. data/ext/ruby_ndtypes/ruby_ndtypes.h +90 -0
  26. data/lib/ndtypes.rb +6 -0
  27. data/lib/ndtypes/version.rb +2 -2
  28. data/lib/ruby_ndtypes.so +0 -0
  29. metadata +2 -2
@@ -123,8 +123,6 @@ yylex(YYSTYPE *val, YYLTYPE *loc, yyscan_t scanner, ndt_context_t *ctx)
123
123
  %type <ndt> fixed_string
124
124
  %type <ndt> bytes
125
125
  %type <ndt> fixed_bytes
126
- %type <ndt> array_dimensions
127
- %type <ndt> array
128
126
  %type <ndt> ref
129
127
 
130
128
  %type <ndt> tuple_type
@@ -225,7 +223,7 @@ datashape_with_ellipsis:
225
223
  | fixed_ellipsis { $$ = $1; }
226
224
  | NAME_UPPER LBRACK fixed_ellipsis RBRACK { $$ = mk_contig($1, (ndt_t *)$3, ctx); if ($$ == NULL) YYABORT; }
227
225
  | VAR ELLIPSIS STAR dtype { $$ = mk_var_ellipsis($4, ctx); if ($$ == NULL) YYABORT; }
228
- | array_dimensions { $$ = $1; }
226
+ | ARRAY ELLIPSIS STAR datashape { $$ = mk_array_ellipsis($4, ctx); if ($$ == NULL) YYABORT; }
229
227
 
230
228
  fixed_ellipsis:
231
229
  ELLIPSIS STAR dimensions_tail { $$ = mk_ellipsis_dim(NULL, $3, ctx); if ($$ == NULL) YYABORT; }
@@ -246,7 +244,8 @@ dimensions_nooption:
246
244
  | NAME_UPPER STAR dimensions_tail { $$ = mk_symbolic_dim($1, $3, ctx); if ($$ == NULL) YYABORT; }
247
245
  | VAR arguments_opt STAR dimensions_tail { $$ = mk_var_dim($2, $4, false, ctx); if ($$ == NULL) YYABORT; }
248
246
  | QUESTIONMARK VAR arguments_opt STAR dimensions_tail { $$ = mk_var_dim($3, $5, true, ctx); if ($$ == NULL) YYABORT; }
249
-
247
+ | ARRAY STAR datashape { $$ = mk_array($3, false, ctx); if ($$ == NULL) YYABORT; }
248
+ | QUESTIONMARK ARRAY STAR datashape { $$ = mk_array($4, true, ctx); if ($$ == NULL) YYABORT; }
250
249
 
251
250
  dimensions_tail:
252
251
  dtype { $$ = $1; }
@@ -347,15 +346,6 @@ encoding:
347
346
  bytes:
348
347
  option_opt BYTES arguments_opt { $$ = mk_bytes($3, $1, ctx); if ($$ == NULL) YYABORT; }
349
348
 
350
- array_dimensions:
351
- array { $$ = $1; }
352
- | option_opt ARRAY ELLIPSIS OF datashape { $$ = mk_array_ellipsis($5, ctx); if ($$ == NULL) YYABORT; }
353
- | option_opt ARRAY ELLIPSIS OF array { $$ = mk_array_ellipsis($5, ctx); if ($$ == NULL) YYABORT; }
354
-
355
- array:
356
- option_opt ARRAY OF datashape { $$ = mk_array($4, $1, ctx); if ($$ == NULL) YYABORT; }
357
- | option_opt ARRAY OF array { $$ = mk_array($4, $1, ctx); if ($$ == NULL) YYABORT; }
358
-
359
349
  fixed_bytes:
360
350
  option_opt FIXED_BYTES LPAREN attribute_seq RPAREN { $$ = mk_fixed_bytes($4, $1, ctx); if ($$ == NULL) YYABORT; }
361
351
 
@@ -610,7 +610,7 @@ datashape(buf_t *buf, const ndt_t *t, int d, ndt_context_t *ctx)
610
610
 
611
611
  if (t->EllipsisDim.name) {
612
612
  if (strcmp(t->EllipsisDim.name, "array") == 0) {
613
- n = ndt_snprintf(ctx, buf, "array... of ");
613
+ n = ndt_snprintf(ctx, buf, "array... * ");
614
614
  }
615
615
  else {
616
616
  n = ndt_snprintf(ctx, buf, "%s... * ", t->EllipsisDim.name);
@@ -628,7 +628,7 @@ datashape(buf_t *buf, const ndt_t *t, int d, ndt_context_t *ctx)
628
628
  }
629
629
 
630
630
  case Array: {
631
- n = ndt_snprintf(ctx, buf, "array of ");
631
+ n = ndt_snprintf(ctx, buf, "array * ");
632
632
  if (n < 0) return -1;
633
633
 
634
634
  return datashape(buf, t->Array.type, d, ctx);
@@ -2384,14 +2384,14 @@ const match_testcase_t match_tests[] = {
2384
2384
  "!10 * 3 * 2 * float64", 0 },
2385
2385
 
2386
2386
  /* array... */
2387
- { "array... of float64",
2387
+ { "array... * float64",
2388
2388
  "2 * 3 * float64", 0 },
2389
2389
 
2390
- { "array... of float64",
2391
- "array of float64", 1 },
2390
+ { "array... * float64",
2391
+ "array * float64", 1 },
2392
2392
 
2393
- { "array... of float64",
2394
- "array of array of float64", 1 },
2393
+ { "array... * float64",
2394
+ "array * array * float64", 1 },
2395
2395
 
2396
2396
  /* END MANUALLY GENERATED */
2397
2397
 
@@ -45,8 +45,8 @@ const char *parse_tests[] = {
45
45
  "10 * L * Any",
46
46
  "10 * 10 * L * Any",
47
47
  "var * Any",
48
- "array of Any",
49
- "array of array of Any",
48
+ "array * Any",
49
+ "array * array * Any",
50
50
  "... * Any",
51
51
  "10 * Any",
52
52
  "Any",
@@ -259,26 +259,26 @@ const char *parse_tests[] = {
259
259
  "1286044356 * LbR6JPFI * 2096958782 * uint8",
260
260
  "categorical(-507014936.36, -25910, 'xM3Mys0XqH', 4265882500)",
261
261
  "var * var * FixedBytesKind",
262
- "array of FixedBytesKind",
263
- "array of array of FixedBytesKind",
262
+ "array * FixedBytesKind",
263
+ "array * array * FixedBytesKind",
264
264
  "var * var * var * fixed_bytes(size=2816010912, align=16)",
265
- "array of fixed_bytes(size=2816010912, align=16)",
265
+ "array * fixed_bytes(size=2816010912, align=16)",
266
266
  "36 * 16 * fixed_bytes(size=912328236, align=2)",
267
267
  "var * var * float64",
268
- "array of float64",
268
+ "array * float64",
269
269
  "var * var * var * ZcTmBXnKPi",
270
- "array of ZcTmBXnKPi",
270
+ "array * ZcTmBXnKPi",
271
271
  "categorical('omhwkoWVWw', 43, 946986991)",
272
272
  "var * float32",
273
273
  "var * var * var * uint16",
274
274
  "var * var * var * ScalarKind",
275
- "array of ScalarKind",
275
+ "array * ScalarKind",
276
276
  "fixed_bytes(size=280180380, align=2)",
277
277
  "fixed_string(1901614748, 'utf-32')",
278
278
  "var * M7",
279
279
  "var * bytes(align=2)",
280
280
  "var * var * ULy8(char)",
281
- "array of ULy8(char)",
281
+ "array * ULy8(char)",
282
282
  "fixed_bytes(size=1882259744, align=16)",
283
283
  "categorical(-136747211.015, -58, -83)",
284
284
  "3739637665 * 1476113530 * 1701021063 * IKd * 450514382 * WXn",
@@ -286,7 +286,7 @@ const char *parse_tests[] = {
286
286
  "var * R8KFFEabJ",
287
287
  "var * QoFb",
288
288
  "var * fixed_string(1233383142, 'utf-32')",
289
- "array of fixed_string(1233383142, 'utf-32')",
289
+ "array * fixed_string(1233383142, 'utf-32')",
290
290
  "fixed_bytes(size=2882797968, align=4)",
291
291
  "fixed_bytes(size=1233209904, align=8)",
292
292
  "WhRsMHHXYp(categorical(145))",
@@ -349,7 +349,7 @@ const char *parse_tests[] = {
349
349
  "2 * 3 * ThisRecord of {first: (int64, complex128), second: string}",
350
350
  "2 * 3 * ThisRecord of {first: (int64, complex128), second: string} | ThatTuple of (bytes, string)",
351
351
  "2 * 3 * Int of int64 | ThisRecord of {first: (int64, complex128), second: string} | ThatTuple of (bytes, string)",
352
- "array of Int of int64 | ThisRecord of {first: (int64, complex128), second: uint8} | ThatTuple of (float64, float64)",
352
+ "array * Int of int64 | ThisRecord of {first: (int64, complex128), second: uint8} | ThatTuple of (float64, float64)",
353
353
 
354
354
  "fixed(shape=10) * complex128",
355
355
 
@@ -377,7 +377,7 @@ const char *parse_tests[] = {
377
377
 
378
378
  /* var..., array... */
379
379
  "var... * (int8, int64)",
380
- "array... of (int8, int64)",
380
+ "array... * (int8, int64)",
381
381
 
382
382
  /* END MANUALLY GENERATED */
383
383
 
@@ -396,7 +396,7 @@ const char *parse_error_tests[] = {
396
396
  "?[10 * 10 $ X * Any$",
397
397
  "?[10 * 10 $ X * Any$",
398
398
  "$var * Any",
399
- "$array of Any",
399
+ "$array * Any",
400
400
  "=var * Any",
401
401
  "$[var * Any]",
402
402
  "xxx[var * Any]",
@@ -27748,13 +27748,13 @@ const char *parse_error_tests[] = {
27748
27748
  "fixed_bytes(1342281638, align=xxx)",
27749
27749
  "Y5vtk * var * 905934102 * 1310846899 * fixed[3359714476] * LKgwlEDf * 2822334059 * ; PKI_8Ob8(fixed_string(795133707))",
27750
27750
  "?(E00Lr_HMM * ... * UAzC * var * M4nJaK * , var * var * 1002912577 * PZPD)",
27751
- "?(E00Lr_HMM * ... * UAzC * array of M4nJaK * , array of array of 1002912577 * PZPD)",
27751
+ "?(E00Lr_HMM * ... * UAzC * array * M4nJaK * , array * array * 1002912577 * PZPD)",
27752
27752
  "?ref(fixed_string(3865363101, 'ucs-10'))",
27753
27753
  "fixed[3622391868] * SUc9IusL * CaPaWth4m * CEwSPY_6Z * HPW * SbvgP * 29709a97707 * 1300296096 * Fixed * VA8O",
27754
27754
  "fixed[1603107638)] * 2764230114 * IRXLe * Odlw6RSx * ... * Fixed * var * 2484716214 * ScalarKind",
27755
- "fixed[1603107638)] * 2764230114 * IRXLe * Odlw6RSx * ... * Fixed * array of 2484716214 * ScalarKind",
27755
+ "fixed[1603107638)] * 2764230114 * IRXLe * Odlw6RSx * ... * Fixed * array * 2484716214 * ScalarKind",
27756
27756
  "ZmQxcy * var * 1098824011 * var * var * (,,,)",
27757
- "ZmQxcy * array of 1098824011 of array of array * (,,,)",
27757
+ "ZmQxcy * array * 1098824011 * array * array * (,,,)",
27758
27758
  "ref(?x1869144321 * Y3_Dm0 * int32)",
27759
27759
  "categorical[\"a\", 1619552300, 490620000000000000000000000000000000000000, 18772, -84, 'l']",
27760
27760
  "?fixed[2889099917] * ... * var * JgdIXy5M * var * Wr2[categorical['gLsA7BM43V', 16460]]",
@@ -27762,7 +27762,7 @@ const char *parse_error_tests[] = {
27762
27762
  "?var * Fixed * FdN_HERKv * 4204012258 * var * fixed[233758212000000000000000000000000000] * Fixed * FixedBytesKind",
27763
27763
  "?categorical[30987, -16536, -270032755.642, -189, -823800099]",
27764
27764
  "?Fixed * 1998811088 * var * var * var * var * bytes(align=-58)",
27765
- "?Fixed * 1998811088 * array of array of array of array of bytes(align=-58)",
27765
+ "?Fixed * 1998811088 * array * array * array * array * bytes(align=-58)",
27766
27766
  "257051452 * QRgi * Fixed * 4147849906 * var * P4h8i8 * var * 3924618173 * fixed[207255421] * int100",
27767
27767
  "categorical[408786241.474, 2840608325, 44038, 1763886348, \"jOt', 24]",
27768
27768
  "?[OQ78AW32d[categorical[49]%]",
@@ -27866,9 +27866,9 @@ const char *parse_error_tests[] = {
27866
27866
 
27867
27867
  /* var... and array... */
27868
27868
  "var... of float64",
27869
- "var... * (int64, str)",
27870
- "array... * float64",
27871
- "array... * (int64, str)",
27869
+ "var... of (int64, str)",
27870
+ "array... of float64",
27871
+ "array... of (int64, str)",
27872
27872
  /* END MANUALLY GENERATED */
27873
27873
 
27874
27874
  NULL
@@ -276,7 +276,7 @@ const char *parse_roundtrip_tests[] = {
276
276
  /* BEGIN RANDOM */
277
277
  "fixed_bytes(size=1342281600, align=16)",
278
278
  "var * var * var * (...)",
279
- "array of (...)",
279
+ "array * (...)",
280
280
  "categorical(-84, 18772, 49062, 1619552300, 'a', 'l')",
281
281
  "categorical(24, 44038, 1763886348, 2840608325, 1.2e-32, 'jOt')",
282
282
  "categorical(-2049848438, 94, 3577056037, 3599739756, 1.2e-32)",
@@ -284,15 +284,15 @@ const char *parse_roundtrip_tests[] = {
284
284
  "1286044356 * LbR6JPFI * 2096958782 * uint8",
285
285
  "categorical(-25910, 4265882500, 1.2e-32, 'xM3Mys0XqH')",
286
286
  "var * var * FixedBytesKind",
287
- "array of FixedBytesKind",
287
+ "array * FixedBytesKind",
288
288
  "var * var * var * fixed_bytes(size=2816010912, align=16)",
289
289
  "36 * 16 * fixed_bytes(size=912328236, align=2)",
290
290
  "var * var * var * ZcTmBXnKPi",
291
291
  "categorical(946986991, 43, 'omhwkoWVWw')",
292
292
  "var * float32",
293
- "array of float32",
293
+ "array * float32",
294
294
  "var * var * var * uint16",
295
- "array of uint16",
295
+ "array * uint16",
296
296
  "var * var * var * ScalarKind",
297
297
  "fixed_bytes(size=280180300, align=2)",
298
298
  "fixed_string(1901614748, 'utf32')",
@@ -308,7 +308,7 @@ const char *parse_roundtrip_tests[] = {
308
308
  "fixed_bytes(size=1233209904, align=8)",
309
309
  "WhRsMHHXYp(categorical(145))",
310
310
  "var * var * bytes(align=2)",
311
- "array of fixed_bytes(size=2882797900, align=2)",
311
+ "array * fixed_bytes(size=2882797900, align=2)",
312
312
  "categorical(-85, -49, -26791, 8094, 1780, 1.2e-32, 'pX')",
313
313
  "D6nfBg_(categorical(16278, 26651, 147170982, 1.2e-32, 'ylR7'))",
314
314
  "categorical(482331467, 3229733591, -1.2e-32, 1.2e-32)",
@@ -358,7 +358,7 @@ const char *parse_roundtrip_tests[] = {
358
358
 
359
359
  /* var... and array... */
360
360
  "var... * float64",
361
- "array... of float64",
361
+ "array... * float64",
362
362
 
363
363
  /* END MANUALLY GENERATED */
364
364
 
@@ -801,28 +801,28 @@ const typecheck_testcase_t typecheck_tests[] = {
801
801
  { .loc = loc(),
802
802
  .success=true,
803
803
 
804
- .signature="array... of float64 -> array... of int64",
805
- .args={"array of float64"},
804
+ .signature="array... * float64 -> array... * int64",
805
+ .args={"array * float64"},
806
806
  .kwargs={NULL},
807
807
 
808
808
  .outer_dims=1,
809
809
  .nin=1,
810
810
  .nout=1,
811
811
  .nargs=2,
812
- .types={ "array of float64", "array of int64" } },
812
+ .types={ "array * float64", "array * int64" } },
813
813
 
814
814
  { .loc = loc(),
815
815
  .success=true,
816
816
 
817
- .signature="array... of array of float64, array... of uint8 -> array... of array of int64",
818
- .args={"array of array of float64", "array of uint8"},
817
+ .signature="array... * array * float64, array... * uint8 -> array... * array * int64",
818
+ .args={"array * array * float64", "array * uint8"},
819
819
  .kwargs={NULL},
820
820
 
821
821
  .outer_dims=1,
822
822
  .nin=2,
823
823
  .nout=1,
824
824
  .nargs=3,
825
- .types={ "array of array of float64", "array of uint8", "array of array of int64" } },
825
+ .types={ "array * array * float64", "array * uint8", "array * array * int64" } },
826
826
 
827
827
  { .loc=NULL, .success=false, .signature= NULL, .args={NULL}, .kwargs={NULL} }
828
828
  };
@@ -229,7 +229,7 @@ from_string(PyObject *v)
229
229
  return NULL;
230
230
  }
231
231
 
232
- return t;
232
+ return t;
233
233
  }
234
234
 
235
235
  static PyObject *
@@ -1100,7 +1100,7 @@ static PyMethodDef ndtype_methods [] =
1100
1100
  /* Boolean functions on array types */
1101
1101
  { "is_c_contiguous", (PyCFunction)ndtype_ndt_is_c_contiguous, METH_NOARGS, doc_is_c_contiguous },
1102
1102
  { "is_f_contiguous", (PyCFunction)ndtype_ndt_is_f_contiguous, METH_NOARGS, doc_is_f_contiguous },
1103
- { "is_var_contiguous", (PyCFunction)dtype_ndt_is_var_contiguous, METH_NOARGS, NULL },
1103
+ { "is_var_contiguous", (PyCFunction)ndtype_ndt_is_var_contiguous, METH_NOARGS, NULL },
1104
1104
 
1105
1105
  /* Binary functions */
1106
1106
  { "at", (PyCFunction)ndtype_at, METH_VARARGS|METH_KEYWORDS, NULL },
@@ -601,10 +601,11 @@ class TestEllipsisDim(unittest.TestCase):
601
601
  self.assertRaises(TypeError, getattr, t, 'shape')
602
602
  self.assertRaises(TypeError, getattr, t, 'strides')
603
603
 
604
+
604
605
  class TestArray(unittest.TestCase):
605
606
 
606
607
  def test_array_predicates(self):
607
- t = ndt("array of complex128")
608
+ t = ndt("array * complex128")
608
609
  check_serialize(self, t)
609
610
 
610
611
  self.assertFalse(t.isabstract())
@@ -621,7 +622,7 @@ class TestArray(unittest.TestCase):
621
622
 
622
623
  def test_array_dim_common_fields(self):
623
624
  dt = "{a: complex64, b: float64}"
624
- t = ndt("array of %s" % dt)
625
+ t = ndt("array * %s" % dt)
625
626
  check_serialize(self, t)
626
627
  dtype = ndt(dt)
627
628
 
@@ -637,8 +638,25 @@ class TestArray(unittest.TestCase):
637
638
 
638
639
  def test_array_invariants(self):
639
640
  # Mixing array with fixed/var dimensions is disallowed.
640
- self.assertRaises(TypeError, ndt, "array of 2 * int64")
641
- self.assertRaises(TypeError, ndt, "array of var * int64")
641
+ self.assertRaises(TypeError, ndt, "array * 2 * int64")
642
+ self.assertRaises(TypeError, ndt, "array * var * int64")
643
+
644
+ def test_array_geojson(self):
645
+ typedef("id", """
646
+ String of string
647
+ | Int of int64
648
+ """)
649
+
650
+ typedef("position", "array * float64")
651
+
652
+ typedef("geometry", """
653
+ Point of position
654
+ | MultiPoint of array * position
655
+ | LineString of array * position
656
+ | MultiLineString of array * array * position
657
+ | Polygon of array * position
658
+ | MultiPolygon of array * array * position
659
+ """)
642
660
 
643
661
 
644
662
  class TestTuple(unittest.TestCase):
@@ -12,7 +12,6 @@ static const rb_data_type_t NdtObject_type;
12
12
  /* Class declarations. */
13
13
  VALUE cNDTypes;
14
14
  VALUE mNDTypes_GCGuard;
15
- static VALUE cNDTypes_RBuf;
16
15
 
17
16
  static VALUE rb_eValueError;
18
17
 
@@ -941,36 +940,29 @@ rb_ndtypes_from_type(const ndt_t *type)
941
940
  return self;
942
941
  }
943
942
 
944
- /* Return 1 if obj is of type NDTypes. 0 otherwise. */
945
943
  int
946
944
  rb_ndtypes_check_type(VALUE obj)
947
945
  {
948
946
  return NDT_CHECK_TYPE(obj);
949
947
  }
950
948
 
951
- /* Get a pointer to the NdtObject struct that is contained within obj. */
952
949
  NdtObject *
953
950
  rb_ndtypes_get_ndt_object(VALUE obj)
954
951
  {
955
952
  NdtObject *ndt_p;
956
-
957
953
  if (!NDT_CHECK_TYPE(obj)) {
958
954
  /* raise error */
959
955
  }
960
-
961
956
  GET_NDT(obj, ndt_p);
962
-
963
957
  return ndt_p;
964
958
  }
965
959
 
966
- /* Get an allocated Ruby object of type NDTypes. ndt_p should have been allocated already. */
967
960
  VALUE
968
961
  rb_ndtypes_make_ndt_object(NdtObject *ndt_p)
969
962
  {
970
963
  return MAKE_NDT(cNDTypes, ndt_p);
971
964
  }
972
965
 
973
- /* Perform allocation and get a Ruby object of type NDTypes. */
974
966
  VALUE
975
967
  rb_ndtypes_wrap_ndt_object(void)
976
968
  {
@@ -979,7 +971,6 @@ rb_ndtypes_wrap_ndt_object(void)
979
971
  return WRAP_NDT(cNDTypes, ndt_p);
980
972
  }
981
973
 
982
- /* Get pointer to the internal ndt_t object from the NDTypes Ruby object ndt. */
983
974
  const ndt_t *
984
975
  rb_ndtypes_const_ndt(VALUE ndt)
985
976
  {
@@ -994,11 +985,6 @@ rb_ndtypes_const_ndt(VALUE ndt)
994
985
  return ndt_p->ndt;
995
986
  }
996
987
 
997
- /* Function for taking a source type and moving it accross the subtree.
998
-
999
- @param src NDTypes Ruby object of the source XND object.
1000
- @param t Pointer to type of the view of XND object.
1001
- */
1002
988
  VALUE
1003
989
  rb_ndtypes_move_subtree(VALUE src, ndt_t *t)
1004
990
  {
@@ -1021,11 +1007,6 @@ rb_ndtypes_move_subtree(VALUE src, ndt_t *t)
1021
1007
  return dest;
1022
1008
  }
1023
1009
 
1024
- /* Create NDT object from String. Returns the same object if type is NDT.
1025
-
1026
- @param type String object containing description of type.
1027
- @return New NDT object.
1028
- */
1029
1010
  VALUE
1030
1011
  rb_ndtypes_from_object(VALUE type)
1031
1012
  {
@@ -1073,7 +1054,6 @@ void Init_ruby_ndtypes(void)
1073
1054
 
1074
1055
  /* define classes */
1075
1056
  cNDTypes = rb_define_class("NDTypes", rb_cObject);
1076
- cNDTypes_RBuf = rb_define_class_under(cNDTypes, "RBuf", rb_cObject);
1077
1057
  mNDTypes_GCGuard = rb_define_module_under(cNDTypes, "GCGuard");
1078
1058
 
1079
1059
  /* errors */
@@ -18,14 +18,104 @@ extern "C" {
18
18
  typedef struct NdtObject NdtObject;
19
19
  extern VALUE cNDTypes;
20
20
 
21
+ /**
22
+ * @brief Return 1 if obj is of type NDTypes. 0 otherwise.
23
+ *
24
+ * @param obj Ruby object whose type has to be checked.
25
+ *
26
+ * @return Boolean value whether it is NDT object or not.
27
+ */
28
+
21
29
  int rb_ndtypes_check_type(VALUE obj);
30
+
31
+ /**
32
+ * @brief Get a pointer to the NdtObject struct that obj contains.
33
+ *
34
+ * @details This function unwraps the Ruby object obj passed to it and
35
+ * returns a pointer to the `NdtObject` struct that is contained within it.
36
+ * You must passed an NDT Ruby object.
37
+ *
38
+ * @param obj Ruby object of type NDT.
39
+ *
40
+ * @return Pointer to the NdtObject encapsulated within the Ruby object.
41
+ */
22
42
  NdtObject * rb_ndtypes_get_ndt_object(VALUE obj);
43
+
44
+ /**
45
+ * @brief Calls TypedData_Make_Struct and returns a Ruby object wrapping over ndt_p.
46
+ *
47
+ * @details This function calls the TypedData_Make_Struct macro from the Ruby
48
+ * C API for wrapping over argument passed to it. The ndt_p pointer must be allocated
49
+ * and data assingned to its contents before calling this function.
50
+ *
51
+ * @param ndt_p Pointer to NdtObject allocated by the caller.
52
+ *
53
+ * @return Ruby object wrapping over NdtObject.
54
+ */
23
55
  VALUE rb_ndtypes_make_ndt_object(NdtObject *ndt_p);
56
+
57
+ /**
58
+ * @brief Perform allocation using TypedData_Wrap_Struct and return a Ruby NDT object.
59
+ *
60
+ * @details This function does not set any of the data within the struct and assigns
61
+ * the NdtObject struct within the Ruby object to NULL. For allocating an already allocated
62
+ * NdtObject within a Ruby object use the rb_ndtypes_make_ndt_object() function.
63
+ *
64
+ * @return NDT Ruby object.
65
+ */
24
66
  VALUE rb_ndtypes_wrap_ndt_object(void);
67
+
68
+ /**
69
+ * @brief Unwrap the Ruby object ndt and return the pointer to ndt_t placed within it.
70
+ *
71
+ * @param ndt Ruby NDT object.
72
+ *
73
+ * @return Pointer to ndt_t type wrapped within the passed Ruby object.
74
+ */
25
75
  const ndt_t * rb_ndtypes_const_ndt(VALUE ndt);
76
+
77
+ /**
78
+ * @brief Function for taking a source type and moving it across the subtree.
79
+ *
80
+ * @param src NDTypes Ruby object of the source XND object.
81
+ * @param t Pointer to type of the view of XND object.
82
+ *
83
+ * @return NDT Ruby object of the moved subtree.
84
+ */
26
85
  VALUE rb_ndtypes_move_subtree(VALUE src, ndt_t *t);
86
+
87
+ /**
88
+ * @brief Create NDT object from Ruby String. Returns the same object if type is NDT.
89
+ * If you pass a String as an argument, read the string and create an NDT from it.
90
+ *
91
+ * @param type Ruby object. Can be Ruby String or NDT object.
92
+ *
93
+ * @return Ruby object of type NDT.
94
+ */
27
95
  VALUE rb_ndtypes_from_object(VALUE type);
96
+
97
+ /**
98
+ * @brief Make Ruby aware of the error condition raised by libndtypes by using
99
+ * the set_error_info() Ruby C API function.
100
+ *
101
+ * @param ctx Struct of type ndt_context_t.
102
+ *
103
+ * @return Ruby error class object.
104
+ */
105
+
28
106
  VALUE rb_ndtypes_set_error(ndt_context_t *ctx);
107
+
108
+ /**
109
+ * @brief Create an NDT Ruby object from an ndt_t struct.
110
+ *
111
+ * @details The caller can use this function for creating a Ruby NDT
112
+ * object from a ndt_t struct that has already been allocated using one
113
+ * of the allocation functions from libndtypes like ndt_from_string().
114
+ *
115
+ * @param type An allocated pointer to a struct of type ndt_t.
116
+ *
117
+ * @return Ruby object of type NDT.
118
+ */
29
119
  VALUE rb_ndtypes_from_type(const ndt_t *type);
30
120
 
31
121
  #define INT2BOOL(t) (t ? Qtrue : Qfalse)