chinwag 0.1.3 → 0.1.4
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/chinwag/dict.c +36 -0
- data/ext/chinwag/dict.h +2 -0
- data/ext/chinwag/rb_chinwag_ext.c +26 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f0421f5eac7d74cc245e8367a8d9a7421e7fa0c
|
4
|
+
data.tar.gz: ed3cdf1bfa20276ccadff4aa09fb525426238f25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c5b7acd628a6d89f1b44796a9ef15fb93f9cf8f7bf8f45bf20c35051e1a61f1f171ef7c17916ca5ce5d520f477c949fa80c15af91e5d86e3922a62c2db69d76
|
7
|
+
data.tar.gz: c2ecfd82373f4edcfbeb5d787d393c040ec391ed77d40681a2f44111e576c9966d5728aa80585cc7aa71f59b5b1a267feda85c4ac1943dcf0ea53d4374cd94a4
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ Rake::ExtensionTask.new "chinwag" do |ext|
|
|
8
8
|
ext.lib_dir = "lib/chinwag"
|
9
9
|
end
|
10
10
|
|
11
|
-
s = Gem::Specification.new "chinwag", "0.1.
|
11
|
+
s = Gem::Specification.new "chinwag", "0.1.4" do |s|
|
12
12
|
s.authors = ["Chris Calo"]
|
13
13
|
s.email = ["ccalo@vulcanca.com"]
|
14
14
|
s.summary = "A text-synthesis library, for use in layout testing (and more)."
|
data/ext/chinwag/dict.c
CHANGED
@@ -475,6 +475,42 @@ bool dict_valid(dict_t dict, char** error)
|
|
475
475
|
return true;
|
476
476
|
}
|
477
477
|
|
478
|
+
bool dict_equal(dict_t dict, dict_t against)
|
479
|
+
{
|
480
|
+
if(dict.count != against.count) return false;
|
481
|
+
|
482
|
+
for(U32 i = 0; i != dict.count; ++i)
|
483
|
+
{
|
484
|
+
if(dict.drows[i].count != against.drows[i].count) return false;
|
485
|
+
|
486
|
+
for(U32 j = 0; j != dict.drows[i].count; ++j)
|
487
|
+
{
|
488
|
+
if(strcmp(dict.drows[i].words[j], against.drows[i].words[j]) != 0)
|
489
|
+
return false;
|
490
|
+
}
|
491
|
+
}
|
492
|
+
|
493
|
+
return true;
|
494
|
+
}
|
495
|
+
|
496
|
+
bool dict_not_equal(dict_t dict, dict_t against)
|
497
|
+
{
|
498
|
+
if(dict.count != against.count) return true;
|
499
|
+
|
500
|
+
for(U32 i = 0; i != dict.count; ++i)
|
501
|
+
{
|
502
|
+
if(dict.drows[i].count != against.drows[i].count) return true;
|
503
|
+
|
504
|
+
for(U32 j = 0; j != dict.drows[i].count; ++j)
|
505
|
+
{
|
506
|
+
if(strcmp(dict.drows[i].words[j], against.drows[i].words[j]) != 0)
|
507
|
+
return true;
|
508
|
+
}
|
509
|
+
}
|
510
|
+
|
511
|
+
return false;
|
512
|
+
}
|
513
|
+
|
478
514
|
I32 find_drow_of_size_in_dict(dict_t dict, U32 largest)
|
479
515
|
{
|
480
516
|
// sort dict if necessary
|
data/ext/chinwag/dict.h
CHANGED
@@ -35,6 +35,8 @@ bool dict_exclude(dict_t dict, char const* str);
|
|
35
35
|
bool dict_include(dict_t dict, char const* str);
|
36
36
|
bool dict_any_blanks(dict_t dict);
|
37
37
|
bool dict_valid(dict_t dict, char** error);
|
38
|
+
bool dict_equal(dict_t dict, dict_t against);
|
39
|
+
bool dict_not_equal(dict_t dict, dict_t against);
|
38
40
|
I32 find_drow_of_size_in_dict(dict_t dict, U32 largest);
|
39
41
|
U32 total_dict(dict_t dict);
|
40
42
|
U32 dict_largest(dict_t dict);
|
@@ -722,6 +722,30 @@ VALUE c_cw_dict_add_assign_op(VALUE obj, VALUE addend)
|
|
722
722
|
return c_cw_dict_append_op(obj, addend);
|
723
723
|
}
|
724
724
|
|
725
|
+
VALUE c_cw_dict_check_equality(VALUE obj, VALUE against)
|
726
|
+
{
|
727
|
+
dict_t* d, *comparison;
|
728
|
+
|
729
|
+
// get original pointers from Ruby VM
|
730
|
+
Data_Get_Struct(obj, dict_t, d);
|
731
|
+
Data_Get_Struct(against, dict_t, comparison);
|
732
|
+
|
733
|
+
if(dict_equal(*d, *comparison)) return Qtrue;
|
734
|
+
return Qfalse;
|
735
|
+
}
|
736
|
+
|
737
|
+
VALUE c_cw_dict_check_inequality(VALUE obj, VALUE against)
|
738
|
+
{
|
739
|
+
dict_t* d, *comparison;
|
740
|
+
|
741
|
+
// get original pointers from Ruby VM
|
742
|
+
Data_Get_Struct(obj, dict_t, d);
|
743
|
+
Data_Get_Struct(against, dict_t, comparison);
|
744
|
+
|
745
|
+
if(dict_not_equal(*d, *comparison)) return Qtrue;
|
746
|
+
return Qfalse;
|
747
|
+
}
|
748
|
+
|
725
749
|
void Init_chinwag()
|
726
750
|
{
|
727
751
|
// setup module extension and containing class(es)
|
@@ -769,8 +793,8 @@ void Init_chinwag()
|
|
769
793
|
rb_define_method(c_cw_dict, "+", c_cw_dict_add_op, 1);
|
770
794
|
rb_define_method(c_cw_dict, "+=", c_cw_dict_add_assign_op, 1);
|
771
795
|
rb_define_method(c_cw_dict, "<<", c_cw_dict_append_op, 1);
|
772
|
-
|
773
|
-
|
796
|
+
rb_define_method(c_cw_dict, "==", c_cw_dict_check_equality, 1);
|
797
|
+
rb_define_method(c_cw_dict, "!=", c_cw_dict_check_inequality, 1);
|
774
798
|
|
775
799
|
// method aliases
|
776
800
|
rb_define_alias(c_cw_dict, "dup", "clone");
|