# HG changeset patch
# User Petter Tomner <tomner@kth.se>
# Date 1641174226 -3600
#      Mon Jan 03 02:43:46 2022 +0100
# Node ID be202ca69ba9824931787c638d56752bce6f6489
# Parent  94435aa4d28ca8265b101ff52b579fb18af71a72
interpreter: Constant literal type_id

Make the type_id for builtin types a constant literal to make
the type_id an immediate constant in the machine code avoiding
pointer dereferencing of t_id.

libinterp/octave-value/
	* ov.cc: Add classdef before java to make its type_id
	         able to be constant
	* cdef-manager.cc: Register type in ov.cc
	* ov-base.h: Macros for const type_id and enum
	* ov-typeinfo.cc: Support explicit type_id
	* ov-typeinfo.h

Alot of repetetive implementation of the const type_id ...

libinterp/octave-value/
	*ov-bool-mat.cc
	*ov-bool-mat.h
	*ov-bool-sparse.cc
	*ov-bool-sparse.h
	*ov-bool.cc
	*ov-bool.h
	*ov-builtin.cc
	*ov-builtin.h
	*ov-cell.cc
	*ov-cell.h
	*ov-class.cc
	*ov-class.h
	*ov-classdef.cc
	*ov-classdef.h
	*ov-colon.cc
	*ov-colon.h
	*ov-complex.cc
	*ov-complex.h
	*ov-cs-list.cc
	*ov-cs-list.h
	*ov-cx-diag.cc
	*ov-cx-diag.h
	*ov-cx-mat.cc
	*ov-cx-mat.h
	*ov-cx-sparse.cc
	*ov-cx-sparse.h
	*ov-dld-fcn.cc
	*ov-dld-fcn.h
	*ov-fcn-handle.cc
	*ov-fcn-handle.h
	*ov-float.cc
	*ov-float.h
	*ov-flt-complex.cc
	*ov-flt-complex.h
	*ov-flt-cx-diag.cc
	*ov-flt-cx-diag.h
	*ov-flt-cx-mat.cc
	*ov-flt-cx-mat.h
	*ov-flt-re-diag.cc
	*ov-flt-re-diag.h
	*ov-flt-re-mat.cc
	*ov-flt-re-mat.h
	*ov-int16.cc
	*ov-int16.h
	*ov-int32.cc
	*ov-int32.h
	*ov-int64.cc
	*ov-int64.h
	*ov-int8.cc
	*ov-int8.h
	*ov-intx.h
	*ov-lazy-idx.cc
	*ov-lazy-idx.h
	*ov-magic-int.cc
	*ov-magic-int.h
	*ov-mex-fcn.cc
	*ov-null-mat.cc
	*ov-null-mat.h
	*ov-oncleanup.cc
	*ov-oncleanup.h
	*ov-perm.cc
	*ov-perm.h
	*ov-range.cc
	*ov-range.h
	*ov-re-diag.cc
	*ov-re-diag.h
	*ov-re-mat.cc
	*ov-re-mat.h
	*ov-re-sparse.cc
	*ov-re-sparse.h
	*ov-scalar.cc
	*ov-scalar.h
	*ov-str-mat.cc
	*ov-str-mat.h
	*ov-struct.cc
	*ov-struct.h
	*ov-uint16.cc
	*ov-uint16.h
	*ov-uint32.cc
	*ov-uint32.h
	*ov-uint64.cc
	*ov-uint64.h
	*ov-uint8.cc
	*ov-uint8.h
	*ov-usr-fcn.cc
	*ov-usr-fcn.h

diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/cdef-manager.cc
--- a/libinterp/octave-value/cdef-manager.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/cdef-manager.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -327,10 +327,6 @@
       m_meta_class (), m_meta_property (), m_meta_method (),
       m_meta_package (), m_meta ()
   {
-    type_info& ti = m_interpreter.get_type_info ();
-
-    octave_classdef::register_type (ti);
-
     // bootstrap
     cdef_class tmp_handle = make_class ("handle");
 
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-base.h
--- a/libinterp/octave-value/ov-base.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-base.h	Mon Jan 03 02:43:46 2022 +0100
@@ -161,7 +161,76 @@
 DEF_BTYP_TRAITS (btyp_uint32, octave_uint32);
 DEF_BTYP_TRAITS (btyp_uint64, octave_uint64);
 DEF_BTYP_TRAITS (btyp_bool, bool);
-DEF_BTYP_TRAITS (btyp_char, char);
+DEF_BTYP_TRAITS(btyp_char, char);
+
+enum fixed_typeid
+  {
+    typeid_unknown_type = 0,
+    typeid_cell = 1,
+    typeid_scalar = 2,
+    typeid_complex_scalar = 3,
+    typeid_matrix = 4,
+    typeid_diagonal_matrix = 5,
+    typeid_complex_matrix = 6,
+    typeid_complex_diagonal_matrix = 7,
+    typeid_float_range = 8,
+    typeid_range = 9,
+    typeid_int8_range = 10,
+    typeid_int16_range = 11,
+    typeid_int32_range = 12,
+    typeid_int64_range = 13,
+    typeid_uint8_range = 14,
+    typeid_uint16_range = 15,
+    typeid_uint32_range = 16,
+    typeid_uint64_range = 17,
+    typeid_bool = 18,
+    typeid_bool_matrix = 19,
+    typeid_string = 20,
+    typeid_sq_string = 21,
+    typeid_int8_scalar = 22,
+    typeid_int16_scalar = 23,
+    typeid_int32_scalar = 24,
+    typeid_int64_scalar = 25,
+    typeid_uint8_scalar = 26,
+    typeid_uint16_scalar = 27,
+    typeid_uint32_scalar = 28,
+    typeid_uint64_scalar = 29,
+    typeid_int8_matrix = 30,
+    typeid_int16_matrix = 31,
+    typeid_int32_matrix = 32,
+    typeid_int64_matrix = 33,
+    typeid_uint8_matrix = 34,
+    typeid_uint16_matrix = 35,
+    typeid_uint32_matrix = 36,
+    typeid_uint64_matrix = 37,
+    typeid_sparse_bool_matrix = 38,
+    typeid_sparse_matrix = 39,
+    typeid_sparse_complex_matrix = 40,
+    typeid_struct = 41,
+    typeid_scalar_struct = 42,
+    typeid_class = 43,
+    typeid_list_cs_list = 44,
+    typeid_colon_magic_colon = 45,
+    typeid_in_function_built_in_function = 46,
+    typeid_defined_function_user_defined_function = 47,
+    typeid_linked_function_dynamically_linked_function = 48,
+    typeid_handle_function_handle = 49,
+    typeid_float_scalar = 50,
+    typeid_float_complex_scalar = 51,
+    typeid_float_matrix = 52,
+    typeid_float_diagonal_matrix = 53,
+    typeid_float_complex_matrix = 54,
+    typeid_float_complex_diagonal_matrix = 55,
+    typeid_permutation_matrix = 56,
+    typeid_magic_int = 57,
+    typeid_magic_uint = 58,
+    typeid_null_matrix = 59,
+    typeid_null_string = 60,
+    typeid_null_sq_string = 61,
+    typeid_lazy_index = 62,
+    typeid_onCleanup = 63,
+    typeid_classdef = 64,
+  };
 
 
 // T_ID is the type id of struct objects, set by register_type().
@@ -175,6 +244,8 @@
 #define DECLARE_OV_BASE_TYPEID_FUNCTIONS_AND_DATA       \
   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(virtual)
 
+#include <iostream>
+
 #define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA2(VIRTUAL)                  \
   public:                                                               \
     VIRTUAL int type_id (void) const { return t_id; }                   \
@@ -191,10 +262,33 @@
     static const std::string t_name;                                    \
     static const std::string c_name;
 
-#define DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS(cls, type)           \
+#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(VIRTUAL,T_ID)        \
+  public:                                                               \
+    VIRTUAL int type_id (void) const { return T_ID; }                   \
+    VIRTUAL std::string type_name (void) const { return t_name; }       \
+    VIRTUAL std::string class_name (void) const { return c_name; }      \
+    static int static_type_id (void) { return T_ID; }                   \
+    static std::string static_type_name (void) { return t_name; }       \
+    static std::string static_class_name (void) { return c_name; }      \
+    static void register_type (void);                                   \
+    static void register_type (octave::type_info&);                     \
+                                                                        \
+  private:                                                              \
+    static const int t_id;                                                    \
+    static const std::string t_name;                                    \
+    static const std::string c_name;
+
+#define DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS(cls, type)                  \
+  template <> void cls<type>::register_type(void);                             \
+  template <> void cls<type>::register_type(octave::type_info &);              \
+  template <> int cls<type>::t_id;                                             \
+  template <> const std::string cls<type>::t_name;                             \
+  template <> const std::string cls<type>::c_name;
+
+#define DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST(cls, type)     \
   template <> void cls<type>::register_type (void);                     \
   template <> void cls<type>::register_type (octave::type_info&);       \
-  template <> int cls<type>::t_id;                                      \
+  template <> const int cls<type>::t_id;                                      \
   template <> const std::string cls<type>::t_name;                      \
   template <> const std::string cls<type>::c_name;
 
@@ -215,11 +309,34 @@
     t_id = ti.register_type (t::t_name, t::c_name, v);                  \
   }
 
+#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL_CONST(tspec, t, n, c, id) \
+  tspec const int t::t_id (id);                                         \
+  tspec const std::string t::t_name (n);                                \
+  tspec const std::string t::c_name (c);                                \
+  tspec void t::register_type (void)                                    \
+  {                                                                     \
+    octave::type_info& type_info                                        \
+      = octave::__get_type_info__ (#t "::register_type");               \
+                                                                        \
+    register_type (type_info);                                          \
+  }                                                                     \
+  tspec void t::register_type (octave::type_info& ti)                   \
+  {                                                                     \
+    octave_value v (new t ());                                          \
+    ti.register_type (t::t_name, t::c_name, v, false, id);              \
+  }
+
 #define DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)           \
   DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL (template <>, t, n, c)
 
-#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)            \
-  DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL ( , t, n, c)
+#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)                           \
+  DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL(, t, n, c)
+
+#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(t, n, c, id)                 \
+  DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL_CONST(, t, n, c, id)
+
+#define DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(t, n, c, id)        \
+  DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_INTERNAL_CONST (template <>, t, n, c, id)
 
 // A base value type, so that derived types only have to redefine what
 // they need (if they are derived from octave_base_value instead of
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool-mat.cc
--- a/libinterp/octave-value/ov-bool-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -67,8 +67,9 @@
 
 template class octave_base_matrix<boolNDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool_matrix,
-                                     "bool matrix", "logical");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_bool_matrix,
+                                           "bool matrix", "logical",
+                                           fixed_typeid::typeid_bool_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool-mat.h
--- a/libinterp/octave-value/ov-bool-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -240,7 +240,8 @@
 
 protected:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_bool_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool-sparse.cc
--- a/libinterp/octave-value/ov-bool-sparse.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool-sparse.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -53,8 +53,10 @@
 
 template class octave_base_sparse<SparseBoolMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sparse_bool_matrix,
-                                     "sparse bool matrix", "logical");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_sparse_bool_matrix,
+  "sparse bool matrix", "logical",
+  fixed_typeid::typeid_sparse_bool_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool-sparse.h
--- a/libinterp/octave-value/ov-bool-sparse.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool-sparse.h	Mon Jan 03 02:43:46 2022 +0100
@@ -154,7 +154,9 @@
 
 protected:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_sparse_bool_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool.cc
--- a/libinterp/octave-value/ov-bool.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -58,7 +58,9 @@
 
 template class octave_base_scalar<bool>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool, "bool", "logical");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_bool, "bool",
