[ 
https://issues.apache.org/jira/browse/THRIFT-5749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17798152#comment-17798152
 ] 

Jens Geyer edited comment on THRIFT-5749 at 12/18/23 11:49 AM:
---------------------------------------------------------------

Enabling RTTI comes with small, but necessary changes to the generated code.

*With RTTI enabled:*
 - the interfaces derive from {{IBaseWithTypeInfo}} which in turn derives from 
{{IBase}}.
 - binary translates to {{TThriftBytes}} instead of {{System.TBytes}} to 
prevent against {{E2134 "TBytes has no typinfo"}}.

{{TThriftBytes}} is assignment compatible to {{TBytes}} but it may require 
other code changes, e.g. when using {{Length()}}.

Implementing/querying {{IBaseWithTypeInfo}}  is not necessary/foreseen, its 
only purpose is to add typeinfo.

*Compatibilty note:*

There may cases where activating RTTI leads to uncompileable code, presenting 
{{E2134 "TMyEnum has no typinfo"}} where {{TMyEnum}} is an "irregular" enum 
like {{TNumberz}} from the test suite. This is a known limitation of the Delphi 
RTTI system [1] and *NOT* a bug in Thrift. At this time, you simply cannot use 
RTTI with such enums, unless Embarcadero finally does that stuff right.

[1] 
https://stackoverflow.com/questions/1420562/why-do-i-get-type-has-no-typeinfo-error-with-an-enum-type


was (Author: jensg):
Enabling RTTI comes with small, but necessary changes to the generated code.

*With RTTI enabled:*
 - the interfaces derive from {{IBaseWithTypeInfo}} which in turn derives from 
{{{}IBase{}}}.
 - binary translates to {{TThriftBytes}} instead of {{System.TBytes}} to 
prevent against {{{}E2134 "TBytes has no typinfo"{}}}.

{{TThriftBytes}} is assignment compatible to {{TBytes}} but it may require 
other code changes, e.g. when using {{{}Length(){}}}.

Implementing/querying {{IBaseWithTypeInfo}} is not necessary/foreseen, its only 
purpose is to add typeinfo.

*Compatibilty note:*

There may cases where activating RTTI leads to uncompileable code, presenting 
{{E2134 "TMyEnum has no typinfo"}} where {{TMyEnum}} is an "irregular" enum 
like {{TNumberz}} from the test suite. This is a [well-known limitation of the 
Delphi RTTI 
system|[http://example.com|https://stackoverflow.com/questions/1420562/why-do-i-get-type-has-no-typeinfo-error-with-an-enum-type]]
 and *NOT* a bug in Thrift. At this time, you simply cannot use RTTI with such 
enums, unless Embarcadero finally does that stuff right.

> Option to enable RTTI info
> --------------------------
>
>                 Key: THRIFT-5749
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5749
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Delphi - Compiler
>            Reporter: Jens Geyer
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.20.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> In some cases it would be helpful to have RTTI info available for generated 
> API interfaces.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to