pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2018-12-08
2018-12-08 16:04:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>
4664e1b2db67790528b3c01f8ba626a795016908 (
36
lines) (+
28
/-
8
)
[
Show
|
Annotate
]
Branch:
master
EFUNs: m_clear() now supports multisets and objects.
Adds LFUN _m_clear().
1671:
} }
-
/*! @decl void m_clear(mapping map)
+
/*! @decl void m_clear(mapping
|multiset|object
map)
*!
-
*! Clear the contents of a mapping.
+
*! Clear the contents of a mapping
or multiset
.
*!
-
*! This function clears the content of the mapping @[map] so
-
*!
that it becomes empty. This is an atomic operation.
+
*! This function clears the content of the mapping
+
*! or multiset
@[map] so that it becomes empty.
+
*!
This is an atomic operation.
*!
-
+
*! If @[map] is an object @[lfun::_m_clear()] will be called
+
*! in it.
+
*!
*! @seealso *! @[m_delete()] */ PMOD_EXPORT
-
PIKEFUN void m_clear(mapping map)
-
efun
+
PIKEFUN void m_clear(mapping
|multiset|object
map)
+
efun
;
optflags OPT_SIDE_EFFECT; {
-
/
*
FIXME:
Add
an
LFUN
__
M
_
CLEAR
analogous
with
LFUN__M_
DELETE?
*/
-
clear_
mapping
(
map
);
+
struct program
*
p;
+
if
(TYPEOF(*map)
== PIKE
_
T
_
MAPPING) {
+
clear
_
mapping(map->u.mapping);
+
}
else if (TYPEOF(*map) == PIKE_T_MULTISET) {
+
clear_multiset(map->u.multiset);
+
} else if ((TYPEOF(*map) == PIKE_T_OBJECT) && (p = map->u.object->prog)) {
+
int id = FIND_
LFUN
(p->inherits[SUBTYPEOF(*map)].prog, LFUN
__M_
CLEAR);
+
if( id == -1 ) {
+
SIMPLE_ARG_TYPE_ERROR("m_
clear
", 1, "object with lfun::
_
m_clear
()
")
;
}
-
+
apply_low(map->u.object,
+
id + p->inherits[SUBTYPEOF(*map)].identifier_level, 0);
+
pop_stack();
+
} else {
+
SIMPLE_ARG_TYPE_ERROR("m_clear", 1, "mapping|multiset");
+
}
+
pop_n_elems(args);
+
}
/*! @decl int get_weak_flag(array|mapping|multiset m) *!