Recent

Author Topic: [CLOSED] How to translate these macros into Pascal?  (Read 3780 times)

guest65405

  • Guest
[CLOSED] How to translate these macros into Pascal?
« on: April 02, 2020, 06:25:49 pm »
Code: C  [Select][+][-]
  1. #define _cdCheckCanvas(_canvas) (_canvas!=NULL && ((unsigned char*)_canvas)[0] == 'C' && ((unsigned char*)_canvas)[1] == 'D') // _canvas is a struct, _cdCanvas
  2. #define _cdSwapInt(_a,_b) {int _c=_a;_a=_b;_b=_c;}
  3. #define _cdSwapDouble(_a,_b) {double _c=_a;_a=_b;_b=_c;}
  4. #define _cdRound(_x) ((int)(_x < 0? (_x-0.5): (_x+0.5)))
  5.  
  6. #define cdCanvas2Raster(x, y) {(void)x; cdUpdateYAxis(y);} //x, y are integers

h2pas has trouble translating these macros. Even if I convert them into C functions myself it's still can't get over. Please help.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8458
  • FPC developer.
Re: How to translate these macros into Pascal?
« Reply #1 on: April 02, 2020, 07:20:56 pm »
See my answer to your last macro question. You need to propagate knowledge about usage back to the macro definition to make it typed.

If that is not possible, the only solution is to use an external macro processor on the source code before passing it on to the Pascal compiler

guest65405

  • Guest
Re: How to translate these macros into Pascal?
« Reply #2 on: April 03, 2020, 04:04:04 am »
See my answer to your last macro question. You need to propagate knowledge about usage back to the macro definition to make it typed.

If that is not possible, the only solution is to use an external macro processor on the source code before passing it on to the Pascal compiler

Please just help me translate these macros into Pascal. I have updated the post to add types.

Here is the struct _cdCanvas:

Code: C  [Select][+][-]
  1. struct _cdCanvas
  2. {
  3.   char signature[2];  /* must be "CD" */
  4.  
  5.   /* can NOT be NULL */
  6.   void   (*cxPixel)(cdCtxCanvas* ctxcanvas, int x, int y, long color);
  7.   void   (*cxLine)(cdCtxCanvas* ctxcanvas, int x1, int y1, int x2, int y2);
  8.   void   (*cxPoly)(cdCtxCanvas* ctxcanvas, int mode, cdPoint* points, int n);
  9.   void   (*cxRect)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax);
  10.   void   (*cxBox)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax);
  11.   void   (*cxArc)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2);
  12.   void   (*cxSector)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2);
  13.   void   (*cxChord)(cdCtxCanvas* ctxcanvas, int xc, int yc, int w, int h, double angle1, double angle2);
  14.   void   (*cxText)(cdCtxCanvas* ctxcanvas, int x, int y, const char *s, int len);
  15.   void   (*cxKillCanvas)(cdCtxCanvas* ctxcanvas);
  16.   int    (*cxFont)(cdCtxCanvas* ctxcanvas, const char *type_face, int style, int size);
  17.   void   (*cxPutImageRectMap)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *index, const long *colors, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
  18.  
  19.   /* default implementation uses the simulation driver */
  20.   void   (*cxGetFontDim)(cdCtxCanvas* ctxcanvas, int *max_width, int *height, int *ascent, int *descent);
  21.   void   (*cxGetTextSize)(cdCtxCanvas* ctxcanvas, const char *s, int len, int *width, int *height);
  22.  
  23.   /* all the following function pointers can be NULL */
  24.  
  25.   void   (*cxFlush)(cdCtxCanvas* ctxcanvas);
  26.   void   (*cxClear)(cdCtxCanvas* ctxcanvas);
  27.  
  28.   void   (*cxFPixel)(cdCtxCanvas* ctxcanvas, double x, double y, long color);
  29.   void   (*cxFLine)(cdCtxCanvas* ctxcanvas, double x1, double y1, double x2, double y2);
  30.   void   (*cxFPoly)(cdCtxCanvas* ctxcanvas, int mode, cdfPoint* points, int n);
  31.   void   (*cxFRect)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax);
  32.   void   (*cxFBox)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax);
  33.   void   (*cxFArc)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2);
  34.   void   (*cxFSector)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2);
  35.   void   (*cxFChord)(cdCtxCanvas* ctxcanvas, double xc, double yc, double w, double h, double angle1, double angle2);
  36.   void   (*cxFText)(cdCtxCanvas* ctxcanvas, double x, double y, const char *s, int len);
  37.  
  38.   int    (*cxClip)(cdCtxCanvas* ctxcanvas, int mode);
  39.   void   (*cxClipArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax);
  40.   void   (*cxFClipArea)(cdCtxCanvas* ctxcanvas, double xmin, double xmax, double ymin, double ymax);
  41.   int    (*cxBackOpacity)(cdCtxCanvas* ctxcanvas, int opacity);
  42.   int    (*cxWriteMode)(cdCtxCanvas* ctxcanvas, int mode);
  43.   int    (*cxLineStyle)(cdCtxCanvas* ctxcanvas, int style);
  44.   int    (*cxLineWidth)(cdCtxCanvas* ctxcanvas, int width);
  45.   int    (*cxLineJoin)(cdCtxCanvas* ctxcanvas, int join);
  46.   int    (*cxLineCap)(cdCtxCanvas* ctxcanvas, int cap);
  47.   int    (*cxInteriorStyle)(cdCtxCanvas* ctxcanvas, int style);
  48.   int    (*cxHatch)(cdCtxCanvas* ctxcanvas, int style);
  49.   void   (*cxStipple)(cdCtxCanvas* ctxcanvas, int w, int h, const unsigned char *stipple);
  50.   void   (*cxPattern)(cdCtxCanvas* ctxcanvas, int w, int h, const long *pattern);
  51.   int    (*cxNativeFont)(cdCtxCanvas* ctxcanvas, const char* font);
  52.   int    (*cxTextAlignment)(cdCtxCanvas* ctxcanvas, int alignment);
  53.   double (*cxTextOrientation)(cdCtxCanvas* ctxcanvas, double angle);
  54.   void   (*cxPalette)(cdCtxCanvas* ctxcanvas, int n, const long *palette, int mode);
  55.   long   (*cxBackground)(cdCtxCanvas* ctxcanvas, long color);
  56.   long   (*cxForeground)(cdCtxCanvas* ctxcanvas, long color);
  57.   void   (*cxTransform)(cdCtxCanvas* ctxcanvas, const double* matrix);
  58.  
  59.   void   (*cxGetImageRGB)(cdCtxCanvas* ctxcanvas, unsigned char *r, unsigned char *g, unsigned char *b, int x, int y, int w, int h);
  60.   void   (*cxPutImageRectRGB)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
  61.   void   (*cxPutImageRectRGBA)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char *r, const unsigned char *g, const unsigned char *b, const unsigned char *a, int x, int y, int w, int h, int xmin, int xmax, int ymin, int ymax);
  62.  
  63.   void   (*cxFPutImageRectRGB)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
  64.   void   (*cxFPutImageRectRGBA)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* r, const unsigned char* g, const unsigned char* b, const unsigned char* a, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
  65.   void   (*cxFPutImageRectMap)(cdCtxCanvas* ctxcanvas, int iw, int ih, const unsigned char* index, const long* colors, double x, double y, double w, double h, int xmin, int xmax, int ymin, int ymax);
  66.  
  67.   void   (*cxScrollArea)(cdCtxCanvas* ctxcanvas, int xmin, int xmax, int ymin, int ymax, int dx, int dy);
  68.  
  69.   cdCtxImage* (*cxCreateImage)(cdCtxCanvas* ctxcanvas, int w, int h);
  70.   void   (*cxKillImage)(cdCtxImage* ctximage);
  71.   void   (*cxGetImage)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y);
  72.   void   (*cxPutImageRect)(cdCtxCanvas* ctxcanvas, cdCtxImage* ctximage, int x, int y, int xmin, int xmax, int ymin, int ymax);
  73.  
  74.   void   (*cxNewRegion)(cdCtxCanvas* ctxcanvas);
  75.   int    (*cxIsPointInRegion)(cdCtxCanvas* ctxcanvas, int x, int y);
  76.   void   (*cxOffsetRegion)(cdCtxCanvas* ctxcanvas, int x, int y);
  77.   void   (*cxGetRegionBox)(cdCtxCanvas* ctxcanvas, int *xmin, int *xmax, int *ymin, int *ymax);
  78.  
  79.   int    (*cxActivate)(cdCtxCanvas* ctxcanvas);
  80.   void   (*cxDeactivate)(cdCtxCanvas* ctxcanvas);
  81.  
  82.   /* the driver must update these, when the canvas is created and
  83.      whenever the canvas change its size or bpp. */
  84.   int w,h;            /* size in pixels */              /****  pixel =   mm   * res  ****/
  85.   double w_mm, h_mm;  /* size in mm */                  /****   mm   =  pixel / res  ****/
  86.   double xres, yres;  /* resolution in pixels/mm */     /****   res  =  pixel / mm   ****/
  87.   int bpp;            /* number of bits per pixel */
  88.   int invert_yaxis;   /* invert Y coordinates before calling the driver,
  89.                          used only when the native Y axis orientation is top-bottom "!(cap&CD_CAP_YAXIS)".
  90.                          It is turned off by the driver if native transformation matrix is used. */
  91.   double matrix[6];
  92.   int use_matrix;
  93.  
  94.   /* clipping attributes */
  95.   int clip_mode;
  96.   cdRect clip_rect;
  97.   cdfRect clip_frect;
  98.   int clip_poly_n;
  99.   cdPoint* clip_poly;    /* only defined if integer polygon created, if exist clip_fpoly is NULL, and ->Poly exists */
  100.   cdfPoint* clip_fpoly;  /* only defined if real polygon created, if exist clip_poly is NULL, and ->fPoly exists  */
  101.  
  102.   /* clipping region attributes */
  103.   int new_region;
  104.   int combine_mode;
  105.  
  106.   /* color attributes */
  107.   long foreground, background;
  108.   int back_opacity, write_mode;
  109.  
  110.   /* primitive attributes */
  111.   int mark_type, mark_size;
  112.  
  113.   int line_style, line_width;
  114.   int line_cap, line_join;
  115.   int* line_dashes;
  116.   int line_dashes_count;
  117.  
  118.   int interior_style, hatch_style;
  119.   int fill_mode;
  120.  
  121.   char font_type_face[1024];
  122.   int font_style, font_size;
  123.   int text_alignment;
  124.   double text_orientation;
  125.   char native_font[1024];
  126.  
  127.   int pattern_w, pattern_h, pattern_size;
  128.   long* pattern;
  129.   int stipple_w, stipple_h, stipple_size;
  130.   unsigned char* stipple;
  131.  
  132.   /* origin */
  133.   int use_origin;
  134.   cdPoint origin;            /* both points contains the same coordinate always */
  135.   cdfPoint forigin;
  136.  
  137.   /* last polygon */
  138.   int poly_mode,
  139.       poly_n,                /* current number of vertices */
  140.       poly_size, fpoly_size; /* allocated number of vertices, only increases */
  141.   cdPoint* poly;             /* used during an integer polygon creation */
  142.   cdfPoint* fpoly;           /* used during an real polygon creation, only if ->cxFPoly exists */
  143.   int use_fpoly;
  144.  
  145.   /* last path */
  146.   int path_n,                /* current number of actions */
  147.       path_size;             /* allocated number of actions, only increases */
  148.   int* path;                 /* used during path creation */
  149.   int path_arc_index;        /* used for arc */
  150.  
  151.   /* simulation flags */
  152.   int sim_mode;
  153.  
  154.   /* WC */
  155.   double s, sx, tx, sy, ty;   /* Transform Window -> Viewport (scale+translation)*/
  156.   cdfRect window;             /* Window in WC */
  157.   cdRect viewport;            /* Viewport in pixels */
  158.  
  159.   cdAttribute* attrib_list[50];
  160.   int attrib_n;
  161.  
  162.   cdVectorFont* vector_font;
  163.   cdSimulation* simulation;
  164.   cdCtxCanvas* ctxcanvas;
  165.   cdContext* context;
  166.  
  167.   void* userdata;
  168. };