+                                           "logical",
+                                           fixed_typeid::typeid_bool);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-bool.h
--- a/libinterp/octave-value/ov-bool.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-bool.h	Mon Jan 03 02:43:46 2022 +0100
@@ -258,7 +258,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_bool);
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-builtin.cc
--- a/libinterp/octave-value/ov-builtin.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-builtin.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -38,9 +38,11 @@
 #include "unwind-prot.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_builtin,
-                                     "built-in function",
-                                     "built-in function");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_builtin,
+  "built-in function",
+  "built-in function",
+  fixed_typeid::typeid_in_function_built_in_function);
 
 octave_value_list
 octave_builtin::execute (octave::tree_evaluator& tw, int nargout,
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-builtin.h
--- a/libinterp/octave-value/ov-builtin.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-builtin.h	Mon Jan 03 02:43:46 2022 +0100
@@ -121,7 +121,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_in_function_built_in_function)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cell.cc
--- a/libinterp/octave-value/ov-cell.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cell.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -142,7 +142,8 @@
 
 template class octave_base_matrix<Cell>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cell, "cell", "cell");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_cell, "cell", "cell",
+                                           fixed_typeid::typeid_cell);
 
 void octave_cell::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame)
 {
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cell.h
--- a/libinterp/octave-value/ov-cell.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cell.h	Mon Jan 03 02:43:46 2022 +0100
@@ -189,7 +189,8 @@
 
   mutable std::unique_ptr<Array<std::string>> m_cellstr_cache;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_cell)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-class.cc
--- a/libinterp/octave-value/ov-class.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-class.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -62,15 +62,15 @@
 #include "variables.h"
 
 
-int octave_class::t_id (-1);
+const int octave_class::t_id (fixed_typeid::typeid_class);
 
 const std::string octave_class::t_name ("class");
 
 void
 octave_class::register_type (octave::type_info& ti)
 {
-  t_id = ti.register_type (octave_class::t_name, "<unknown>",
-                           octave_value (new octave_class ()));
+  ti.register_type (octave_class::t_name, "<unknown>",
+                    octave_value (new octave_class ()));
 }
 
 octave_class::octave_class (const octave_map& m, const std::string& id,
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-class.h
--- a/libinterp/octave-value/ov-class.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-class.h	Mon Jan 03 02:43:46 2022 +0100
@@ -219,17 +219,17 @@
   octave_map m_map;
 
 public:
-  int type_id (void) const { return t_id; }
+  int type_id (void) const { return fixed_typeid::typeid_class; }
   std::string type_name (void) const { return t_name; }
   std::string class_name (void) const { return c_name; }
 
-  static int static_type_id (void) { return t_id; }
+  static int static_type_id (void) { return fixed_typeid::typeid_class; }
   static std::string static_type_name (void) { return t_name; }
   static std::string static_class_name (void) { return "<unknown>"; }
   static OCTINTERP_API void register_type (octave::type_info&);
 
 private:
-  static int t_id;
+  static const int t_id;
 
   static const std::string t_name;
   std::string c_name;
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-classdef.cc
--- a/libinterp/octave-value/ov-classdef.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-classdef.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -58,15 +58,16 @@
   return (ctx.ok () && octave::is_superclass (ctx, cls));
 }
 
-int octave_classdef::t_id (-1);
+const int octave_classdef::t_id (fixed_typeid::typeid_classdef);
 
 const std::string octave_classdef::t_name ("object");
 
 void
 octave_classdef::register_type (octave::type_info& ti)
 {
-  t_id = ti.register_type (octave_classdef::t_name, "<unknown>",
-                           octave_value (new octave_classdef ()));
+  ti.register_type (octave_classdef::t_name, "<unknown>",
+                    octave_value (new octave_classdef ()),
+                    false, fixed_typeid::typeid_classdef);
 }
 
 octave_value_list
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-classdef.h
--- a/libinterp/octave-value/ov-classdef.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-classdef.h	Mon Jan 03 02:43:46 2022 +0100
@@ -148,11 +148,11 @@
 
 public:
 
-  int type_id (void) const { return t_id; }
+  int type_id (void) const { return fixed_typeid::typeid_classdef; }
   std::string type_name (void) const { return t_name; }
   std::string class_name (void) const { return m_object.class_name (); }
 
-  static int static_type_id (void) { return t_id; }
+  static int static_type_id (void) { return fixed_typeid::typeid_classdef; }
   static std::string static_type_name (void) { return t_name; }
   static std::string static_class_name (void) { return "<unknown>"; }
   static OCTINTERP_API void register_type (octave::type_info&);
@@ -161,7 +161,7 @@
 
   octave::cdef_object m_object;
 
-  static int t_id;
+  static const int t_id;
 
   static const std::string t_name;
 };
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-colon.cc
--- a/libinterp/octave-value/ov-colon.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-colon.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -34,8 +34,10 @@
 #include "ovl.h"
 #include "ov-colon.h"
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_magic_colon,
-                                     "magic-colon", "magic-colon");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_magic_colon,
+  "magic-colon", "magic-colon",
+  fixed_typeid::typeid_colon_magic_colon);
 
 void
 octave_magic_colon::print (std::ostream& os, bool)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-colon.h
--- a/libinterp/octave-value/ov-colon.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-colon.h	Mon Jan 03 02:43:46 2022 +0100
@@ -78,7 +78,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_colon_magic_colon)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-complex.cc
--- a/libinterp/octave-value/ov-complex.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-complex.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -62,8 +62,9 @@
 
 template class octave_base_scalar<Complex>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex,
-                                     "complex scalar", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_complex,
+                                           "complex scalar", "double",
+                                           fixed_typeid::typeid_complex_scalar);
 
 namespace octave
 {
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-complex.h
--- a/libinterp/octave-value/ov-complex.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-complex.h	Mon Jan 03 02:43:46 2022 +0100
@@ -206,7 +206,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_complex_scalar)
 };
 
 typedef octave_complex octave_complex_scalar;
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cs-list.cc
--- a/libinterp/octave-value/ov-cs-list.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cs-list.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -36,7 +36,9 @@
 #include "unwind-prot.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_cs_list, "cs-list", "cs-list");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_cs_list, "cs-list",
