fabriciocolombo / delphi-rest-client-api

A Delphi REST client API to consume REST services written in any programming language.
Apache License 2.0
380 stars 182 forks source link

Add support for Delphi XE8 #42

Closed RobertoSchneiders closed 9 years ago

RobertoSchneiders commented 9 years ago

I don't have the XE8 version yet, but some people are requesting this. Anyone have this version and can do this changes?

Just add this to the line 117 of the DelphiRest.inc file and run the tests.

{$IFDEF VER290} // RAD Studio XE8
  {$DEFINE DELPHI_7_UP}
  {$DEFINE DELPHI_2007_UP}
  {$DEFINE DELPHI_2009_UP}
  {$DEFINE DELPHI_2010_UP}
  {$DEFINE DELPHI_XE_UP}
  {$DEFINE DELPHI_XE2_UP}
  {$DEFINE DELPHI_XE3_UP}
  {$DEFINE DELPHI_XE4_UP}
  {$DEFINE DELPHI_XE5_UP}
  {$DEFINE DELPHI_XE6_UP}
  {$DEFINE DELPHI_XE7}
  {$DEFINE DELPHI_XE7_UP}
  {$DEFINE DELPHI_XE8}
  {$DEFINE DELPHI_XE8_UP}
{$ENDIF VER290}

Maybe we can find a better way to do this and avoid this changes for every new version.

ronaldhoek commented 9 years ago

I would suggest this approach for 'DelphiRest.inc' - this will notify you when a unknown version is used for compiling the project en requires reviewing this 'code' before making assuptions on why somthing else does not work.

(* Full Delphi Version Compiler Directives list could be found here: https://gist.github.com/2485849*)

{$DEFINE USE_INDY}
{$DEFINE USE_WIN_HTTP}
{$DEFINE USE_WIN_INET}

// Delphi 7
{$DEFINE DELPHI_7_UP}
{$IFDEF VER150}
  {$DEFINE DELPHI_7}
  {$UNDEF USE_INDY}
{$ELSE}
  //Delphi 2007
  {$DEFINE DELPHI_2007_UP}
  {$IFDEF VER185}
    {$DEFINE DELPHI_2007}
  {$ELSE}
     // RAD Studio 2009
    {$DEFINE DELPHI_2009_UP}
    {$IFDEF VER200}
      {$DEFINE DELPHI_2009}
    {$ELSE}
      // RAD Studio 2010
      {$DEFINE DELPHI_2010_UP}
      {$IFDEF VER210}
        {$DEFINE DELPHI_2010}
      {$ELSE}
        // RAD Studio XE
        {$DEFINE DELPHI_XE_UP}
        {$IFDEF VER220}
          {$DEFINE DELPHI_XE}
        {$ELSE}
          // RAD Studio XE2
          {$DEFINE DELPHI_XE2_UP}
          {$IFDEF VER230}
            {$DEFINE DELPHI_XE2}
          {$ELSE}
            // RAD Studio XE3
            {$DEFINE DELPHI_XE3_UP}
            {$IFDEF VER240}
              {$DEFINE DELPHI_XE3}
            {$ELSE}
              // RAD Studio XE4
              {$DEFINE DELPHI_XE4_UP}
              {$IFDEF VER250}
                {$DEFINE DELPHI_XE4}
              {$ELSE}
                // RAD Studio XE5
                {$DEFINE DELPHI_XE5_UP}
                {$IFDEF VER260}
                  {$DEFINE DELPHI_XE5}
                {$ELSE}
                  // RAD Studio XE6
                  {$DEFINE DELPHI_XE6_UP}
                  {$IFDEF VER270}
                    {$DEFINE DELPHI_XE6}
                  {$ELSE}
                    // RAD Studio XE7
                    {$DEFINE DELPHI_XE7_UP}
                    {$IFDEF VER280}
                      {$DEFINE DELPHI_XE7}
                    {$ELSE}
                      // RAD Studio XE8
                      {$DEFINE DELPHI_XE8_UP}
                      {$IFDEF VER290}
                        {$DEFINE DELPHI_XE8}
                      {$ELSE}
                        !!! UNKNOW OR UNSUPPORTED DELPHI VERSION !!!
                      {$ENDIF VER290}
                    {$ENDIF VER280}
                  {$ENDIF VER270}
                {$ENDIF VER260}
              {$ENDIF VER250}
            {$ENDIF VER240}
          {$ENDIF VER230}
        {$ENDIF VER220}
      {$ENDIF VER210}
    {$ENDIF VER200}
  {$ENDIF VER185}
{$ENDIF VER150}

{$IFDEF DELPHI_2010_UP}
  {$DEFINE USE_GENERICS}
{$ENDIF}

{$IFNDEF DELPHI_XE_UP}
  {$DEFINE USE_SUPER_OBJECT}
{$ENDIF}

{$IFDEF MACOS}
  {$UNDEF USE_SUPER_OBJECT}
  {$UNDEF USE_WIN_HTTP}
  {$UNDEF USE_WIN_INET}  
{$ENDIF}

However I would suggest banning out the use of 'DELPHI_????_UP' directives in the units themselves. These are not informative on why some code is being used or not. This is something, which can be done later (apart from the suggest modification of 'DelphiRest.inc' above) and would take more effort.

Ex.

    {$IFDEF DELPHI_XE6_UP}, Json{$ENDIF}

Change to:

    {$IFDEF USE_DELPHI_JSON}, Json{$ENDIF}

By adding the code below to 'DelphiRest.inc' you can specify at a central point, for what purpose the define is used.

{$IFDEF DELPHI_XE6_UP}
  // Include the use of Delphi own JSon library (available from XE 6)
  {$DEFINE USE_DELPHI_JSON}
{$ENDIF}

When the 'rules' for the define change, this change is applied to all units...

RobertoSchneiders commented 9 years ago

I think we can use this {$IF CompilerVersion >= 22.0} and completely eliminate all the {$IFDEF VERXYZ} code.

fabriciocolombo commented 9 years ago

i agree, compiler version seems a better option and it will also clean up the DelphiRest.inc file. And also use more meaningful compiler directives.

ronaldhoek commented 9 years ago

Be sure to check the 'CONDITIONALEXPRESSIONS' define when using {$IF CompilerVersion >= 22.0}

{$IFDEF CONDITIONALEXPRESSIONS}
  {$IF CompilerVersion >= 22.0}
    // etc.
  {$ENDIF}
{$ELSE}
  !!! UNSUPPORTED DELPHI VERSION !!!
{IFEND}