view src/ov-int16.cc @ 13241:2a8dcb5b3a00

improve default indexing for objects * ov-class.cc (octave_class::is_class_method): Also return true for anonymous functions executing in the context of a class method or constructor. * ov-class.h (octave_class:do_multi_index_op): New function. * ov-fcn.h (octave_function::is_private_function_of_class): Now const. (octave_function::is_anonymous_function_of_class): New virtual function. * ov-usr-fcn.h (octave_function::anonymous_function): New data member. (octave_user_function::mark_as_anonymous_function): New function. (octave_user_function::is_anonymous_function): New function. (octave_user_function::is_anonymous_function_of_class): New function. * ov-usr-fcn.cc (octave_user_function::octave_user_function): Initialize anonymous_function data member. (octave_user_function::profiler_name): Distinguish between inline and anonymous functions. (octave_user_function::do_multi_index_op): Use is_anonymous_function instead of checking whether cmd_list is marked as an anonymous function body. * pt-fcn-handle.cc (tree_anon_fcn_handle::rvalue1): If parent function is a class method or constructor, stash the dispatch type in the new function. Mark the new function as anonymous, not inline.
author John W. Eaton <jwe@octave.org>
date Wed, 28 Sep 2011 16:45:21 -0400
parents 1a3cdafcb2a5
children 72c96de7a403
line wrap: on
line source

/*

Copyright (C) 2004-2011 John W. Eaton

This file is part of Octave.

Octave is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

Octave is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with Octave; see the file COPYING.  If not, see
<http://www.gnu.org/licenses/>.

*/

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <climits>

#include <iostream>

#include "lo-ieee.h"
#include "lo-utils.h"
#include "mx-base.h"
#include "quit.h"

#include "defun.h"
#include "gripes.h"
#include "oct-obj.h"
#include "oct-lvalue.h"
#include "ops.h"
#include "ov-base.h"

#ifdef HAVE_HDF5
#define HDF5_SAVE_TYPE H5T_NATIVE_INT16
#endif

#include "ov-base-int.h"
#include "ov-base-int.cc"
#include "ov-int16.h"
#include "ov-type-conv.h"
#include "pr-output.h"
#include "variables.h"

#include "byte-swap.h"
#include "ls-oct-ascii.h"
#include "ls-utils.h"
#include "ls-hdf5.h"

template class octave_base_matrix<int16NDArray>;

template class octave_base_int_matrix<int16NDArray>;

DEFINE_OCTAVE_ALLOCATOR (octave_int16_matrix);

DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int16_matrix,
                                     "int16 matrix", "int16");

template class octave_base_scalar<octave_int16>;

template class octave_base_int_scalar<octave_int16>;

DEFINE_OCTAVE_ALLOCATOR (octave_int16_scalar);

DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int16_scalar,
                                     "int16 scalar", "int16");

DEFUN (int16, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} int16 (@var{x})\n\
Convert @var{x} to 16-bit integer type.\n\
@end deftypefn")
{
  OCTAVE_TYPE_CONV_BODY (int16);
}

/*

%!assert (class (int16 (1)), "int16")
%!assert (int16 (1.25), int16 (1))
%!assert (int16 (1.5), int16 (2))
%!assert (int16 (-1.5), int16 (-2))
%!assert (int16 (2^17), int16 (2^16-1))
%!assert (int16 (-2^17), int16 (-2^16))

*/