+                                           "cs-list",
+                                           fixed_typeid::typeid_list_cs_list);
 
 octave_cs_list::octave_cs_list (const Cell& c)
   : octave_base_value (), m_list (c)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cs-list.h
--- a/libinterp/octave-value/ov-cs-list.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cs-list.h	Mon Jan 03 02:43:46 2022 +0100
@@ -91,7 +91,8 @@
   // The list of Octave values.
   octave_value_list m_list;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_list_cs_list);
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-diag.cc
--- a/libinterp/octave-value/ov-cx-diag.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-diag.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -40,8 +40,10 @@
 
 template class octave_base_diag<ComplexDiagMatrix, ComplexMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_diag_matrix,
-                                     "complex diagonal matrix", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_complex_diag_matrix,
+  "complex diagonal matrix", "double",
+  fixed_typeid::typeid_complex_diagonal_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-diag.h
--- a/libinterp/octave-value/ov-cx-diag.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-diag.h	Mon Jan 03 02:43:46 2022 +0100
@@ -98,7 +98,9 @@
 
   OCTINTERP_API bool chk_valid_scalar (const octave_value&, Complex&) const;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_complex_diagonal_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-mat.cc
--- a/libinterp/octave-value/ov-cx-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -67,8 +67,9 @@
 
 template class octave_base_matrix<ComplexNDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_complex_matrix,
-                                     "complex matrix", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_complex_matrix,
+                                           "complex matrix", "double",
+                                           fixed_typeid::typeid_complex_matrix);
 
 static octave_base_value *
 default_numeric_demotion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-mat.h
--- a/libinterp/octave-value/ov-cx-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -181,7 +181,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_complex_matrix);
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-sparse.cc
--- a/libinterp/octave-value/ov-cx-sparse.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-sparse.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -54,8 +54,10 @@
 
 template class octave_base_sparse<SparseComplexMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sparse_complex_matrix,
-                                     "sparse complex matrix", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_sparse_complex_matrix,
+  "sparse complex matrix", "double",
+  fixed_typeid::typeid_sparse_complex_matrix);
 
 octave_base_value *
 octave_sparse_complex_matrix::try_narrowing_conversion (void)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-cx-sparse.h
--- a/libinterp/octave-value/ov-cx-sparse.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-cx-sparse.h	Mon Jan 03 02:43:46 2022 +0100
@@ -155,7 +155,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_sparse_complex_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-dld-fcn.cc
--- a/libinterp/octave-value/ov-dld-fcn.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-dld-fcn.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -39,9 +39,11 @@
 #include "ov.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_dld_function,
-                                     "dynamically-linked function",
-                                     "dynamically-linked function");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_dld_function,
+  "dynamically-linked function",
+  "dynamically-linked function",
+  fixed_typeid::typeid_linked_function_dynamically_linked_function);
 
 octave_dld_function::octave_dld_function
   (octave_builtin::fcn ff, const octave::dynamic_library& shl,
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-dld-fcn.h
--- a/libinterp/octave-value/ov-dld-fcn.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-dld-fcn.h	Mon Jan 03 02:43:46 2022 +0100
@@ -110,7 +110,9 @@
   // on the file to see if it has changed.
   bool m_system_fcn_file;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_linked_function_dynamically_linked_function)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-fcn-handle.cc
--- a/libinterp/octave-value/ov-fcn-handle.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-fcn-handle.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -78,9 +78,11 @@
 #include "ls-utils.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle,
-                                     "function handle",
-                                     "function_handle");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_fcn_handle,
+  "function handle",
+  "function_handle",
+  fixed_typeid::typeid_handle_function_handle);
 
 const std::string octave_fcn_handle::anonymous ("@<anonymous>");
 
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-fcn-handle.h
--- a/libinterp/octave-value/ov-fcn-handle.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-fcn-handle.h	Mon Jan 03 02:43:46 2022 +0100
@@ -367,7 +367,9 @@
 
   octave::base_fcn_handle * get_rep (void) const { return m_rep.get (); }
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_handle_function_handle)
 };
 
 extern bool
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-float.cc
--- a/libinterp/octave-value/ov-float.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-float.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -61,8 +61,9 @@
 
 template class octave_base_scalar<float>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_scalar, "float scalar",
-                                     "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_float_scalar, "float scalar",
+                                           "single",
+                                           fixed_typeid::typeid_float_scalar);
 
 octave_value
 octave_float_scalar::do_index_op (const octave_value_list& idx, bool resize_ok)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-float.h
--- a/libinterp/octave-value/ov-float.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-float.h	Mon Jan 03 02:43:46 2022 +0100
@@ -275,7 +275,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_float_scalar)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-complex.cc
--- a/libinterp/octave-value/ov-flt-complex.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-complex.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -60,8 +60,10 @@
 
 template class octave_base_scalar<FloatComplex>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_complex,
-                                     "float complex scalar", "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_float_complex,
+  "float complex scalar", "single",
+  fixed_typeid::typeid_float_complex_scalar);
 
 octave_base_value *
 octave_float_complex::try_narrowing_conversion (void)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-complex.h
--- a/libinterp/octave-value/ov-flt-complex.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-complex.h	Mon Jan 03 02:43:46 2022 +0100
@@ -197,7 +197,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_float_complex_scalar)
 };
 
 typedef octave_float_complex octave_float_complex_scalar;
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-cx-diag.cc
--- a/libinterp/octave-value/ov-flt-cx-diag.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-cx-diag.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -39,8 +39,11 @@
 
 template class octave_base_diag<FloatComplexDiagMatrix, FloatComplexMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_complex_diag_matrix,
-                                     "float complex diagonal matrix", "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_float_complex_diag_matrix,
+  "float complex diagonal matrix",
+  "single",
+  fixed_typeid::typeid_float_complex_diagonal_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-cx-diag.h
--- a/libinterp/octave-value/ov-flt-cx-diag.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-cx-diag.h	Mon Jan 03 02:43:46 2022 +0100
@@ -95,7 +95,9 @@
   bool chk_valid_scalar (const octave_value&,
                          FloatComplex&) const;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_float_complex_diagonal_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-cx-mat.cc
