diff --git a/lib/master.pike.in b/lib/master.pike.in index 0e5966aea3fe1ae52f0c6da8bcd2975d751e2210..06afc6b0185f709ad5e9e1a5d5b25d1747962aa6 100644 --- a/lib/master.pike.in +++ b/lib/master.pike.in @@ -1,6 +1,6 @@ /* -*- Pike -*- * - * $Id: master.pike.in,v 1.95 2000/01/16 05:19:20 hubbe Exp $ + * $Id: master.pike.in,v 1.96 2000/01/27 23:07:27 hubbe Exp $ * * Master-file for Pike. * @@ -427,11 +427,6 @@ object new(mixed prog, mixed ... args) return prog(@args); } -multiset mkmultiset(array a) -{ - return aggregate_multiset(@a); -} - function clone = new; /* This array contains the names of the functions @@ -453,7 +448,6 @@ constant master_efuns = ({ "remove_program_path", "describe_backtrace", "describe_error", - "mkmultiset", "new", "clone", diff --git a/src/builtin_functions.c b/src/builtin_functions.c index 2bbc39263f8577f81b9a983712f603616c2b1279..ae5a0c599df887964f240f5947ea20e5643c1c16 100644 --- a/src/builtin_functions.c +++ b/src/builtin_functions.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: builtin_functions.c,v 1.231 2000/01/24 14:00:30 noring Exp $"); +RCSID("$Id: builtin_functions.c,v 1.232 2000/01/27 23:07:41 hubbe Exp $"); #include "interpret.h" #include "svalue.h" #include "pike_macros.h" @@ -2291,6 +2291,17 @@ void f_mkmapping(INT32 args) push_mapping(m); } +void f_mkmultiset(INT32 args) +{ + struct multiset *m; + struct array *a; + get_all_args("mkmultiset",args,"%a",&a); + + m=mkmultiset(sp[-args].u.array); + pop_n_elems(args); + push_multiset(m); +} + #define SETFLAG(FLAGS,FLAG,ONOFF) \ FLAGS = (FLAGS & ~FLAG) | ( ONOFF ? FLAG : 0 ) void f_set_weak_flag(INT32 args) @@ -3159,7 +3170,7 @@ static void f_interleave_array(INT32 args) INT32 e; struct keypair *k; - if (!(m = ITEM(arr)[j].u.mapping)->size) { + if (! m_sizeof(m = ITEM(arr)[j].u.mapping)) { /* Not available */ ITEM(min)[i].u.integer = -1; continue; @@ -5626,6 +5637,10 @@ void init_builtin_efuns(void) ADD_EFUN("mkmapping",f_mkmapping, tFunc(tArr(tSetvar(1,tMix)) tArr(tSetvar(2,tMix)), tMap(tVar(1),tVar(2))),OPT_TRY_OPTIMIZE); + + ADD_EFUN("mkmultiset",f_mkmultiset, + tFunc(tArr(tSetvar(1,tMix)), tSet(tVar(1))), + OPT_TRY_OPTIMIZE); /* function(1=mixed,int:1) */ ADD_EFUN("set_weak_flag",f_set_weak_flag, diff --git a/src/testsuite.in b/src/testsuite.in index 11fe2b2d19f4e36822302b35e8a539df2c4b365a..47f756df010c6836b672e7f8c6fc43f93d9665ec 100644 --- a/src/testsuite.in +++ b/src/testsuite.in @@ -1,4 +1,4 @@ -test_true([["$Id: testsuite.in,v 1.264 2000/01/26 13:45:55 noring Exp $"]]); +test_true([["$Id: testsuite.in,v 1.265 2000/01/27 23:07:41 hubbe Exp $"]]); cond([[all_constants()->_verify_internals]], [[ @@ -971,6 +971,7 @@ test_any_equal([[ o->a += ({2}); return o->a; ]], ({1,2})) + test_any_equal([[ class A { array a = ({1}); @@ -984,6 +985,67 @@ test_any_equal([[ return o->a; ]], ({1,2})) +test_any_equal([[ + class A { + array a = ({1}); +// void `->= (string var, mixed val) {::`->= (var, val);} + }; + class B { + int z; + inherit A; + void `->= (string var, mixed val) { A::`->= (var, val);} + }; + object o = B(); + o->a += ({2}); + return o->a; +]], ({1,2})) + +test_any_equal([[ + class FOO + { + int q,w,z; + }; + class A { + array a = ({1}); + }; + class B { + inherit FOO; + int b,c,d,e,f,g; + inherit A; + void `->= (string var, mixed val) { A::`->= (var, val);} + }; + object o = B(); + o->a += ({2}); + return o->a; +]], ({1,2})) + + +test_any_equal([[ + class A { + array a = ({1}); + }; + class B { + int z; + inherit A : FNORD; + + class Q + { + mixed `-> (string var) + { + return FNORD::`-> (var); + } + void `->= (string var, mixed val) + { + FNORD::`->= (var, val); + } + } + }; + object o = B(); + object o2=o->Q(); + o2->a += ({2}); + return o->a; +]], ({1,2})) + test_true(mappingp(_memory_usage())) test_true(_refs("")); test_true(_refs(({}))); @@ -2442,6 +2504,7 @@ test_true([[(array(array))([]) ]]) test_true([[(array(array))([1:2]) ]]) test_true([[(array(array))([1:2,3:4]) ]]) test_true([[(array(array))([1:2,3:4,5:6]) ]]) +test_equal( [[ (multiset) ({1})]], [[ (< 1 >) ]] ) test_eval_error([[return (mapping)""]]) // testing @