[svn:parrot] r36255 - in trunk: include/parrot src src/ops src/pmc t/oo
allison at svn.parrot.org
allison at svn.parrot.org
Sun Feb 1 20:26:11 UTC 2009
Author: allison
Date: Sun Feb 1 20:26:10 2009
New Revision: 36255
URL: https://trac.parrot.org/parrot/changeset/36255
Log:
[cage] Apply patch to implement 'remove_parent' (with updates for API changes),
resolving RT #50646. Remove unneeded function 'Parrot_remove_parent'. Implement
'remove_attribute' vtable function on Class PMC and call from 'removeattribute'
op. Add tests for removing parents and removing attributes. Resolves RT #43423.
Added:
trunk/t/oo/attributes.t
trunk/t/oo/inheritance.t
Modified:
trunk/include/parrot/oo.h
trunk/src/oo.c
trunk/src/ops/object.ops
trunk/src/ops/ops.num
trunk/src/pmc/class.pmc
Modified: trunk/include/parrot/oo.h
==============================================================================
--- trunk/include/parrot/oo.h Sun Feb 1 20:10:05 2009 (r36254)
+++ trunk/include/parrot/oo.h Sun Feb 1 20:26:10 2009 (r36255)
@@ -128,16 +128,6 @@
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-PARROT_EXPORT
-PARROT_IGNORABLE_RESULT
-PARROT_CAN_RETURN_NULL
-PMC * Parrot_remove_parent(PARROT_INTERP,
- ARGIN(PMC *removed_class),
- ARGIN(PMC *existing_class))
- __attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3);
-
void destroy_object_cache(PARROT_INTERP)
__attribute__nonnull__(1);
@@ -222,10 +212,6 @@
#define ASSERT_ARGS_Parrot_oo_get_class_str __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp) \
|| PARROT_ASSERT_ARG(name)
-#define ASSERT_ARGS_Parrot_remove_parent __attribute__unused__ int _ASSERT_ARGS_CHECK = \
- PARROT_ASSERT_ARG(interp) \
- || PARROT_ASSERT_ARG(removed_class) \
- || PARROT_ASSERT_ARG(existing_class)
#define ASSERT_ARGS_destroy_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(interp)
#define ASSERT_ARGS_init_object_cache __attribute__unused__ int _ASSERT_ARGS_CHECK = \
Modified: trunk/src/oo.c
==============================================================================
--- trunk/src/oo.c Sun Feb 1 20:10:05 2009 (r36254)
+++ trunk/src/oo.c Sun Feb 1 20:26:10 2009 (r36255)
@@ -558,33 +558,6 @@
/*
-=item C<PMC * Parrot_remove_parent>
-
-This currently does nothing but return C<PMCNULL>.
-RT #50646
-
-=cut
-
-*/
-
-PARROT_EXPORT
-PARROT_IGNORABLE_RESULT
-PARROT_CAN_RETURN_NULL
-PMC *
-Parrot_remove_parent(PARROT_INTERP, ARGIN(PMC *removed_class),
- ARGIN(PMC *existing_class))
-{
- ASSERT_ARGS(Parrot_remove_parent)
- UNUSED(interp);
- UNUSED(removed_class);
- UNUSED(existing_class);
-
- return PMCNULL;
-}
-
-
-/*
-
=item C<void mark_object_cache>
Marks all PMCs in the object method cache as live. This shouldn't strictly be
Modified: trunk/src/ops/object.ops
==============================================================================
--- trunk/src/ops/object.ops Sun Feb 1 20:10:05 2009 (r36254)
+++ trunk/src/ops/object.ops Sun Feb 1 20:26:10 2009 (r36255)
@@ -422,7 +422,7 @@
=cut
inline op removeparent(invar PMC, invar PMC) :object_classes {
- Parrot_remove_parent(interp, $2, $1);
+ VTABLE_remove_parent(interp, $1, $2);
}
=item B<addrole>(invar PMC, invar PMC)
@@ -457,20 +457,12 @@
=item B<removeattribute>(invar PMC, in STR) B<(unimplemented)>
-=item B<removeattribute>(invar PMC, in INT) B<(unimplemented)>
-
-Remove attribute $2 from class $1, specified either by name or offset.
+Remove attribute $2 from class $1, specified by name.
=cut
-op removeattribute(invar PMC, in STR) :flow {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
- "removeattribute is not implemented");
-}
-
-op removeattribute(invar PMC, in INT) :flow {
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
- "removeattribute is not implemented");
+op removeattribute(invar PMC, in STR) :object_classes {
+ VTABLE_remove_attribute(interp, $1, $2);
}
=item B<getattribute>(out PMC, invar PMC, in STR)
Modified: trunk/src/ops/ops.num
==============================================================================
--- trunk/src/ops/ops.num Sun Feb 1 20:10:05 2009 (r36254)
+++ trunk/src/ops/ops.num Sun Feb 1 20:26:10 2009 (r36255)
@@ -784,478 +784,476 @@
addattribute_p_sc 754
removeattribute_p_s 755
removeattribute_p_sc 756
-removeattribute_p_i 757
-removeattribute_p_ic 758
-getattribute_p_p_s 759
-getattribute_p_p_sc 760
-getattribute_p_p_p_s 761
-getattribute_p_p_pc_s 762
-getattribute_p_p_p_sc 763
-getattribute_p_p_pc_sc 764
-setattribute_p_s_p 765
-setattribute_p_sc_p 766
-setattribute_p_p_s_p 767
-setattribute_p_pc_s_p 768
-setattribute_p_p_sc_p 769
-setattribute_p_pc_sc_p 770
-inspect_p_p 771
-inspect_p_pc 772
-inspect_p_p_s 773
-inspect_p_pc_s 774
-inspect_p_p_sc 775
-inspect_p_pc_sc 776
-pic_infix___ic_p_p 777
-pic_inline_sub___ic_p_p 778
-pic_get_params___pc 779
-pic_set_returns___pc 780
-pic_callr___pc 781
-new_p_s 782
-new_p_sc 783
-new_p_s_p 784
-new_p_sc_p 785
-new_p_s_pc 786
-new_p_sc_pc 787
-new_p_p 788
-new_p_pc 789
-new_p_p_p 790
-new_p_pc_p 791
-new_p_p_pc 792
-new_p_pc_pc 793
-typeof_s_p 794
-typeof_p_p 795
-get_repr_s_p 796
-find_method_p_p_s 797
-find_method_p_p_sc 798
-defined_i_p 799
-defined_i_p_ki 800
-defined_i_p_kic 801
-defined_i_p_k 802
-defined_i_p_kc 803
-exists_i_p_ki 804
-exists_i_p_kic 805
-exists_i_p_k 806
-exists_i_p_kc 807
-delete_p_k 808
-delete_p_kc 809
-delete_p_ki 810
-delete_p_kic 811
-elements_i_p 812
-push_p_i 813
-push_p_ic 814
-push_p_n 815
-push_p_nc 816
-push_p_s 817
-push_p_sc 818
-push_p_p 819
-pop_i_p 820
-pop_n_p 821
-pop_s_p 822
-pop_p_p 823
-unshift_p_i 824
-unshift_p_ic 825
-unshift_p_n 826
-unshift_p_nc 827
-unshift_p_s 828
-unshift_p_sc 829
-unshift_p_p 830
-shift_i_p 831
-shift_n_p 832
-shift_s_p 833
-shift_p_p 834
-setprop_p_s_p 835
-setprop_p_sc_p 836
-getprop_p_s_p 837
-getprop_p_sc_p 838
-delprop_p_s 839
-delprop_p_sc 840
-prophash_p_p 841
-freeze_s_p 842
-thaw_p_s 843
-thaw_p_sc 844
-add_multi_s_s_p 845
-add_multi_sc_s_p 846
-add_multi_s_sc_p 847
-add_multi_sc_sc_p 848
-find_multi_p_s_s 849
-find_multi_p_sc_s 850
-find_multi_p_s_sc 851
-find_multi_p_sc_sc 852
-register_p 853
-unregister_p 854
-box_p_i 855
-box_p_ic 856
-box_p_n 857
-box_p_nc 858
-box_p_s 859
-box_p_sc 860
-clone_s_s 861
-clone_s_sc 862
-exchange_i_i 863
-exchange_p_p 864
-exchange_n_n 865
-exchange_s_s 866
-set_i_i 867
-set_i_ic 868
-set_i_n 869
-set_i_nc 870
-set_i_s 871
-set_i_sc 872
-set_n_n 873
-set_n_nc 874
-set_n_i 875
-set_n_ic 876
-set_n_s 877
-set_n_sc 878
-set_n_p 879
-set_s_p 880
-set_s_s 881
-set_s_sc 882
-set_s_i 883
-set_s_ic 884
-set_s_n 885
-set_s_nc 886
-set_p_pc 887
-set_p_p 888
-set_p_i 889
-set_p_ic 890
-set_p_n 891
-set_p_nc 892
-set_p_s 893
-set_p_sc 894
-set_i_p 895
-assign_p_p 896
-assign_p_i 897
-assign_p_ic 898
-assign_p_n 899
-assign_p_nc 900
-assign_p_s 901
-assign_p_sc 902
-assign_s_s 903
-assign_s_sc 904
-setref_p_p 905
-deref_p_p 906
-setp_ind_i_p 907
-setp_ind_ic_p 908
-setn_ind_i_n 909
-setn_ind_ic_n 910
-setn_ind_i_nc 911
-setn_ind_ic_nc 912
-sets_ind_i_s 913
-sets_ind_ic_s 914
-sets_ind_i_sc 915
-sets_ind_ic_sc 916
-seti_ind_i_i 917
-seti_ind_ic_i 918
-seti_ind_i_ic 919
-seti_ind_ic_ic 920
-set_p_ki_i 921
-set_p_kic_i 922
-set_p_ki_ic 923
-set_p_kic_ic 924
-set_p_ki_n 925
-set_p_kic_n 926
-set_p_ki_nc 927
-set_p_kic_nc 928
-set_p_ki_s 929
-set_p_kic_s 930
-set_p_ki_sc 931
-set_p_kic_sc 932
-set_p_ki_p 933
-set_p_kic_p 934
-set_i_p_ki 935
-set_i_p_kic 936
-set_n_p_ki 937
-set_n_p_kic 938
-set_s_p_ki 939
-set_s_p_kic 940
-set_p_p_ki 941
-set_p_p_kic 942
-set_p_k_i 943
-set_p_kc_i 944
-set_p_k_ic 945
-set_p_kc_ic 946
-set_p_k_n 947
-set_p_kc_n 948
-set_p_k_nc 949
-set_p_kc_nc 950
-set_p_k_s 951
-set_p_kc_s 952
-set_p_k_sc 953
-set_p_kc_sc 954
-set_p_k_p 955
-set_p_kc_p 956
-set_i_p_k 957
-set_i_p_kc 958
-set_n_p_k 959
-set_n_p_kc 960
-set_s_p_k 961
-set_s_p_kc 962
-set_p_p_k 963
-set_p_p_kc 964
-clone_p_p 965
-clone_p_p_p 966
-clone_p_p_pc 967
-copy_p_p 968
-null_s 969
-null_i 970
-null_p 971
-null_n 972
-cleari 973
-clearn 974
-clears 975
-clearp 976
-ord_i_s 977
-ord_i_sc 978
-ord_i_s_i 979
-ord_i_sc_i 980
-ord_i_s_ic 981
-ord_i_sc_ic 982
-chr_s_i 983
-chr_s_ic 984
-chopn_s_i 985
-chopn_s_ic 986
-chopn_s_s_i 987
-chopn_s_sc_i 988
-chopn_s_s_ic 989
-chopn_s_sc_ic 990
-concat_s_s 991
-concat_s_sc 992
-concat_p_p 993
-concat_p_s 994
-concat_p_sc 995
-concat_s_s_s 996
-concat_s_sc_s 997
-concat_s_s_sc 998
-concat_p_p_s 999
-concat_p_p_sc 1000
-concat_p_p_p 1001
-repeat_s_s_i 1002
-repeat_s_sc_i 1003
-repeat_s_s_ic 1004
-repeat_s_sc_ic 1005
-repeat_p_p_i 1006
-repeat_p_p_ic 1007
-repeat_p_p_p 1008
-repeat_p_i 1009
-repeat_p_ic 1010
-repeat_p_p 1011
-length_i_s 1012
-length_i_sc 1013
-bytelength_i_s 1014
-bytelength_i_sc 1015
-pin_s 1016
-unpin_s 1017
-substr_s_s_i 1018
-substr_s_sc_i 1019
-substr_s_s_ic 1020
-substr_s_sc_ic 1021
-substr_s_s_i_i 1022
-substr_s_sc_i_i 1023
-substr_s_s_ic_i 1024
-substr_s_sc_ic_i 1025
-substr_s_s_i_ic 1026
-substr_s_sc_i_ic 1027
-substr_s_s_ic_ic 1028
-substr_s_sc_ic_ic 1029
-substr_s_s_i_i_s 1030
-substr_s_s_ic_i_s 1031
-substr_s_s_i_ic_s 1032
-substr_s_s_ic_ic_s 1033
-substr_s_s_i_i_sc 1034
-substr_s_s_ic_i_sc 1035
-substr_s_s_i_ic_sc 1036
-substr_s_s_ic_ic_sc 1037
-substr_s_i_i_s 1038
-substr_s_ic_i_s 1039
-substr_s_i_ic_s 1040
-substr_s_ic_ic_s 1041
-substr_s_i_i_sc 1042
-substr_s_ic_i_sc 1043
-substr_s_i_ic_sc 1044
-substr_s_ic_ic_sc 1045
-substr_s_p_i_i 1046
-substr_s_p_ic_i 1047
-substr_s_p_i_ic 1048
-substr_s_p_ic_ic 1049
-index_i_s_s 1050
-index_i_sc_s 1051
-index_i_s_sc 1052
-index_i_sc_sc 1053
-index_i_s_s_i 1054
-index_i_sc_s_i 1055
-index_i_s_sc_i 1056
-index_i_sc_sc_i 1057
-index_i_s_s_ic 1058
-index_i_sc_s_ic 1059
-index_i_s_sc_ic 1060
-index_i_sc_sc_ic 1061
-sprintf_s_s_p 1062
-sprintf_s_sc_p 1063
-sprintf_p_p_p 1064
-new_s 1065
-new_s_i 1066
-new_s_ic 1067
-stringinfo_i_s_i 1068
-stringinfo_i_sc_i 1069
-stringinfo_i_s_ic 1070
-stringinfo_i_sc_ic 1071
-upcase_s_s 1072
-upcase_s_sc 1073
-upcase_s 1074
-downcase_s_s 1075
-downcase_s_sc 1076
-downcase_s 1077
-titlecase_s_s 1078
-titlecase_s_sc 1079
-titlecase_s 1080
-join_s_s_p 1081
-join_s_sc_p 1082
-split_p_s_s 1083
-split_p_sc_s 1084
-split_p_s_sc 1085
-split_p_sc_sc 1086
-charset_i_s 1087
-charset_i_sc 1088
-charsetname_s_i 1089
-charsetname_s_ic 1090
-find_charset_i_s 1091
-find_charset_i_sc 1092
-trans_charset_s_i 1093
-trans_charset_s_ic 1094
-trans_charset_s_s_i 1095
-trans_charset_s_sc_i 1096
-trans_charset_s_s_ic 1097
-trans_charset_s_sc_ic 1098
-encoding_i_s 1099
-encoding_i_sc 1100
-encodingname_s_i 1101
-encodingname_s_ic 1102
-find_encoding_i_s 1103
-find_encoding_i_sc 1104
-trans_encoding_s_i 1105
-trans_encoding_s_ic 1106
-trans_encoding_s_s_i 1107
-trans_encoding_s_sc_i 1108
-trans_encoding_s_s_ic 1109
-trans_encoding_s_sc_ic 1110
-is_cclass_i_i_s_i 1111
-is_cclass_i_ic_s_i 1112
-is_cclass_i_i_sc_i 1113
-is_cclass_i_ic_sc_i 1114
-is_cclass_i_i_s_ic 1115
-is_cclass_i_ic_s_ic 1116
-is_cclass_i_i_sc_ic 1117
-is_cclass_i_ic_sc_ic 1118
-find_cclass_i_i_s_i_i 1119
-find_cclass_i_ic_s_i_i 1120
-find_cclass_i_i_sc_i_i 1121
-find_cclass_i_ic_sc_i_i 1122
-find_cclass_i_i_s_ic_i 1123
-find_cclass_i_ic_s_ic_i 1124
-find_cclass_i_i_sc_ic_i 1125
-find_cclass_i_ic_sc_ic_i 1126
-find_cclass_i_i_s_i_ic 1127
-find_cclass_i_ic_s_i_ic 1128
-find_cclass_i_i_sc_i_ic 1129
-find_cclass_i_ic_sc_i_ic 1130
-find_cclass_i_i_s_ic_ic 1131
-find_cclass_i_ic_s_ic_ic 1132
-find_cclass_i_i_sc_ic_ic 1133
-find_cclass_i_ic_sc_ic_ic 1134
-find_not_cclass_i_i_s_i_i 1135
-find_not_cclass_i_ic_s_i_i 1136
-find_not_cclass_i_i_sc_i_i 1137
-find_not_cclass_i_ic_sc_i_i 1138
-find_not_cclass_i_i_s_ic_i 1139
-find_not_cclass_i_ic_s_ic_i 1140
-find_not_cclass_i_i_sc_ic_i 1141
-find_not_cclass_i_ic_sc_ic_i 1142
-find_not_cclass_i_i_s_i_ic 1143
-find_not_cclass_i_ic_s_i_ic 1144
-find_not_cclass_i_i_sc_i_ic 1145
-find_not_cclass_i_ic_sc_i_ic 1146
-find_not_cclass_i_i_s_ic_ic 1147
-find_not_cclass_i_ic_s_ic_ic 1148
-find_not_cclass_i_i_sc_ic_ic 1149
-find_not_cclass_i_ic_sc_ic_ic 1150
-escape_s_s 1151
-compose_s_s 1152
-compose_s_sc 1153
-spawnw_i_s 1154
-spawnw_i_sc 1155
-spawnw_i_p 1156
-err_i 1157
-err_s 1158
-err_s_i 1159
-err_s_ic 1160
-time_i 1161
-time_n 1162
-gmtime_s_i 1163
-gmtime_s_ic 1164
-localtime_s_i 1165
-localtime_s_ic 1166
-decodetime_p_i 1167
-decodetime_p_ic 1168
-decodelocaltime_p_i 1169
-decodelocaltime_p_ic 1170
-sysinfo_s_i 1171
-sysinfo_s_ic 1172
-sysinfo_i_i 1173
-sysinfo_i_ic 1174
-sleep_i 1175
-sleep_ic 1176
-sleep_n 1177
-sleep_nc 1178
-sizeof_i_i 1179
-sizeof_i_ic 1180
-store_lex_s_p 1181
-store_lex_sc_p 1182
-find_lex_p_s 1183
-find_lex_p_sc 1184
-get_namespace_p 1185
-get_namespace_p_p 1186
-get_namespace_p_pc 1187
-get_hll_namespace_p 1188
-get_hll_namespace_p_p 1189
-get_hll_namespace_p_pc 1190
-get_root_namespace_p 1191
-get_root_namespace_p_p 1192
-get_root_namespace_p_pc 1193
-get_global_p_s 1194
-get_global_p_sc 1195
-get_global_p_p_s 1196
-get_global_p_pc_s 1197
-get_global_p_p_sc 1198
-get_global_p_pc_sc 1199
-get_hll_global_p_s 1200
-get_hll_global_p_sc 1201
-get_hll_global_p_p_s 1202
-get_hll_global_p_pc_s 1203
-get_hll_global_p_p_sc 1204
-get_hll_global_p_pc_sc 1205
-get_root_global_p_s 1206
-get_root_global_p_sc 1207
-get_root_global_p_p_s 1208
-get_root_global_p_pc_s 1209
-get_root_global_p_p_sc 1210
-get_root_global_p_pc_sc 1211
-set_global_s_p 1212
-set_global_sc_p 1213
-set_global_p_s_p 1214
-set_global_pc_s_p 1215
-set_global_p_sc_p 1216
-set_global_pc_sc_p 1217
-set_hll_global_s_p 1218
-set_hll_global_sc_p 1219
-set_hll_global_p_s_p 1220
-set_hll_global_pc_s_p 1221
-set_hll_global_p_sc_p 1222
-set_hll_global_pc_sc_p 1223
-set_root_global_s_p 1224
-set_root_global_sc_p 1225
-set_root_global_p_s_p 1226
-set_root_global_pc_s_p 1227
-set_root_global_p_sc_p 1228
-set_root_global_pc_sc_p 1229
-find_name_p_s 1230
-find_name_p_sc 1231
+getattribute_p_p_s 757
+getattribute_p_p_sc 758
+getattribute_p_p_p_s 759
+getattribute_p_p_pc_s 760
+getattribute_p_p_p_sc 761
+getattribute_p_p_pc_sc 762
+setattribute_p_s_p 763
+setattribute_p_sc_p 764
+setattribute_p_p_s_p 765
+setattribute_p_pc_s_p 766
+setattribute_p_p_sc_p 767
+setattribute_p_pc_sc_p 768
+inspect_p_p 769
+inspect_p_pc 770
+inspect_p_p_s 771
+inspect_p_pc_s 772
+inspect_p_p_sc 773
+inspect_p_pc_sc 774
+pic_infix___ic_p_p 775
+pic_inline_sub___ic_p_p 776
+pic_get_params___pc 777
+pic_set_returns___pc 778
+pic_callr___pc 779
+new_p_s 780
+new_p_sc 781
+new_p_s_p 782
+new_p_sc_p 783
+new_p_s_pc 784
+new_p_sc_pc 785
+new_p_p 786
+new_p_pc 787
+new_p_p_p 788
+new_p_pc_p 789
+new_p_p_pc 790
+new_p_pc_pc 791
+typeof_s_p 792
+typeof_p_p 793
+get_repr_s_p 794
+find_method_p_p_s 795
+find_method_p_p_sc 796
+defined_i_p 797
+defined_i_p_ki 798
+defined_i_p_kic 799
+defined_i_p_k 800
+defined_i_p_kc 801
+exists_i_p_ki 802
+exists_i_p_kic 803
+exists_i_p_k 804
+exists_i_p_kc 805
+delete_p_k 806
+delete_p_kc 807
+delete_p_ki 808
+delete_p_kic 809
+elements_i_p 810
+push_p_i 811
+push_p_ic 812
+push_p_n 813
+push_p_nc 814
+push_p_s 815
+push_p_sc 816
+push_p_p 817
+pop_i_p 818
+pop_n_p 819
+pop_s_p 820
+pop_p_p 821
+unshift_p_i 822
+unshift_p_ic 823
+unshift_p_n 824
+unshift_p_nc 825
+unshift_p_s 826
+unshift_p_sc 827
+unshift_p_p 828
+shift_i_p 829
+shift_n_p 830
+shift_s_p 831
+shift_p_p 832
+setprop_p_s_p 833
+setprop_p_sc_p 834
+getprop_p_s_p 835
+getprop_p_sc_p 836
+delprop_p_s 837
+delprop_p_sc 838
+prophash_p_p 839
+freeze_s_p 840
+thaw_p_s 841
+thaw_p_sc 842
+add_multi_s_s_p 843
+add_multi_sc_s_p 844
+add_multi_s_sc_p 845
+add_multi_sc_sc_p 846
+find_multi_p_s_s 847
+find_multi_p_sc_s 848
+find_multi_p_s_sc 849
+find_multi_p_sc_sc 850
+register_p 851
+unregister_p 852
+box_p_i 853
+box_p_ic 854
+box_p_n 855
+box_p_nc 856
+box_p_s 857
+box_p_sc 858
+clone_s_s 859
+clone_s_sc 860
+exchange_i_i 861
+exchange_p_p 862
+exchange_n_n 863
+exchange_s_s 864
+set_i_i 865
+set_i_ic 866
+set_i_n 867
+set_i_nc 868
+set_i_s 869
+set_i_sc 870
+set_n_n 871
+set_n_nc 872
+set_n_i 873
+set_n_ic 874
+set_n_s 875
+set_n_sc 876
+set_n_p 877
+set_s_p 878
+set_s_s 879
+set_s_sc 880
+set_s_i 881
+set_s_ic 882
+set_s_n 883
+set_s_nc 884
+set_p_pc 885
+set_p_p 886
+set_p_i 887
+set_p_ic 888
+set_p_n 889
+set_p_nc 890
+set_p_s 891
+set_p_sc 892
+set_i_p 893
+assign_p_p 894
+assign_p_i 895
+assign_p_ic 896
+assign_p_n 897
+assign_p_nc 898
+assign_p_s 899
+assign_p_sc 900
+assign_s_s 901
+assign_s_sc 902
+setref_p_p 903
+deref_p_p 904
+setp_ind_i_p 905
+setp_ind_ic_p 906
+setn_ind_i_n 907
+setn_ind_ic_n 908
+setn_ind_i_nc 909
+setn_ind_ic_nc 910
+sets_ind_i_s 911
+sets_ind_ic_s 912
+sets_ind_i_sc 913
+sets_ind_ic_sc 914
+seti_ind_i_i 915
+seti_ind_ic_i 916
+seti_ind_i_ic 917
+seti_ind_ic_ic 918
+set_p_ki_i 919
+set_p_kic_i 920
+set_p_ki_ic 921
+set_p_kic_ic 922
+set_p_ki_n 923
+set_p_kic_n 924
+set_p_ki_nc 925
+set_p_kic_nc 926
+set_p_ki_s 927
+set_p_kic_s 928
+set_p_ki_sc 929
+set_p_kic_sc 930
+set_p_ki_p 931
+set_p_kic_p 932
+set_i_p_ki 933
+set_i_p_kic 934
+set_n_p_ki 935
+set_n_p_kic 936
+set_s_p_ki 937
+set_s_p_kic 938
+set_p_p_ki 939
+set_p_p_kic 940
+set_p_k_i 941
+set_p_kc_i 942
+set_p_k_ic 943
+set_p_kc_ic 944
+set_p_k_n 945
+set_p_kc_n 946
+set_p_k_nc 947
+set_p_kc_nc 948
+set_p_k_s 949
+set_p_kc_s 950
+set_p_k_sc 951
+set_p_kc_sc 952
+set_p_k_p 953
+set_p_kc_p 954
+set_i_p_k 955
+set_i_p_kc 956
+set_n_p_k 957
+set_n_p_kc 958
+set_s_p_k 959
+set_s_p_kc 960
+set_p_p_k 961
+set_p_p_kc 962
+clone_p_p 963
+clone_p_p_p 964
+clone_p_p_pc 965
+copy_p_p 966
+null_s 967
+null_i 968
+null_p 969
+null_n 970
+cleari 971
+clearn 972
+clears 973
+clearp 974
+ord_i_s 975
+ord_i_sc 976
+ord_i_s_i 977
+ord_i_sc_i 978
+ord_i_s_ic 979
+ord_i_sc_ic 980
+chr_s_i 981
+chr_s_ic 982
+chopn_s_i 983
+chopn_s_ic 984
+chopn_s_s_i 985
+chopn_s_sc_i 986
+chopn_s_s_ic 987
+chopn_s_sc_ic 988
+concat_s_s 989
+concat_s_sc 990
+concat_p_p 991
+concat_p_s 992
+concat_p_sc 993
+concat_s_s_s 994
+concat_s_sc_s 995
+concat_s_s_sc 996
+concat_p_p_s 997
+concat_p_p_sc 998
+concat_p_p_p 999
+repeat_s_s_i 1000
+repeat_s_sc_i 1001
+repeat_s_s_ic 1002
+repeat_s_sc_ic 1003
+repeat_p_p_i 1004
+repeat_p_p_ic 1005
+repeat_p_p_p 1006
+repeat_p_i 1007
+repeat_p_ic 1008
+repeat_p_p 1009
+length_i_s 1010
+length_i_sc 1011
+bytelength_i_s 1012
+bytelength_i_sc 1013
+pin_s 1014
+unpin_s 1015
+substr_s_s_i 1016
+substr_s_sc_i 1017
+substr_s_s_ic 1018
+substr_s_sc_ic 1019
+substr_s_s_i_i 1020
+substr_s_sc_i_i 1021
+substr_s_s_ic_i 1022
+substr_s_sc_ic_i 1023
+substr_s_s_i_ic 1024
+substr_s_sc_i_ic 1025
+substr_s_s_ic_ic 1026
+substr_s_sc_ic_ic 1027
+substr_s_s_i_i_s 1028
+substr_s_s_ic_i_s 1029
+substr_s_s_i_ic_s 1030
+substr_s_s_ic_ic_s 1031
+substr_s_s_i_i_sc 1032
+substr_s_s_ic_i_sc 1033
+substr_s_s_i_ic_sc 1034
+substr_s_s_ic_ic_sc 1035
+substr_s_i_i_s 1036
+substr_s_ic_i_s 1037
+substr_s_i_ic_s 1038
+substr_s_ic_ic_s 1039
+substr_s_i_i_sc 1040
+substr_s_ic_i_sc 1041
+substr_s_i_ic_sc 1042
+substr_s_ic_ic_sc 1043
+substr_s_p_i_i 1044
+substr_s_p_ic_i 1045
+substr_s_p_i_ic 1046
+substr_s_p_ic_ic 1047
+index_i_s_s 1048
+index_i_sc_s 1049
+index_i_s_sc 1050
+index_i_sc_sc 1051
+index_i_s_s_i 1052
+index_i_sc_s_i 1053
+index_i_s_sc_i 1054
+index_i_sc_sc_i 1055
+index_i_s_s_ic 1056
+index_i_sc_s_ic 1057
+index_i_s_sc_ic 1058
+index_i_sc_sc_ic 1059
+sprintf_s_s_p 1060
+sprintf_s_sc_p 1061
+sprintf_p_p_p 1062
+new_s 1063
+new_s_i 1064
+new_s_ic 1065
+stringinfo_i_s_i 1066
+stringinfo_i_sc_i 1067
+stringinfo_i_s_ic 1068
+stringinfo_i_sc_ic 1069
+upcase_s_s 1070
+upcase_s_sc 1071
+upcase_s 1072
+downcase_s_s 1073
+downcase_s_sc 1074
+downcase_s 1075
+titlecase_s_s 1076
+titlecase_s_sc 1077
+titlecase_s 1078
+join_s_s_p 1079
+join_s_sc_p 1080
+split_p_s_s 1081
+split_p_sc_s 1082
+split_p_s_sc 1083
+split_p_sc_sc 1084
+charset_i_s 1085
+charset_i_sc 1086
+charsetname_s_i 1087
+charsetname_s_ic 1088
+find_charset_i_s 1089
+find_charset_i_sc 1090
+trans_charset_s_i 1091
+trans_charset_s_ic 1092
+trans_charset_s_s_i 1093
+trans_charset_s_sc_i 1094
+trans_charset_s_s_ic 1095
+trans_charset_s_sc_ic 1096
+encoding_i_s 1097
+encoding_i_sc 1098
+encodingname_s_i 1099
+encodingname_s_ic 1100
+find_encoding_i_s 1101
+find_encoding_i_sc 1102
+trans_encoding_s_i 1103
+trans_encoding_s_ic 1104
+trans_encoding_s_s_i 1105
+trans_encoding_s_sc_i 1106
+trans_encoding_s_s_ic 1107
+trans_encoding_s_sc_ic 1108
+is_cclass_i_i_s_i 1109
+is_cclass_i_ic_s_i 1110
+is_cclass_i_i_sc_i 1111
+is_cclass_i_ic_sc_i 1112
+is_cclass_i_i_s_ic 1113
+is_cclass_i_ic_s_ic 1114
+is_cclass_i_i_sc_ic 1115
+is_cclass_i_ic_sc_ic 1116
+find_cclass_i_i_s_i_i 1117
+find_cclass_i_ic_s_i_i 1118
+find_cclass_i_i_sc_i_i 1119
+find_cclass_i_ic_sc_i_i 1120
+find_cclass_i_i_s_ic_i 1121
+find_cclass_i_ic_s_ic_i 1122
+find_cclass_i_i_sc_ic_i 1123
+find_cclass_i_ic_sc_ic_i 1124
+find_cclass_i_i_s_i_ic 1125
+find_cclass_i_ic_s_i_ic 1126
+find_cclass_i_i_sc_i_ic 1127
+find_cclass_i_ic_sc_i_ic 1128
+find_cclass_i_i_s_ic_ic 1129
+find_cclass_i_ic_s_ic_ic 1130
+find_cclass_i_i_sc_ic_ic 1131
+find_cclass_i_ic_sc_ic_ic 1132
+find_not_cclass_i_i_s_i_i 1133
+find_not_cclass_i_ic_s_i_i 1134
+find_not_cclass_i_i_sc_i_i 1135
+find_not_cclass_i_ic_sc_i_i 1136
+find_not_cclass_i_i_s_ic_i 1137
+find_not_cclass_i_ic_s_ic_i 1138
+find_not_cclass_i_i_sc_ic_i 1139
+find_not_cclass_i_ic_sc_ic_i 1140
+find_not_cclass_i_i_s_i_ic 1141
+find_not_cclass_i_ic_s_i_ic 1142
+find_not_cclass_i_i_sc_i_ic 1143
+find_not_cclass_i_ic_sc_i_ic 1144
+find_not_cclass_i_i_s_ic_ic 1145
+find_not_cclass_i_ic_s_ic_ic 1146
+find_not_cclass_i_i_sc_ic_ic 1147
+find_not_cclass_i_ic_sc_ic_ic 1148
+escape_s_s 1149
+compose_s_s 1150
+compose_s_sc 1151
+spawnw_i_s 1152
+spawnw_i_sc 1153
+spawnw_i_p 1154
+err_i 1155
+err_s 1156
+err_s_i 1157
+err_s_ic 1158
+time_i 1159
+time_n 1160
+gmtime_s_i 1161
+gmtime_s_ic 1162
+localtime_s_i 1163
+localtime_s_ic 1164
+decodetime_p_i 1165
+decodetime_p_ic 1166
+decodelocaltime_p_i 1167
+decodelocaltime_p_ic 1168
+sysinfo_s_i 1169
+sysinfo_s_ic 1170
+sysinfo_i_i 1171
+sysinfo_i_ic 1172
+sleep_i 1173
+sleep_ic 1174
+sleep_n 1175
+sleep_nc 1176
+sizeof_i_i 1177
+sizeof_i_ic 1178
+store_lex_s_p 1179
+store_lex_sc_p 1180
+find_lex_p_s 1181
+find_lex_p_sc 1182
+get_namespace_p 1183
+get_namespace_p_p 1184
+get_namespace_p_pc 1185
+get_hll_namespace_p 1186
+get_hll_namespace_p_p 1187
+get_hll_namespace_p_pc 1188
+get_root_namespace_p 1189
+get_root_namespace_p_p 1190
+get_root_namespace_p_pc 1191
+get_global_p_s 1192
+get_global_p_sc 1193
+get_global_p_p_s 1194
+get_global_p_pc_s 1195
+get_global_p_p_sc 1196
+get_global_p_pc_sc 1197
+get_hll_global_p_s 1198
+get_hll_global_p_sc 1199
+get_hll_global_p_p_s 1200
+get_hll_global_p_pc_s 1201
+get_hll_global_p_p_sc 1202
+get_hll_global_p_pc_sc 1203
+get_root_global_p_s 1204
+get_root_global_p_sc 1205
+get_root_global_p_p_s 1206
+get_root_global_p_pc_s 1207
+get_root_global_p_p_sc 1208
+get_root_global_p_pc_sc 1209
+set_global_s_p 1210
+set_global_sc_p 1211
+set_global_p_s_p 1212
+set_global_pc_s_p 1213
+set_global_p_sc_p 1214
+set_global_pc_sc_p 1215
+set_hll_global_s_p 1216
+set_hll_global_sc_p 1217
+set_hll_global_p_s_p 1218
+set_hll_global_pc_s_p 1219
+set_hll_global_p_sc_p 1220
+set_hll_global_pc_sc_p 1221
+set_root_global_s_p 1222
+set_root_global_sc_p 1223
+set_root_global_p_s_p 1224
+set_root_global_pc_s_p 1225
+set_root_global_p_sc_p 1226
+set_root_global_pc_sc_p 1227
+find_name_p_s 1228
+find_name_p_sc 1229
Modified: trunk/src/pmc/class.pmc
==============================================================================
--- trunk/src/pmc/class.pmc Sun Feb 1 20:10:05 2009 (r36254)
+++ trunk/src/pmc/class.pmc Sun Feb 1 20:26:10 2009 (r36255)
@@ -628,7 +628,7 @@
=item C<void add_attribute(STRING *name, PMC *type)>
Adds the given attribute (C<name>) with an optional C<type>.
-Creates a new class if the current class has been instantiated.
+Throws an exception if the current class has been instantiated.
Enters the attribute in the C<attrib_metadata> table.
Returns an error if an attribute of C<name> already exists.
@@ -664,6 +664,38 @@
/*
+=item C<void remove_attribute(STRING *name)>
+
+Removes the given attribute (C<name>) from the class. Throws an exception if
+the current class has been instantiated, or if the class has no attribute
+C<name>.
+
+=cut
+
+*/
+
+ VTABLE void remove_attribute(STRING *name, PMC *type) {
+ Parrot_Class_attributes * const _class = PARROT_CLASS(SELF);
+
+ /* If we've been instantiated already, not allowed. */
+ if (_class->instantiated)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Modifications to classes are not allowed after instantiation.");
+
+ /* If we don't have an attribute of this name, it's an error. */
+ if (!VTABLE_exists_keyed_str(interp, _class->attrib_metadata, name))
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Attribute '%Ss' cannot be removed, does not exist in '%Ss'.", name,
+ VTABLE_get_string(INTERP, SELF));
+
+ /* Remove the attribute from the attrib_metadata table. */
+ VTABLE_delete_keyed_str(interp, _class->attrib_metadata, name);
+
+ build_attrib_index(interp, SELF);
+ }
+
+/*
+
=item C<void add_method(STRING *name, PMC *sub)>
Adds the given sub PMC as a method with the given name.
@@ -812,6 +844,67 @@
/*
+=item C<void remove_parent(PMC *parent)>
+
+Remove the supplied class object from the list of parents for the class.
+Throws an exception if parent is null, is not a class, or is not a parent, or
+if the class has been instantiated.
+
+=cut
+
+*/
+ VTABLE void remove_parent(PMC *parent) {
+ Parrot_Class_attributes * const _class = PARROT_CLASS(SELF);
+
+ /* get number of direct parents */
+ const int parent_count = VTABLE_elements(interp, _class->parents);
+
+ int index; /* loop iterator */
+
+ /* If we've been instantiated already, not allowed. */
+ if (_class->instantiated) {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Modifications to classes are not allowed after instantiation.");
+ }
+
+ /* Ensure it really is a class. */
+ if (!PObj_is_class_TEST(parent)) {
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Parent isn't a Class.");
+ }
+
+ /* iterate over all direct parents, looking for
+ * the parent to be removed.
+ */
+ for (index = 0; index < parent_count; index++) {
+ /* get the next parent */
+ PMC * const current_parent = VTABLE_get_pmc_keyed_int(interp,
+ _class->parents, index);
+ if (current_parent == parent)
+ break;
+ }
+ if (index >= parent_count)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
+ "Can't remove_parent: is not a parent.");
+
+ /* Move up the remaining parents on the list and pops it */
+ for (; index < parent_count - 1; index++) {
+ PMC * const current_parent = VTABLE_get_pmc_keyed_int(interp,
+ _class->parents, index + 1);
+ VTABLE_set_pmc_keyed_int(interp, _class->parents,
+ index, current_parent);
+ }
+ VTABLE_pop_pmc(interp, _class->parents);
+
+ _class->all_parents = Parrot_ComputeMRO_C3(interp, SELF);
+
+ /* Anonymous classes have no entry in the vtable array */
+ if (!CLASS_is_anon_TEST(SELF))
+ interp->vtables[VTABLE_type(interp, SELF)]->mro = _class->all_parents;
+ }
+
+/*
+
=item C<void add_role(PMC *role)>
Adds the supplied PMC to the list of roles for the class, provided there are
Added: trunk/t/oo/attributes.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/oo/attributes.t Sun Feb 1 20:26:10 2009 (r36255)
@@ -0,0 +1,73 @@
+#! parrot
+# Copyright (C) 2008, The Perl Foundation.
+# $Id: $
+
+=head1 NAME
+
+t/oo/attributes.t - Test OO attributes
+
+=head1 SYNOPSIS
+
+ % prove t/oo/attributes.t
+
+=head1 DESCRIPTION
+
+Tests OO features related to adding and removing attributes.
+
+=cut
+
+.sub main :main
+ .include 'include/test_more.pir'
+
+ plan(3)
+
+ remove_1()
+.end
+
+.sub remove_1
+ .local pmc class, object, init_hash
+ .local pmc exception, message
+
+ init_hash = new 'Hash'
+ $P1 = new 'String'
+ $P1 = 'data for Foo'
+ init_hash['data'] = $P1
+
+ # First pass, adding an attribute.
+ class = newclass "Foo"
+ addattribute class, 'data'
+ object = new class, init_hash
+ $P2 = getattribute object, 'data'
+ is($P2, 'data for Foo', 'class attribute retrieved via the instance')
+
+ # Second pass, removing the attribute after adding it.
+ class = newclass "Bar"
+ addattribute class, 'data'
+ removeattribute class, 'data'
+ push_eh catch_bad_attr_init
+ object = new class, init_hash
+ pop_eh
+ ok(0)
+
+ try_access:
+ object = new class
+ push_eh catch_bad_attr_access
+ $P2 = getattribute object, 'data'
+ pop_eh
+ ok(0)
+
+ end
+
+ catch_bad_attr_init:
+ .get_results (exception)
+ message = exception
+ is(message, "No such attribute 'data'", 'class attribute deleted')
+ pop_eh
+ goto try_access
+
+ catch_bad_attr_access:
+ .get_results (exception)
+ message = exception
+ is(message, "No such attribute 'data'", 'class attribute deleted')
+
+.end
Added: trunk/t/oo/inheritance.t
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/t/oo/inheritance.t Sun Feb 1 20:26:10 2009 (r36255)
@@ -0,0 +1,123 @@
+#! parrot
+# Copyright (C) 2008, The Perl Foundation.
+# $Id: $
+
+=head1 NAME
+
+t/oo/removeparent.t - Test OO inheritance
+
+=head1 SYNOPSIS
+
+ % prove t/oo/removeparent.t
+
+=head1 DESCRIPTION
+
+Tests OO features related to the removeparent opcode.
+
+=cut
+
+.sub main :main
+ .include 'include/test_more.pir'
+
+ plan(4)
+
+ remove_1()
+ remove_2()
+ remove_Y()
+ remove_diamond()
+.end
+
+.sub remove_1
+ $P1 = newclass "Foo"
+ $P2 = newclass "Bar"
+ $I1 = isa $P2, $P1
+ if $I1, fail
+ addparent $P2, $P1
+ $I1 = isa $P2, $P1
+ unless $I1, fail
+ removeparent $P2, $P1
+ $I1 = isa $P2, $P1
+ if $I1, fail
+ $I1 = 1
+ ok( $I1, 'simple')
+fail:
+.end
+
+.sub remove_2
+ $P1 = newclass "Foo2_1"
+ $P2 = newclass "Foo2_2"
+ $P3 = newclass "Bar2"
+ $I1 = isa $P3, $P1
+ if $I1, fail
+ $I1 = isa $P3, $P2
+ if $I1, fail
+ addparent $P3, $P1
+ $I1 = isa $P3, $P1
+ unless $I1, fail
+ $I1 = isa $P3, $P2
+ if $I1, fail
+ addparent $P3, $P2
+ $I1 = isa $P3, $P2
+ unless $I1, fail
+ removeparent $P3, $P1
+ $I1 = isa $P3, $P1
+ if $I1, fail
+ $I1 = isa $P3, $P2
+ unless $I1, fail
+ removeparent $P3, $P2
+ $I1 = isa $P3, $P1
+ if $I1, fail
+ $I1 = isa $P3, $P2
+ if $I1, fail
+ $I1 = 1
+ ok( $I1, 'multiple')
+fail:
+.end
+
+.sub remove_Y
+ $P1 = newclass "FooY_1"
+ $P2 = newclass "FooY_2"
+ $P3 = newclass "BarY_1"
+ $P4 = newclass "BarY_2"
+ addparent $P3, $P1
+ addparent $P3, $P2
+ $I1 = isa $P4, $P1
+ if $I1, fail
+ $I1 = isa $P4, $P2
+ if $I1, fail
+ addparent $P4, $P3
+ $I1 = isa $P4, $P1
+ unless $I1, fail
+ $I1 = isa $P4, $P2
+ unless $I1, fail
+ removeparent $P4, $P3
+ $I1 = isa $P4, $P1
+ if $I1, fail
+ $I1 = isa $P4, $P2
+ if $I1, fail
+ $I1 = 1
+ ok( $I1, 'Y')
+fail:
+.end
+
+.sub remove_diamond
+ $P1 = newclass "FooD1"
+ $P2 = newclass "FooD2"
+ $P3 = newclass "FooD3"
+ $P4 = newclass "BarD1"
+ addparent $P2, $P1
+ addparent $P3, $P1
+ addparent $P4, $P2
+ addparent $P4, $P3
+ $I1 = isa $P4, $P1
+ unless $I1, fail
+ removeparent $P4, $P2
+ $I1 = isa $P4, $P1
+ unless $I1, fail
+ removeparent $P4, $P3
+ $I1 = isa $P4, $P1
+ if $I1, fail
+ $I1 = 1
+ ok( $I1, 'diamond')
+fail:
+.end
More information about the parrot-commits
mailing list