--- a/libinterp/octave-value/ov-flt-cx-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-cx-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -71,8 +71,10 @@
 
 template class octave_base_matrix<FloatComplexNDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_complex_matrix,
-                                     "float complex matrix", "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_float_complex_matrix,
+  "float complex matrix", "single",
+  fixed_typeid::typeid_float_complex_matrix);
 
 octave_base_value *
 octave_float_complex_matrix::try_narrowing_conversion (void)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-cx-mat.h
--- a/libinterp/octave-value/ov-flt-cx-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-cx-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -177,7 +177,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_float_complex_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-re-diag.cc
--- a/libinterp/octave-value/ov-flt-re-diag.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-re-diag.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -38,8 +38,10 @@
 
 template class octave_base_diag<FloatDiagMatrix, FloatMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_diag_matrix,
-                                     "float diagonal matrix", "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_float_diag_matrix,
+  "float diagonal matrix", "single",
+  fixed_typeid::typeid_float_diagonal_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-re-diag.h
--- a/libinterp/octave-value/ov-flt-re-diag.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-re-diag.h	Mon Jan 03 02:43:46 2022 +0100
@@ -105,7 +105,9 @@
   bool chk_valid_scalar (const octave_value&,
                          float&) const;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_float_diagonal_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-re-mat.cc
--- a/libinterp/octave-value/ov-flt-re-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-re-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -86,8 +86,9 @@
 
 template class octave_base_matrix<FloatNDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_matrix, "float matrix",
-                                     "single");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_float_matrix, "float matrix",
+                                           "single",
+                                           fixed_typeid::typeid_float_matrix);
 
 octave_base_value *
 octave_float_matrix::try_narrowing_conversion (void)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-flt-re-mat.h
--- a/libinterp/octave-value/ov-flt-re-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-flt-re-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -219,7 +219,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (virtual,
+                                              fixed_typeid::typeid_float_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int16.cc
--- a/libinterp/octave-value/ov-int16.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int16.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<int16NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int16_matrix,
-                                     "int16 matrix", "int16");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int16_matrix,
+                                           "int16 matrix", "int16",
+                                           fixed_typeid::typeid_int16_matrix);
 
 template class octave_base_scalar<octave_int16>;
 
 template class octave_base_int_scalar<octave_int16>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int16_scalar,
-                                     "int16 scalar", "int16");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int16_scalar,
+                                           "int16 scalar", "int16",
+                                           fixed_typeid::typeid_int16_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int16.h
--- a/libinterp/octave-value/ov-int16.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int16.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_int16
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_int16_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_int16_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int32.cc
--- a/libinterp/octave-value/ov-int32.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int32.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<int32NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int32_matrix,
-                                     "int32 matrix", "int32");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int32_matrix,
+                                           "int32 matrix", "int32",
+                                           fixed_typeid::typeid_int32_matrix);
 
 template class octave_base_scalar<octave_int32>;
 
 template class octave_base_int_scalar<octave_int32>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int32_scalar,
-                                     "int32 scalar", "int32");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int32_scalar,
+                                           "int32 scalar", "int32",
+                                           fixed_typeid::typeid_int32_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int32.h
--- a/libinterp/octave-value/ov-int32.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int32.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_int32
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_int32_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_int32_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int64.cc
--- a/libinterp/octave-value/ov-int64.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int64.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<int64NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int64_matrix,
-                                     "int64 matrix", "int64");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int64_matrix,
+                                           "int64 matrix", "int64",
+                                           fixed_typeid::typeid_int64_matrix);
 
 template class octave_base_scalar<octave_int64>;
 
 template class octave_base_int_scalar<octave_int64>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int64_scalar,
-                                     "int64 scalar", "int64");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int64_scalar,
+                                           "int64 scalar", "int64",
+                                           fixed_typeid::typeid_int64_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int64.h
--- a/libinterp/octave-value/ov-int64.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int64.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_int64
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_int64_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_int64_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int8.cc
--- a/libinterp/octave-value/ov-int8.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int8.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<int8NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int8_matrix,
-                                     "int8 matrix", "int8");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int8_matrix,
+                                           "int8 matrix", "int8",
+                                           fixed_typeid::typeid_int8_matrix);
 
 template class octave_base_scalar<octave_int8>;
 
 template class octave_base_int_scalar<octave_int8>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_int8_scalar,
-                                     "int8 scalar", "int8");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_int8_scalar,
+                                           "int8 scalar", "int8",
+                                           fixed_typeid::typeid_int8_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-int8.h
--- a/libinterp/octave-value/ov-int8.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-int8.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,11 @@
 
 #define OCTAVE_INT_BTYP btyp_int8
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_int8_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_int8_scalar
+
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +63,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-intx.h
--- a/libinterp/octave-value/ov-intx.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-intx.h	Mon Jan 03 02:43:46 2022 +0100
@@ -382,7 +382,7 @@
 
   static octave_hdf5_id hdf5_save_type;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (virtual, OCTAVE_INT_MATRIX_TYPEID)
 };
 
 class
@@ -695,5 +695,5 @@
 
   static octave_hdf5_id hdf5_save_type;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (virtual, OCTAVE_INT_SCALAR_TYPEID)
 };
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-lazy-idx.cc
--- a/libinterp/octave-value/ov-lazy-idx.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-lazy-idx.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -33,7 +33,9 @@
 #include "ls-oct-text.h"
 #include "ls-oct-binary.h"
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_lazy_index, "lazy_index", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_lazy_index, "lazy_index",
+                                           "double",
+                                           fixed_typeid::typeid_lazy_index);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-lazy-idx.h
--- a/libinterp/octave-value/ov-lazy-idx.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-lazy-idx.h	Mon Jan 03 02:43:46 2022 +0100
@@ -277,7 +277,8 @@
   static octave_base_value *
   numeric_conversion_function (const octave_base_value&);
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_lazy_index)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-magic-int.cc
--- a/libinterp/octave-value/ov-magic-int.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-magic-int.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -302,8 +302,9 @@
   return tmp.map (umap);
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_magic_uint, "magic_uint",
-                                     "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_magic_uint, "magic_uint",
+                                           "double",
+                                           fixed_typeid::typeid_magic_uint);
 
 octave_base_value::type_conv_info
 octave_magic_uint::numeric_conversion_function (void) const