440bx

  • Hero Member
  • *****
  • Posts: 1876
Re: How to translate these macros into Pascal?
« Reply #3 on: April 03, 2020, 05:56:36 am »
Here is the struct _cdCanvas:
I wouldn't trust a conversion tool to translate that structure definition correctly to Pascal. 
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

guest65405

  • Guest
Re: How to translate these macros into Pascal?
« Reply #4 on: April 03, 2020, 06:55:17 am »
Here is the struct _cdCanvas:
I wouldn't trust a conversion tool to translate that structure definition correctly to Pascal.

I don't believe it either but h2pas seemed to done the job correctly:

Code: Pascal  [Select][+][-]
  1. _cdCanvas = record
  2.         signature : array[0..1] of char;
  3.         cxPixel : procedure (ctxcanvas:PcdCtxCanvas; x:longint; y:longint; color:longint);cdecl;
  4.         cxLine : procedure (ctxcanvas:PcdCtxCanvas; x1:longint; y1:longint; x2:longint; y2:longint);cdecl;
  5.         cxPoly : procedure (ctxcanvas:PcdCtxCanvas; mode:longint; points:PcdPoint; n:longint);cdecl;
  6.         cxRect : procedure (ctxcanvas:PcdCtxCanvas; xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  7.         cxBox : procedure (ctxcanvas:PcdCtxCanvas; xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  8.         cxArc : procedure (ctxcanvas:PcdCtxCanvas; xc:longint; yc:longint; w:longint; h:longint;
  9.                       angle1:double; angle2:double);cdecl;
  10.         cxSector : procedure (ctxcanvas:PcdCtxCanvas; xc:longint; yc:longint; w:longint; h:longint;
  11.                       angle1:double; angle2:double);cdecl;
  12.         cxChord : procedure (ctxcanvas:PcdCtxCanvas; xc:longint; yc:longint; w:longint; h:longint;
  13.                       angle1:double; angle2:double);cdecl;
  14.         cxText : procedure (ctxcanvas:PcdCtxCanvas; x:longint; y:longint; s:Pchar; len:longint);cdecl;
  15.         cxKillCanvas : procedure (ctxcanvas:PcdCtxCanvas);cdecl;
  16.         cxFont : function (ctxcanvas:PcdCtxCanvas; type_face:Pchar; style:longint; size:longint):longint;cdecl;
  17.         cxPutImageRectMap : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; index:Pbyte; colors:Plongint;
  18.                       x:longint; y:longint; w:longint; h:longint; xmin:longint;
  19.                       xmax:longint; ymin:longint; ymax:longint);cdecl;
  20.         cxGetFontDim : procedure (ctxcanvas:PcdCtxCanvas; max_width:Plongint; height:Plongint; ascent:Plongint; descent:Plongint);cdecl;
  21.         cxGetTextSize : procedure (ctxcanvas:PcdCtxCanvas; s:Pchar; len:longint; width:Plongint; height:Plongint);cdecl;
  22.         cxFlush : procedure (ctxcanvas:PcdCtxCanvas);cdecl;
  23.         cxClear : procedure (ctxcanvas:PcdCtxCanvas);cdecl;
  24.         cxFPixel : procedure (ctxcanvas:PcdCtxCanvas; x:double; y:double; color:longint);cdecl;
  25.         cxFLine : procedure (ctxcanvas:PcdCtxCanvas; x1:double; y1:double; x2:double; y2:double);cdecl;
  26.         cxFPoly : procedure (ctxcanvas:PcdCtxCanvas; mode:longint; points:PcdfPoint; n:longint);cdecl;
  27.         cxFRect : procedure (ctxcanvas:PcdCtxCanvas; xmin:double; xmax:double; ymin:double; ymax:double);cdecl;
  28.         cxFBox : procedure (ctxcanvas:PcdCtxCanvas; xmin:double; xmax:double; ymin:double; ymax:double);cdecl;
  29.         cxFArc : procedure (ctxcanvas:PcdCtxCanvas; xc:double; yc:double; w:double; h:double;
  30.                       angle1:double; angle2:double);cdecl;
  31.         cxFSector : procedure (ctxcanvas:PcdCtxCanvas; xc:double; yc:double; w:double; h:double;
  32.                       angle1:double; angle2:double);cdecl;
  33.         cxFChord : procedure (ctxcanvas:PcdCtxCanvas; xc:double; yc:double; w:double; h:double;
  34.                       angle1:double; angle2:double);cdecl;
  35.         cxFText : procedure (ctxcanvas:PcdCtxCanvas; x:double; y:double; s:Pchar; len:longint);cdecl;
  36.         cxClip : function (ctxcanvas:PcdCtxCanvas; mode:longint):longint;cdecl;
  37.         cxClipArea : procedure (ctxcanvas:PcdCtxCanvas; xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  38.         cxFClipArea : procedure (ctxcanvas:PcdCtxCanvas; xmin:double; xmax:double; ymin:double; ymax:double);cdecl;
  39.         cxBackOpacity : function (ctxcanvas:PcdCtxCanvas; opacity:longint):longint;cdecl;
  40.         cxWriteMode : function (ctxcanvas:PcdCtxCanvas; mode:longint):longint;cdecl;
  41.         cxLineStyle : function (ctxcanvas:PcdCtxCanvas; style:longint):longint;cdecl;
  42.         cxLineWidth : function (ctxcanvas:PcdCtxCanvas; width:longint):longint;cdecl;
  43.         cxLineJoin : function (ctxcanvas:PcdCtxCanvas; join:longint):longint;cdecl;
  44.         cxLineCap : function (ctxcanvas:PcdCtxCanvas; cap:longint):longint;cdecl;
  45.         cxInteriorStyle : function (ctxcanvas:PcdCtxCanvas; style:longint):longint;cdecl;
  46.         cxHatch : function (ctxcanvas:PcdCtxCanvas; style:longint):longint;cdecl;
  47.         cxStipple : procedure (ctxcanvas:PcdCtxCanvas; w:longint; h:longint; stipple:Pbyte);cdecl;
  48.         cxPattern : procedure (ctxcanvas:PcdCtxCanvas; w:longint; h:longint; pattern:Plongint);cdecl;
  49.         cxNativeFont : function (ctxcanvas:PcdCtxCanvas; font:Pchar):longint;cdecl;
  50.         cxTextAlignment : function (ctxcanvas:PcdCtxCanvas; alignment:longint):longint;cdecl;
  51.         cxTextOrientation : function (ctxcanvas:PcdCtxCanvas; angle:double):double;cdecl;
  52.         cxPalette : procedure (ctxcanvas:PcdCtxCanvas; n:longint; palette:Plongint; mode:longint);cdecl;
  53.         cxBackground : function (ctxcanvas:PcdCtxCanvas; color:longint):longint;cdecl;
  54.         cxForeground : function (ctxcanvas:PcdCtxCanvas; color:longint):longint;cdecl;
  55.         cxTransform : procedure (ctxcanvas:PcdCtxCanvas; matrix:Pdouble);cdecl;
  56.         cxGetImageRGB : procedure (ctxcanvas:PcdCtxCanvas; r:Pbyte; g:Pbyte; b:Pbyte; x:longint;
  57.                       y:longint; w:longint; h:longint);cdecl;
  58.         cxPutImageRectRGB : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; r:Pbyte; g:Pbyte;
  59.                       b:Pbyte; x:longint; y:longint; w:longint; h:longint;
  60.                       xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  61.         cxPutImageRectRGBA : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; r:Pbyte; g:Pbyte;
  62.                       b:Pbyte; a:Pbyte; x:longint; y:longint; w:longint;
  63.                       h:longint; xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  64.         cxFPutImageRectRGB : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; r:Pbyte; g:Pbyte;
  65.                       b:Pbyte; x:double; y:double; w:double; h:double;
  66.                       xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  67.         cxFPutImageRectRGBA : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; r:Pbyte; g:Pbyte;
  68.                       b:Pbyte; a:Pbyte; x:double; y:double; w:double;
  69.                       h:double; xmin:longint; xmax:longint; ymin:longint; ymax:longint);cdecl;
  70.         cxFPutImageRectMap : procedure (ctxcanvas:PcdCtxCanvas; iw:longint; ih:longint; index:Pbyte; colors:Plongint;
  71.                       x:double; y:double; w:double; h:double; xmin:longint;
  72.                       xmax:longint; ymin:longint; ymax:longint);cdecl;
  73.         cxScrollArea : procedure (ctxcanvas:PcdCtxCanvas; xmin:longint; xmax:longint; ymin:longint; ymax:longint;
  74.                       dx:longint; dy:longint);cdecl;
  75.         cxCreateImage : function (ctxcanvas:PcdCtxCanvas; w:longint; h:longint):PcdCtxImage;cdecl;
  76.         cxKillImage : procedure (ctximage:PcdCtxImage);cdecl;
  77.         cxGetImage : procedure (ctxcanvas:PcdCtxCanvas; ctximage:PcdCtxImage; x:longint; y:longint);cdecl;
  78.         cxPutImageRect : procedure (ctxcanvas:PcdCtxCanvas; ctximage:PcdCtxImage; x:longint; y:longint; xmin:longint;
  79.                       xmax:longint; ymin:longint; ymax:longint);cdecl;
  80.         cxNewRegion : procedure (ctxcanvas:PcdCtxCanvas);cdecl;
  81.         cxIsPointInRegion : function (ctxcanvas:PcdCtxCanvas; x:longint; y:longint):longint;cdecl;
  82.         cxOffsetRegion : procedure (ctxcanvas:PcdCtxCanvas; x:longint; y:longint);cdecl;
  83.         cxGetRegionBox : procedure (ctxcanvas:PcdCtxCanvas; xmin:Plongint; xmax:Plongint; ymin:Plongint; ymax:Plongint);cdecl;
  84.         cxActivate : function (ctxcanvas:PcdCtxCanvas):longint;cdecl;
  85.         cxDeactivate : procedure (ctxcanvas:PcdCtxCanvas);cdecl;
  86.         w : longint;
  87.         h : longint;
  88.         w_mm : double;
  89.         h_mm : double;
  90.         xres : double;
  91.         yres : double;
  92.         bpp : longint;
  93.         invert_yaxis : longint;
  94.         matrix : array[0..5] of double;
  95.         use_matrix : longint;
  96.         clip_mode : longint;
  97.         clip_rect : cdRect;
  98.         clip_frect : cdfRect;
  99.         clip_poly_n : longint;
  100.         clip_poly : PcdPoint;
  101.         clip_fpoly : PcdfPoint;
  102.         new_region : longint;
  103.         combine_mode : longint;
  104.         foreground : longint;
  105.         background : longint;
  106.         back_opacity : longint;
  107.         write_mode : longint;
  108.         mark_type : longint;
  109.         mark_size : longint;
  110.         line_style : longint;
  111.         line_width : longint;
  112.         line_cap : longint;
  113.         line_join : longint;
  114.         line_dashes : Plongint;
  115.         line_dashes_count : longint;
  116.         interior_style : longint;
  117.         hatch_style : longint;
  118.         fill_mode : longint;
  119.         font_type_face : array[0..1023] of char;
  120.         font_style : longint;
  121.         font_size : longint;
  122.         text_alignment : longint;
  123.         text_orientation : double;
  124.         native_font : array[0..1023] of char;
  125.         pattern_w : longint;
  126.         pattern_h : longint;
  127.         pattern_size : longint;
  128.         pattern : Plongint;
  129.         stipple_w : longint;
  130.         stipple_h : longint;
  131.         stipple_size : longint;
  132.         stipple : Pbyte;
  133.         use_origin : longint;
  134.         origin : cdPoint;
  135.         forigin : cdfPoint;
  136.         poly_mode : longint;
  137.         poly_n : longint;
  138.         poly_size : longint;
  139.         fpoly_size : longint;
  140.         poly : PcdPoint;
  141.         fpoly : PcdfPoint;
  142.         use_fpoly : longint;
  143.         path_n : longint;
  144.         path_size : longint;
  145.         path : Plongint;
  146.         path_arc_index : longint;
  147.         sim_mode : longint;
  148.         s : double;
  149.         sx : double;
  150.         tx : double;
  151.         sy : double;
  152.         ty : double;
  153.         window : cdfRect;
  154.         viewport : cdRect;
  155.         attrib_list : array[0..49] of PcdAttribute;
  156.         attrib_n : longint;
  157.         vector_font : PcdVectorFont;
  158.         simulation : PcdSimulation;
  159.         ctxcanvas : PcdCtxCanvas;
  160.         context : PcdContext;
  161.         userdata : pointer;
  162.       end;

Please help me translate these macros into Pascal. Except the first macro, other macros are fairly simple. I used to convert them to C functions but h2pas still fails. So I want to compare mine version with yours to see what I have done wrong or is it h2pas' bug.

440bx

  • Hero Member
  • *****
  • Posts: 1876
Re: How to translate these macros into Pascal?
« Reply #5 on: April 03, 2020, 07:42:19 am »
Please help me translate these macros into Pascal. Except the first macro, other macros are fairly simple. I used to convert them to C functions but h2pas still fails. So I want to compare mine version with yours to see what I have done wrong or is it h2pas' bug.
Are you referring to the macros in the first post ?

On your reply, post what it is that you've done that isn't working.  That will be helpful.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 64bit.

guest65405

  • Guest
Re: How to translate these macros into Pascal?
« Reply #6 on: April 03, 2020, 07:46:34 am »
Please help me translate these macros into Pascal. Except the first macro, other macros are fairly simple. I used to convert them to C functions but h2pas still fails. So I want to compare mine version with yours to see what I have done wrong or is it h2pas' bug.
Are you referring to the macros in the first post ?

Yes, the macros in my first post.

guest65405

  • Guest
Re: How to translate these macros into Pascal?
« Reply #7 on: April 03, 2020, 09:42:37 am »
I will give up translating these headers with h2pas. I will try Delphi Swig. Thread locked.

guest65405

  • Guest
Re: How to translate these macros into Pascal?
« Reply #8 on: April 04, 2020, 09:50:58 am »
I will give up translating these headers with h2pas. I will try Delphi Swig. Thread locked.

Update: I gave up. Delphi Swig only worsen the problem but not help me at all. BTW, I still think these macros are translatable. But being exhausted I think I have to give up this time.

 

TinyPortal © 2005-2018