Beispiel #1
0
/*#
   @method remove Dictionary
   @brief Removes a given key from the dictionary.
   @param key The key to be removed
   @return True if the key is found and removed, false otherwise.

   If the given key is found, it is removed from the dictionary,
   and the function returns true. If it's not found, it returns false.
*/
FALCON_FUNC  mth_dictRemove ( ::Falcon::VMachine *vm )
{
   Item *dict, *key;
   
   if( vm->self().isMethodic() )
   {
      dict = &vm->self();
      key = vm->param(0);
   }
   else {
      dict = vm->param(0);
      key = vm->param(1);
   }
   
   if( dict == 0  || ! dict->isDict() || key == 0 ) 
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ )
            .origin( e_orig_runtime )
            .extra( vm->self().isMethodic() ? "X" : "D,X" ) );
   }

   CoreDict *d = dict->asDict();
   vm->regA().setBoolean( d->remove( *key ) );
}