@@ -312,8 +313,9 @@
                                             octave_scalar::static_type_id ());
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_magic_int, "magic_int",
-                                     "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_magic_int, "magic_int",
+                                           "double",
+                                           fixed_typeid::typeid_magic_int);
 
 octave_base_value::type_conv_info
 octave_magic_int::numeric_conversion_function (void) const
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-magic-int.h
--- a/libinterp/octave-value/ov-magic-int.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-magic-int.h	Mon Jan 03 02:43:46 2022 +0100
@@ -296,7 +296,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_magic_uint)
 };
 
 class
@@ -322,7 +323,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_magic_int)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-mex-fcn.cc
--- a/libinterp/octave-value/ov-mex-fcn.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-mex-fcn.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -43,8 +43,8 @@
 #include "unwind-prot.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_mex_function,
-                                     "mex function", "mex function");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_mex_function,
+                                    "mex function", "mex function");
 
 octave_mex_function::octave_mex_function
   (void *fptr, bool interleaved, bool fmex, const octave::dynamic_library& shl,
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-null-mat.cc
--- a/libinterp/octave-value/ov-null-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-null-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -31,8 +31,9 @@
 #include "ops.h"
 #include "defun.h"
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_matrix, "null_matrix",
-                                     "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_null_matrix, "null_matrix",
+                                           "double",
+                                           fixed_typeid::typeid_null_matrix);
 
 const octave_value octave_null_matrix::instance (new octave_null_matrix ());
 
@@ -53,7 +54,9 @@
             octave_matrix::static_type_id ());
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_str, "null_string", "char");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_null_str, "null_string",
+                                           "char",
+                                           fixed_typeid::typeid_null_string);
 
 const octave_value octave_null_str::instance (new octave_null_str ());
 
@@ -74,8 +77,9 @@
            octave_char_matrix_str::static_type_id ());
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_null_sq_str, "null_sq_string",
-                                     "char");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_null_sq_str, "null_sq_string",
+                                           "char",
+                                           fixed_typeid::typeid_null_sq_string);
 
 const octave_value octave_null_sq_str::instance (new octave_null_sq_str ());
 
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-null-mat.h
--- a/libinterp/octave-value/ov-null-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-null-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -57,7 +57,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_null_matrix)
 };
 
 // The special "" value
@@ -80,7 +81,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_null_string)
 };
 
 // The special '' value
@@ -103,7 +105,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_null_sq_string)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-oncleanup.cc
--- a/libinterp/octave-value/ov-oncleanup.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-oncleanup.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -36,8 +36,9 @@
 #include "parse.h"
 #include "pt-misc.h"
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_oncleanup, "onCleanup",
-                                     "onCleanup");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_oncleanup, "onCleanup",
+                                           "onCleanup",
+                                           fixed_typeid::typeid_onCleanup);
 
 octave_oncleanup::octave_oncleanup (const octave_value& f)
   : m_fcn (f)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-oncleanup.h
--- a/libinterp/octave-value/ov-oncleanup.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-oncleanup.h	Mon Jan 03 02:43:46 2022 +0100
@@ -93,7 +93,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_onCleanup)
 
 protected:
 
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-perm.cc
--- a/libinterp/octave-value/ov-perm.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-perm.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -478,8 +478,10 @@
   return m_dense_cache;
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_perm_matrix,
-                                     "permutation matrix", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_perm_matrix,
+  "permutation matrix", "double",
+  fixed_typeid::typeid_permutation_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-perm.h
--- a/libinterp/octave-value/ov-perm.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-perm.h	Mon Jan 03 02:43:46 2022 +0100
@@ -265,7 +265,9 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_permutation_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-range.cc
--- a/libinterp/octave-value/ov-range.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-range.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -130,35 +130,46 @@
 
 #endif
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<float>,
-                                              "float_range", "single");
-
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<double>,
-                                              "range", "double");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  ov_range<float>,
+  "float_range", "single",
+  fixed_typeid::typeid_float_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_int8>,
-                                              "int8_range", "int8");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<double>,
+                                                    "range", "double",
+                                                    fixed_typeid::typeid_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_int16>,
-                                              "int16_range", "int16");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_int8>,
+                                                    "int8_range", "int8",
+                                                    fixed_typeid::typeid_int8_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_int32>,
-                                              "int32_range", "int32");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_int16>,
+                                                    "int16_range", "int16",
+                                                    fixed_typeid::typeid_int16_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_int64>,
-                                              "int64_range", "int64");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_int32>,
+                                                    "int32_range", "int32",
+                                                    fixed_typeid::typeid_int32_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_uint8>,
-                                              "uint8_range", "uint8");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_int64>,
+                                                    "int64_range", "int64",
+                                                    fixed_typeid::typeid_int64_range);
+
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_uint8>,
+                                                    "uint8_range", "uint8",
+                                                    fixed_typeid::typeid_uint8_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_uint16>,
-                                              "uint16_range", "uint16");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_uint16>,
+                                                    "uint16_range", "uint16",
+                                                    fixed_typeid::typeid_uint16_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_uint32>,
-                                              "uint32_range", "uint32");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_uint32>,
+                                                    "uint32_range", "uint32",
+                                                    fixed_typeid::typeid_uint32_range);
 
-DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA (ov_range<octave_uint64>,
-                                              "uint64_range", "uint64");
+DEFINE_TEMPLATE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (ov_range<octave_uint64>,
+                                                    "uint64_range", "uint64",
+                                                    fixed_typeid::typeid_uint64_range);
 
 template <typename T>
 static octave_base_value *
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-range.h
--- a/libinterp/octave-value/ov-range.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-range.h	Mon Jan 03 02:43:46 2022 +0100
@@ -491,19 +491,19 @@
 
   static octave_hdf5_id hdf5_save_type;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual, t_id)
 };
 
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, float)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, double)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int8)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int16)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int32)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_int64)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint8)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint16)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint32)
-DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS (ov_range, octave_uint64)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, float)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, double)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_int8)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_int16)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_int32)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_int64)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_uint8)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_uint16)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_uint32)
+DECLARE_TEMPLATE_OV_TYPEID_SPECIALIZATIONS_CONST (ov_range, octave_uint64)
 
 // Specializations.
 
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-diag.cc
--- a/libinterp/octave-value/ov-re-diag.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-diag.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -39,8 +39,11 @@
 
 template class octave_base_diag<DiagMatrix, Matrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_diag_matrix, "diagonal matrix",
-                                     "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_diag_matrix,
+  "diagonal matrix",
+  "double",
+  fixed_typeid::typeid_diagonal_matrix);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-diag.h
--- a/libinterp/octave-value/ov-re-diag.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-diag.h	Mon Jan 03 02:43:46 2022 +0100
@@ -110,7 +110,9 @@
   bool chk_valid_scalar (const octave_value&,
                          double&) const;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_diagonal_matrix)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-mat.cc
--- a/libinterp/octave-value/ov-re-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -87,7 +87,8 @@
 
 template class octave_base_matrix<NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_matrix, "matrix", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_matrix, "matrix", "double",
+                                           fixed_typeid::typeid_matrix);
 
 static octave_base_value *
 default_numeric_demotion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-mat.h
--- a/libinterp/octave-value/ov-re-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -246,7 +246,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_matrix);
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-sparse.cc
--- a/libinterp/octave-value/ov-re-sparse.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-sparse.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -54,8 +54,10 @@
 
 template class octave_base_sparse<SparseMatrix>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_sparse_matrix, "sparse matrix",
-                                     "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_sparse_matrix,
+                                           "sparse matrix",
+                                           "double",
+                                           fixed_typeid::typeid_sparse_matrix);
 
 octave::idx_vector
 octave_sparse_matrix::index_vector (bool /* require_integers */) const
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-re-sparse.h
--- a/libinterp/octave-value/ov-re-sparse.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-re-sparse.h	Mon Jan 03 02:43:46 2022 +0100
@@ -159,7 +159,9 @@
 private:
   octave_value map (double (*fcn) (double)) const;
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_sparse_matrix);
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-scalar.cc
--- a/libinterp/octave-value/ov-scalar.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-scalar.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -65,7 +65,8 @@
 
 template class octave_base_scalar<double>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_scalar, "scalar", "double");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_scalar, "scalar","double",
+                                           fixed_typeid::typeid_scalar);
 
 static octave_base_value *
 default_numeric_demotion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-scalar.h
--- a/libinterp/octave-value/ov-scalar.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-scalar.h	Mon Jan 03 02:43:46 2022 +0100
@@ -278,7 +278,7 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (virtual, fixed_typeid::typeid_scalar)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-str-mat.cc
--- a/libinterp/octave-value/ov-str-mat.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-str-mat.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -57,9 +57,13 @@
 #include "utils.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_str, "string", "char");
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_char_matrix_sq_str, "sq_string",
-                                     "char");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_char_matrix_str,
+                                           "string",
+                                           "char",
+                                           fixed_typeid::typeid_string);
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_char_matrix_sq_str, "sq_string",
+                                           "char",
+                                           fixed_typeid::typeid_sq_string);
 
 static octave_base_value *
 default_numeric_conversion_function (const octave_base_value& a)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-str-mat.h
--- a/libinterp/octave-value/ov-str-mat.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-str-mat.h	Mon Jan 03 02:43:46 2022 +0100
@@ -181,7 +181,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_string)
 };
 
 typedef octave_char_matrix_str octave_char_matrix_dq_str;
@@ -267,7 +268,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_sq_string)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-struct.cc
--- a/libinterp/octave-value/ov-struct.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-struct.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -54,7 +54,8 @@
 #include "pr-output.h"
 
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_struct, "struct", "struct");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(octave_struct, "struct", "struct",
+                                          fixed_typeid::typeid_struct);
 
 // How many levels of structure elements should we print?
 static int Vstruct_levels_to_print = 2;
@@ -1092,8 +1093,9 @@
   return retval;
 }
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_scalar_struct, "scalar struct",
-                                    "struct");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(octave_scalar_struct, "scalar struct",
+                                          "struct",
+                                          fixed_typeid::typeid_scalar_struct);
 
 void
 octave_scalar_struct::break_closure_cycles (const std::shared_ptr<octave::stack_frame>& frame)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-struct.h
--- a/libinterp/octave-value/ov-struct.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-struct.h	Mon Jan 03 02:43:46 2022 +0100
@@ -167,7 +167,8 @@
 
 private:
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_struct)
 };
 
 class
@@ -291,7 +292,8 @@
 
   octave_value to_array (void);
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(virtual,
+                                             fixed_typeid::typeid_scalar_struct)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-typeinfo.cc
--- a/libinterp/octave-value/ov-typeinfo.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-typeinfo.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -89,7 +89,8 @@
   int type_info::register_type (const std::string& t_name,
                                 const std::string& /* c_name */,
                                 const octave_value& val,
-                                bool abort_on_duplicate)
+                                bool abort_on_duplicate,
+                                int id)
   {
     int i = 0;
 
@@ -109,6 +110,13 @@
           }
       }
 
+    if (id >= 0 && i != id)
+      {
+        std::cerr << "out of order fixed id for type " <<
+          t_name << "id:  " << id << std::endl;
+        abort ();
+      }
+
     int len = m_types.numel ();
 
     if (i == len)
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-typeinfo.h
--- a/libinterp/octave-value/ov-typeinfo.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-typeinfo.h	Mon Jan 03 02:43:46 2022 +0100
@@ -149,7 +149,8 @@
     }
 
     int register_type (const std::string&, const std::string&,
-                       const octave_value&, bool abort_on_duplicate = false);
+                       const octave_value&, bool abort_on_duplicate = false,
+                       int id = -1);
 
     bool register_unary_class_op (octave_value::unary_op, unary_class_op_fcn,
                                   bool abort_on_duplicate = false);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint16.cc
