GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
op-class.cc File Reference

Unary and binary operators for classdef and old style classes. More...

#include "oct-time.h"
#include "errwarn.h"
#include "interpreter-private.h"
#include "load-path.h"
#include "ovl.h"
#include "ov.h"
#include "ov-class.h"
#include "ov-typeinfo.h"
#include "ops.h"
#include "symtab.h"
#include "parse.h"
Include dependency graph for op-class.cc:

Go to the source code of this file.

Macros

#define DEF_CLASS_BINOP(opname)
 Helper macro to define binary class operators. More...
 
#define DEF_CLASS_UNOP(opname)
 Helper macro to define unary class operators. More...
 

Functions

void install_class_ops (octave::type_info &ti)
 
static octave_value oct_binop_and (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_default (const octave_value &a1, const octave_value &a2, const std::string &opname)
 Default binary class operator. More...
 
static octave_value oct_binop_eq (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_ge (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_gt (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_ldivide (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_le (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_lt (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_minus (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_mldivide (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_mpower (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_mrdivide (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_mtimes (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_ne (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_or (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_plus (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_power (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_rdivide (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_binop_times (const octave_value &a1, const octave_value &a2)
 
static octave_value oct_unop_ctranspose (const octave_value &a)
 
static octave_value oct_unop_default (const octave_value &a, const std::string &opname)
 Default unary class operator. More...
 
static octave_value oct_unop_not (const octave_value &a)
 
static octave_value oct_unop_transpose (const octave_value &a)
 
static octave_value oct_unop_uminus (const octave_value &a)
 
static octave_value oct_unop_uplus (const octave_value &a)
 

Detailed Description

Unary and binary operators for classdef and old style classes.

Definition in file op-class.cc.

Macro Definition Documentation

◆ DEF_CLASS_BINOP

#define DEF_CLASS_BINOP (   opname)
Value:
static octave_value \
oct_binop_ ## opname (const octave_value& a1, const octave_value& a2) \
{ \
return oct_binop_default (a1, a2, #opname); \
}
static octave_value oct_binop_default(const octave_value &a1, const octave_value &a2, const std::string &opname)
Default binary class operator.
Definition: op-class.cc:138
const octave_base_value & a2

Helper macro to define binary class operators.

Definition at line 170 of file op-class.cc.

◆ DEF_CLASS_UNOP

#define DEF_CLASS_UNOP (   opname)
Value:
static octave_value \
oct_unop_ ## opname (const octave_value& a) \
{ \
return oct_unop_default (a, #opname); \
}
static octave_value oct_unop_default(const octave_value &a, const std::string &opname)
Default unary class operator.
Definition: op-class.cc:52

Helper macro to define unary class operators.

Definition at line 107 of file op-class.cc.

Function Documentation

◆ install_class_ops()

◆ oct_binop_and()

static octave_value oct_binop_and ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 193 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_default()

static octave_value oct_binop_default ( const octave_value a1,
const octave_value a2,
const std::string &  opname 
)
static

Default binary class operator.

Parameters
a1first operand
a2second operand
opnameoperator name

The operator precedence is as follows:

  1. If exactly one of the operands is a user defined class object, then the class method of that operand is invoked.
  2. If both operands are user defined class objects, then 2.1 The superior class method is invoked. 2.2 The leftmost class method is invoked if both classes are the same or their precedence is not defined by superiorto/inferiorto.

Definition at line 138 of file op-class.cc.

References octave::__get_symbol_table__(), a2, octave_base_value::class_name(), octave_value::class_name(), error(), octave::feval(), octave::symbol_table::find_method(), octave_value::function_value(), octave::symbol_table::is_superiorto(), octave_value::is_undefined(), octave_base_value::isobject(), octave_value::isobject(), octave_value_list::length(), octave_value(), and ovl().

◆ oct_binop_eq()

static octave_value oct_binop_eq ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 185 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_ge()

static octave_value oct_binop_ge ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 186 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_gt()

static octave_value oct_binop_gt ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 187 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_ldivide()

static octave_value oct_binop_ldivide ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 192 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_le()

static octave_value oct_binop_le ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 184 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_lt()

static octave_value oct_binop_lt ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 183 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_minus()

static octave_value oct_binop_minus ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 178 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_mldivide()

static octave_value oct_binop_mldivide ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 182 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_mpower()

static octave_value oct_binop_mpower ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 181 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_mrdivide()

static octave_value oct_binop_mrdivide ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 180 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_mtimes()

static octave_value oct_binop_mtimes ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 179 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_ne()

static octave_value oct_binop_ne ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 188 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_or()

static octave_value oct_binop_or ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 194 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_plus()

static octave_value oct_binop_plus ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 177 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_power()

static octave_value oct_binop_power ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 191 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_rdivide()

static octave_value oct_binop_rdivide ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 190 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_binop_times()

static octave_value oct_binop_times ( const octave_value a1,
const octave_value a2 
)
static

Definition at line 189 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_unop_ctranspose()

static octave_value oct_unop_ctranspose ( const octave_value a)
static

Definition at line 118 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_unop_default()

◆ oct_unop_not()

static octave_value oct_unop_not ( const octave_value a)
static

Definition at line 114 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_unop_transpose()

static octave_value oct_unop_transpose ( const octave_value a)
static

Definition at line 117 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_unop_uminus()

static octave_value oct_unop_uminus ( const octave_value a)
static

Definition at line 116 of file op-class.cc.

Referenced by install_class_ops().

◆ oct_unop_uplus()

static octave_value oct_unop_uplus ( const octave_value a)
static

Definition at line 115 of file op-class.cc.

Referenced by install_class_ops().