view anagram/support/cint.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 607e3be6bad8
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * cint.h
 */

#ifndef CINT_H
#define CINT_H

#ifdef VACLGUI
#include <ipoint.hpp>
#endif

struct rect;


struct cint {
  int x, y;

  cint()
    : x(0), y(0)
  {}
  cint(const int xarg, const int yarg)
    : x(xarg), y(yarg)
  {}
  cint(const cint &c)
    : x(c.x), y(c.y)
  {}

#ifdef VACLGUI
  cint(const IPair &p)
    : x(p.coord1()), y(p.coord2())
  {}
  operator IPair () const {
    return IPair(x, y);
  }
#endif

  cint operator = (cint r) {
     x = r.x;
     y = r.y;
     return r;
  }

  int operator == (const cint r) const { return (x == r.x && y == r.y); }
  int operator != (const cint r) const { return (x != r.x || y != r.y); }
  cint operator + (cint r) const {
    r.x += x;
    r.y += y;
    return r;
  }
  cint operator += (const cint r) {
    x += r.x;
    y += r.y;
    return *this;
  }
  cint operator - (cint r) const {
    r.x = x - r.x;
    r.y = y - r.y;
    return r;
  }
  cint operator -= (const cint r) {
    x -= r.x;
    y -= r.y;
    return *this;
  }
  int operator <= (const cint &s) const;
  int operator >= (const cint &s) const;
  int operator < (const cint &s) const;
  int operator > (const cint &s) const;
  int on_boundary(cint, cint) const;
  int inside_rect(cint, cint) const;
  int inside_rect(rect) const;
};

struct rect {
  cint pos, size;
};

cint lrci(cint a, cint b);
int  measure_line(const char *s);
cint measure_string(const char *s);
cint place(cint measure, cint size, int jm);
rect place_rect(rect w, cint s, int jm);
cint ulci(cint a, cint b);


#endif /* CINT_H */