@@ -671,14 +671,14 @@ sub emit_struct_fields($$;%) {
671671
672672 with_emit_traits {
673673 emit_block {
674- emit " static $identity_type identity;" ;
675- emit " static $identity_type *get() { return &identity; }" ;
674+ emit " static const $identity_type identity;" ;
675+ emit " static const $identity_type *get() { return &identity; }" ;
676676 } " template<> struct ${export_prefix}$traits_name " , " ;" ;
677677 };
678678
679679 with_emit_static {
680680 my $ftable = render_field_metadata $tag , $full_name , @fields , %info ;
681- emit " $identity_type ${traits_name} ::identity(" ,
681+ emit " const $identity_type ${traits_name} ::identity(" ,
682682 " sizeof($full_name ), &allocator_fn<${full_name} >, " ,
683683 type_identity_reference($tag ,-parent => 1), ' , ' ,
684684 " \" $name \" , NULL, $ftable );" ;
@@ -707,13 +707,13 @@ sub emit_struct_fields($$;%) {
707707 my $inherits = $flags {-inherits};
708708 my $original_name = $tag -> getAttribute(' original-name' );
709709
710- emit " static $identity_type _identity;" ;
710+ emit " static const $identity_type _identity;" ;
711711
712712 with_emit_static {
713713 local @simple_inits ;
714714 my @ctor_lines = with_emit {
715715 if ($flags {-class}) {
716- $ctor_args = " virtual_identity *_id" ;
716+ $ctor_args = " const virtual_identity *_id" ;
717717 $ctor_arg_init = " = &" .$name ." ::_identity" ;
718718 push @simple_inits , " $flags {-inherits}(_id)" if $flags {-inherits};
719719 emit " _identity.adjust_vtable(this, _id);" ;
@@ -747,14 +747,14 @@ sub emit_struct_fields($$;%) {
747747 my $ftable = render_field_metadata $tag , $full_name , @fields , %info ;
748748
749749 if ($flags {-class}) {
750- emit " virtual_identity ${full_name} ::_identity(" ,
750+ emit " const virtual_identity ${full_name} ::_identity(" ,
751751 " sizeof($full_name ), &${alloc_fn} <${full_name} >, " ,
752752 " \" $name \" , " ,
753753 ($original_name ? " \" $original_name \" " : ' NULL' ), ' , ' ,
754754 ($inherits ? " &${inherits} ::_identity" : ' NULL' ), ' , ' ,
755755 " $ftable );" ;
756756 } else {
757- emit " $identity_type ${full_name} ::_identity(" ,
757+ emit " const $identity_type ${full_name} ::_identity(" ,
758758 " sizeof($full_name ), &allocator_fn<${full_name} >, " ,
759759 type_identity_reference($tag ,-parent => 1), ' , ' ,
760760 " \" $name \" , " ,
0 commit comments