--- a/libinterp/octave-value/ov-uint16.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint16.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -69,12 +69,14 @@
 
 template class octave_base_int_matrix<uint16NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint16_matrix,
-                                     "uint16 matrix", "uint16");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint16_matrix,
+                                          "uint16 matrix", "uint16",
+                                          fixed_typeid::typeid_uint16_matrix);
 
 template class octave_base_scalar<octave_uint16>;
 
 template class octave_base_int_scalar<octave_uint16>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint16_scalar,
-                                     "uint16 scalar", "uint16");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint16_scalar,
+                                           "uint16 scalar", "uint16",
+                                           fixed_typeid::typeid_uint16_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint16.h
--- a/libinterp/octave-value/ov-uint16.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint16.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_uint16
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_uint16_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_uint16_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint32.cc
--- a/libinterp/octave-value/ov-uint32.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint32.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<uint32NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint32_matrix,
-                                     "uint32 matrix", "uint32");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint32_matrix,
+                                           "uint32 matrix", "uint32",
+                                           fixed_typeid::typeid_uint32_matrix);
 
 template class octave_base_scalar<octave_uint32>;
 
 template class octave_base_int_scalar<octave_uint32>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint32_scalar,
-                                     "uint32 scalar", "uint32");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint32_scalar,
+                                           "uint32 scalar", "uint32",
+                                           fixed_typeid::typeid_uint32_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint32.h
--- a/libinterp/octave-value/ov-uint32.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint32.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_uint32
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_uint32_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_uint32_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint64.cc
--- a/libinterp/octave-value/ov-uint64.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint64.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<uint64NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint64_matrix,
-                                     "uint64 matrix", "uint64");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint64_matrix,
+                                           "uint64 matrix", "uint64",
+                                           fixed_typeid::typeid_uint64_matrix);
 
 template class octave_base_scalar<octave_uint64>;
 
 template class octave_base_int_scalar<octave_uint64>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint64_scalar,
-                                     "uint64 scalar", "uint64");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint64_scalar,
+                                           "uint64 scalar", "uint64",
+                                           fixed_typeid::typeid_uint64_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint64.h
--- a/libinterp/octave-value/ov-uint64.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint64.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_uint64
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_uint64_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_uint64_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint8.cc
--- a/libinterp/octave-value/ov-uint8.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint8.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -68,12 +68,14 @@
 
 template class octave_base_int_matrix<uint8NDArray>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint8_matrix,
-                                     "uint8 matrix", "uint8");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint8_matrix,
+                                           "uint8 matrix", "uint8",
+                                           fixed_typeid::typeid_uint8_matrix);
 
 template class octave_base_scalar<octave_uint8>;
 
 template class octave_base_int_scalar<octave_uint8>;
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_uint8_scalar,
-                                     "uint8 scalar", "uint8");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (octave_uint8_scalar,
+                                           "uint8 scalar", "uint8",
+                                           fixed_typeid::typeid_uint8_scalar);
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-uint8.h
--- a/libinterp/octave-value/ov-uint8.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-uint8.h	Mon Jan 03 02:43:46 2022 +0100
@@ -42,6 +42,10 @@
 
 #define OCTAVE_INT_BTYP btyp_uint8
 
+#define OCTAVE_INT_MATRIX_TYPEID fixed_typeid::typeid_uint8_matrix
+
+#define OCTAVE_INT_SCALAR_TYPEID fixed_typeid::typeid_uint8_scalar
+
 #include "ov-intx.h"
 
 #undef OCTAVE_INT_T
@@ -58,4 +62,8 @@
 
 #undef OCTAVE_INT_BTYP
 
+#undef OCTAVE_INT_MATRIX_TYPEID
+
+#undef OCTAVE_INT_SCALAR_TYPEID
+
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-usr-fcn.cc
--- a/libinterp/octave-value/ov-usr-fcn.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-usr-fcn.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -204,9 +204,11 @@
 
 // User defined functions.
 
-DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_user_function,
-                                     "user-defined function",
-                                     "user-defined function");
+DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST (
+  octave_user_function,
+  "user-defined function",
+  "user-defined function",
+  fixed_typeid::typeid_defined_function_user_defined_function);
 
 // Ugh.  This really needs to be simplified (code/data?
 // extrinsic/intrinsic state?).
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov-usr-fcn.h
--- a/libinterp/octave-value/ov-usr-fcn.h	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov-usr-fcn.h	Mon Jan 03 02:43:46 2022 +0100
@@ -478,7 +478,9 @@
 
   void restore_warning_states (void);
 
-  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
+  DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA_CONST(
+    virtual,
+    fixed_typeid::typeid_defined_function_user_defined_function)
 };
 
 #endif
diff -r 94435aa4d28c -r be202ca69ba9 libinterp/octave-value/ov.cc
--- a/libinterp/octave-value/ov.cc	Sun Jan 02 02:08:50 2022 +0100
+++ b/libinterp/octave-value/ov.cc	Mon Jan 03 02:43:46 2022 +0100
@@ -3284,6 +3284,11 @@
 void
 install_types (octave::type_info& ti)
 {
+  // Note that the order of these registrations
+  // need to be in the same order as the matching
+  // fixed_typeid enum value.
+  //
+  // There is an errorcheck for this in register_type ().
   octave_base_value::register_type (ti);
   octave_cell::register_type (ti);
   octave_scalar::register_type (ti);
@@ -3348,6 +3353,7 @@
   octave_null_sq_str::register_type (ti);
   octave_lazy_index::register_type (ti);
   octave_oncleanup::register_type (ti);
+  octave_classdef::register_type (ti);
   octave_java::register_type (ti);
 }
 
