示例#1
0
文件: cmap.c 项目: RushOnline/bouquet
/* generate map putvlc method */
static void c_map_put(symbol_t *sp, list_t *stmts)
{
	c_outi("\n");
	if (cpp()) {
		if (sp->ptype->ident == CLASS_TYPE) 
			c_outi("int %s::putvlc(%s &%sbs, %s%s *%sarg, int *%sparse, int *%scode) {\n", 
                   sp->name, bitstream_class, prefix, 
                   ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                   sp->ptype->name, prefix, prefix, prefix);
		else
			c_outi("int %s::putvlc(%s &%sbs, %s%s %sarg, int *%sparse, int *%scode) {\n", 
                   sp->name, bitstream_class, prefix, 
                   ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                   sp->ptype->name, prefix, prefix, prefix);
	}
	else if (java()) {
		c_outi("public static %s putvlc(%s %sbs, %s %sarg) throws IOException {\n",
               map_result, bitstream_class, prefix, sp->ptype->name, prefix);
	}
    c_identlevel++;

    /* declare hit variable (used for return value), data and size */
	c_outi("int %sdata = 0, %ssize = 0;\n", prefix, prefix);
    c_outi("int %sesc_bits = 0;\n", prefix);
	if (cpp()) 
		c_outi("int %shit = 1;\n\n", prefix);
	else if (java())
		c_outi("boolean %shit = true;\n\n", prefix);

    /* output the core putvlc code (series of putbits with case statements */
    c_map_put_core(sp, stmts);

    c_identlevel--;
    c_outi("}\n");
}
示例#2
0
文件: cxml.c 项目: RushOnline/bouquet
/* put the parsing of a variable with simple parse expr as an XML element */
void c_xml_var_simple(symbol_t* sp, node_t *align, int dims, node_t **dim)
{
    c_outi("if (bAttr) {\n");
    c_identlevel++;    

    if (cpp())
        c_outi("%s(\"<%s", xml_func3, sp->name);
    else if (java())
        c_outi("XML.%s(\"<%s", xml_func3, sp->name);
 
    /* bit values are accessed as integer values */
    if (sp->ptype->ident == CHAR) {
        if (sp->modifiers & M_UNSIGNED) 
            c_out(" type=\\\"flUChar\\\"");
        else 
            c_out(" type=\\\"flSChar\\\"");
    }
    else if (sp->ptype->ident <= INT) {
        if (sp->modifiers & M_UNSIGNED) 
            c_out(" type=\\\"flUInt\\\"");
        else 
            c_out(" type=\\\"flSInt\\\"");
    }
    else if (sp->ptype->ident == FLOAT) 
        c_out(" type=\\\"flFloat\\\"");
    else if (sp->ptype->ident == DOUBLE)
        c_out(" type=\\\"flDouble\\\"");
	else 
        fatal("Internal error CX%d: Expected simple type", __LINE__);

    c_xml_var_helper(sp, align, dims, dim);

    c_identlevel--;    
    c_outi("}\n");

    // !bAttr

    c_outi("else {\n");
    c_identlevel++; 

    if (cpp())
        c_outi("%s(\"<%s", xml_func3, sp->name);
    else if (java())
        c_outi("XML.%s(\"<%s", xml_func3, sp->name);

    c_xml_var_helper(sp, align, dims, dim);

    c_identlevel--;    
    c_outi("}\n");
}
示例#3
0
文件: mfpemul.c 项目: slippyex/OSME
/* Write Timer Data Register:

   Changing the value of the TDR change the value of the internal
   reset latch. However when the timer is stopped the reset value is
   reload into TDR in the next MFP cycle (so it seems to be the case
   according to my test on a real ST). The tricky point is that as MFP
   and CPU clock are separate (for Atari-ST) reading the value just
   after a write can occur before the next MFP cycle in which case the
   current TDR (not the one written) is returned! Fortunatly we don't
   really need to emulate this since it is more a glitch than anything
   a no one should have used it!

   Motorola Datasheet: the TDRs contain the value of their respective
   main counter. This value was captured on the last low-to-high
   transistion of the data strobe pin. The main counter is initialized
   by writting the to the TDR. If the timer is stopped the data is
   loaded simultaneously into both TDR and maincounter. If the TDR is
   written to while the timer is enabled, the value is not loaded into
   the timer until the timer counts through 01. If a write is
   performed while the timer is counting through 01 then an
   *INDETERMINATE* value is loaded into the main counter.

*/
void mfp_put_tdr(mfp_t * const mfp, int timer, int v, bogoc68_t bogoc)
{
  mfp_timer_t * const ptimer = &mfp->timers[timer&3];
  const uint68_t old_tdr = ptimer->tdr_res;

  /* Interrupt when count down to 0 so 0 is 256 */
  v  = (u8)v; v += (!v)<<8;
  ptimer->tdr_res = v;

  if (!ptimer->tcr) {
    ptimer->tdr_cur = v;
    if (mfp_feature) fprintf(stderr, "Reload timer-%c TDR @%u => %u\n",
	    ptimer->def.letter, bogoc, ptimer->tdr_res);
  } else if (ptimer->tcr && v != old_tdr) {
    uint68_t old_frq = timerfrq(old_tdr);
    if (mfp_feature) fprintf(stderr,
	    "Change timer-%c @%u cti:%u psw:%u(%u) cpp:%u"
	    " => %u(%u)->%u(%u)hz\n",
	    ptimer->def.letter, bogoc, ptimer->cti,
	    prediv_width[ptimer->tcr], ptimer->tcr,
	    cpp(ptimer->tdr_res),
	    old_frq,old_tdr,
	    timerfrq(ptimer->tdr_res), ptimer->tdr_res);
  }
}
示例#4
0
文件: cmap.c 项目: RushOnline/bouquet
/* output assignment statements for a simple map entry */
static void c_map_putxml_assign_simple(symbol_t* sp, list_t* entry)
{
    list_t *p = entry->sub1;

    if (p->type == ESC_FTYPE || p->type == ESC_MAP) {
        c_outi("%sesc_bits = ", prefix);
        c_expression(p->e3, 0);
        c_out(";\n");
    }

    if (cpp()) 
        c_outi("*%sarg = ", prefix);
    else if (java())
        c_outi("%sarg = ", prefix);

    /* figure out if we have simple assignment or escape */
    if (p->type == ESC_FTYPE || p->type == ESC_MAP)
        c_map_get_assign_esc(p);
    else {
		if (sp->ptype->ident == FLOAT && entry->sub1->e1->type == DOUBLE)
            c_out("(float)");
		c_expression(p->e1, 0);
	}
    c_out(";\n");

    /* output an element for the value, which corresponds to the code */
    c_xml_map_var_simple(sp, 1);
}
示例#5
0
文件: cmap.c 项目: RushOnline/bouquet
/* output assignment statements for a simple map entry */
static void c_map_get_assign_simple(symbol_t* sp, list_t* entry)
{
    list_t *p = entry->sub1;

    if (p->type == ESC_FTYPE || p->type == ESC_MAP) {
        c_outi("%sesc_bits = ", prefix);
        c_expression(p->e3, 0);
        c_out(";\n");
    }

    if (cpp()) 
        c_outi("*%sarg = ", prefix);
    else if (java())
        c_outi("%sarg = ", prefix);

    /* figure out if we have simple assignment or escape */
    if (p->type == ESC_FTYPE || p->type == ESC_MAP)
        c_map_get_assign_esc(p);
    else {
		if (sp->ptype->ident == FLOAT && p->e1->type == DOUBLE)
            c_out("(float)");
		c_expression(p->e1, 0);
	}
    c_out(";\n");
}
示例#6
0
/* Write Timer Data Register:

   Changing the value of the TDR change the value of the internal
   reset latch. However when the timer is stopped the reset value is
   reload into TDR in the next MFP cycle (so it seems to be the case
   according to my test on a real ST). The tricky point is that as MFP
   and CPU clock are separate (for Atari-ST) reading the value just
   after a write can occur before the next MFP cycle in which case the
   current TDR (not the one written) is returned! Fortunatly we don't
   really need to emulate this since it is more a glitch than anything
   and no one should have used it!

   Motorola Datasheet: the TDRs contain the value of their respective
   main counter. This value was captured on the last low-to-high
   transistion of the data strobe pin. The main counter is initialized
   by writting the to the TDR. If the timer is stopped the data is
   loaded simultaneously into both TDR and maincounter. If the TDR is
   written to while the timer is enabled, the value is not loaded into
   the timer until the timer counts through 01. If a write is
   performed while the timer is counting through 01 then an
   INDETERMINATE value is loaded into the main counter.

*/
void mfp_put_tdr(mfp_t * const mfp, int timer, int68_t v, const bogoc68_t bogoc)
{
  mfp_timer_t * const  ptimer = &mfp->timers[timer&3];
#ifndef NDEBUG
  const uint_t old_tdr = ptimer->tdr_res;
#endif

  /* Interrupt when count down to 0 so 0 is 256 */
  v  = (u8)v; v += (!v)<<8;
  ptimer->tdr_res = v;

  if (!ptimer->tcr) {
    ptimer->tdr_cur = v;
    TRACE68(mfp_cat,
          MYHD "timer-%c -- reload TDR @%u -- %u\n",
            ptimer->def.letter, (unsigned) bogoc, (unsigned) ptimer->tdr_res);
  }
#ifndef NDEBUG
  else if (ptimer->tcr && v != old_tdr) {
    uint_t old_frq = timerfrq(old_tdr);
    TRACE68(mfp_cat,
            MYHD "timer-%c -- change @%u cti:%u psw:%u(%u) cpp:%u"
            " -- %u(%u) -> %u(%u)hz\n",
            ptimer->def.letter, (unsigned) bogoc, (unsigned) ptimer->cti,
            (unsigned) prediv_width[ptimer->tcr], (unsigned) ptimer->tcr,
            (unsigned) cpp(ptimer->tdr_res),
            (unsigned) old_frq, (unsigned) old_tdr,
            (unsigned) timerfrq(ptimer->tdr_res), (unsigned) ptimer->tdr_res);
  }
#endif
}
示例#7
0
void mfp_adjust_bogoc(mfp_t * const mfp, const bogoc68_t bogoc)
{
  mfp_timer_t *ptimer;

  if (!bogoc) return;
  for (ptimer = mfp->timers; ptimer != mfp->timers+4; ++ptimer) {
    if (ptimer->tcr) {
      if (ptimer->cti < bogoc) {
        TRACE68(mfp_cat,
              MYHD "timer-%c -- adjust -- cti:%u cycle:%u\n",
              ptimer->def.letter, (unsigned) ptimer->cti, (unsigned) bogoc);
      }
      assert(ptimer->cti >= bogoc);
      while (ptimer->cti < bogoc) {
        /* $$$ !!! SHOULD NOT HAPPEN !!! */
        ++ptimer->int_lost;
        ptimer->cti += cpp(ptimer->tdr_res);
      }
      if (ptimer->int_lost) {
        msg68_critical(MYHD "timer-%c -- adjust has lost interrupt -- %d\n",
                       ptimer->def.letter, ptimer->int_lost);
        ptimer->int_lost = 0;
      }
      ptimer->cti -= bogoc;
    }
  }
}
示例#8
0
/* Control register changes, adjust ``cti'' (cycle to next interrupt)
 *
 *    This case is a bit tricky : Changing timer prescale on the fly
 *    may have unpredictable result mostly because we dunno how
 *    prescaler works exactly. Here I assume the prescaler is
 *    resetted.
 *
 *    !!! chipmon of synergy does !!!
 *
 */
static inline
void reconf_timer(mfp_timer_t * const ptimer, int tcr, const bogoc68_t bogoc)
{
#if !defined(NDEBUG) || !defined(CPP_SUPPORTS_VA_MACROS)
  uint_t          frq = timerfrq(ptimer->tdr_res); /* old frequency       */
#endif
  const bogoc68_t cti = ptimer->cti - bogoc;       /* cycles to interrupt */
  const uint_t    psw = prediv_width[ptimer->tcr]; /* cycles count-down   */
  const uint_t    cnt = cti/psw;                   /* count-down          */
  const uint_t    psr = cti % psw;
  /* const uint68_t  psc = psw-psr; */

  /* cnt%ptimer->tdr_res+1; no MODULO since TDR may have change and anyway
     cti was calculated with 1 timer cycle !!! */
  const uint_t    tdr = cnt+1;
  const cycle68_t new_psw = prediv_width[(int)tcr];

  if (bogoc > ptimer->cti) {
    TRACE68(mfp_cat,
          MYHD "timer-%c -- reconf out of range -- @%u > cti:%u\n",
          ptimer->def.letter, (unsigned) bogoc, (unsigned) ptimer->cti);
    ptimer->cti = bogoc + psw * ptimer->tdr_res;
  } else {
    ptimer->cti = bogoc + psr + (tdr-1) * new_psw;
    ptimer->cti = bogoc + /* psr + */ (tdr/* -1 */) * new_psw;
  }

  ptimer->tcr = tcr;

  TRACE68(mfp_cat,
          MYHD "timer-%c -- reconf @%u cti:%u cpp:%u -- %u:%uhz\n",
          ptimer->def.letter, (unsigned) bogoc,
          (unsigned) ptimer->cti, (unsigned) cpp(ptimer->tdr_res),
          (unsigned) frq, (unsigned) timerfrq(ptimer->tdr_res));
}
示例#9
0
文件: cmap.c 项目: RushOnline/bouquet
/* generate map putxml method */
static void c_map_putxml(symbol_t* sp, list_t* stmts)
{
	c_out("\n");
    if (cpp()) {
        c_outi("int %s::putxml(%s &%sbs, short int bAttr, %s%s *%sarg, int *%sparse, int *%scode) {\n", 
               sp->name, bitstream_class, prefix, 
               ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
               sp->ptype->name, prefix, prefix, prefix);
		c_identlevel++;
		/* declare hit variable (used for return value), data and size */
		c_outi("int %sdata = 0, %ssize = 0;\n", prefix, prefix);
        c_outi("int %sesc_bits = 0;\n", prefix);
		c_outi("int %shit = 1;\n\n", prefix);
    } 
    else if (java()) {
		c_outi("public static %s putxml(%s %sbs, boolean bAttr) throws IOException {\n", 
               map_result, bitstream_class, prefix, sp->ptype->name, prefix, prefix, prefix);
		c_identlevel++;
		/* declare hit variable (used for return value), data and size */
		c_outi("int %sdata = 0, %ssize = 0;\n", prefix, prefix);
        c_outi("int %sesc_bits = 0;\n", prefix);
		c_outi("boolean %shit = true;\n", prefix);
		if (sp->ptype->ident == CLASS_TYPE) 
			c_outi("%s %sarg = new %s();\n\n", sp->ptype->name, prefix, sp->ptype->name);
		else
			c_outi("%s %sarg = %s%s;\n\n",
                   sp->ptype->name, prefix, (sp->ptype->ident == FLOAT) ? "(float)" : "",
                   (sp->ptype->ident <= INT) ? "0" : "0.0");
	}
    
    /* output the core putxml code (series of getbits with case statements) */
    c_map_putxml_core(sp, stmts);

    /* return code and size, if requested */
    if (cpp()) {
        c_outi("if (%sparse != NULL) *%sparse = %ssize;\n", prefix, prefix, prefix);
        c_outi("if (%scode != NULL) *%scode = %sdata;\n", prefix, prefix, prefix);
		c_outi("return %shit;\n", prefix);
	}
    else if (java())
        c_outi("return new %s(%shit, %sdata, %ssize, %sarg);\n", map_result, prefix, prefix, prefix, prefix);
	
    c_identlevel--;
    c_outi("}\n");
}
示例#10
0
/* output verbatim code */
void verbatim(verbatim_t *vp)
{
    if (vp == NULL || vp->str == NULL) return;
    
    /* output preprocessor directive for file/line info */
    if (!supp_lineno && cpp()) {
        c_out("#");
        c_out("line %d \"%s\"\n", vp->lineno, filename);
    }
    c_outi("%s\n", vp->str);
}
示例#11
0
int main( int argc, char *argv[] )
 {
  std::cout << __FUNCTION__ << std::endl;
  // Some typedefs
  typedef ::reflection::operation::transfer::observe_class<std::ostream> observe_type;
  typedef ::reflection::operation::transfer::xml::print_struct<std::ostream> xml_type;
  typedef ::reflection::operation::transfer::json::print_struct<std::ostream> json_type;
  typedef ::reflection::operation::transfer::cpp::print_struct<std::ostream> cpp_type;
  typedef ::reflection::operation::transfer::yaml::print_struct<std::ostream> yaml_type;
  typedef ::reflection::operation::transfer::protobuf::print_struct<std::ostream> protobuf_type;
  typedef ::reflection::operation::transfer::ini::print_struct<std::ostream> ini_type;

  MyClassReflection   r;  //!< Reflection of Original, with pointing to some instance

  observe_type observe; //!< Algorithm for observation AKA serialization

  { cpp_type cpp( observe ); //!< Fill observator how to serialize.
                    observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r ); // CPPize for example

  observe.clear();
  { xml_type xml( observe );//!< Fill observator how to serialize.
                  observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r ); // XMLize

  observe.clear();
  { json_type json( observe );//!< Fill observator how to serialize.
                    observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r ); // JSONize

  observe.clear();
  { yaml_type yaml( observe );//!< Fill observator how to serialize.
                    observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r ); // YAMLize

  observe.clear();
  { protobuf_type protobuf( observe );//!< Fill observator how to serialize.
                            observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r ); // Protobufferize

  observe.clear();
  { ini_type ini( observe );//!< Fill observator how to serialize.
                  observe.register_class<MyBaseClass, MyBaseClasssReflectionView>( );
  }
  observe.view( std::cout, r );  // INIrize

  return EXIT_SUCCESS;
 }
示例#12
0
文件: mfpemul.c 项目: slippyex/OSME
/* Resume a stopped timer: tcr 0->!0
 */
static __inline
void resume_timer(mfp_timer_t * const ptimer, int tcr, bogoc68_t bogoc)
{
  ptimer->tcr = tcr;
  ptimer->cti = bogoc + ptimer->tdr_cur * prediv_width[tcr] - ptimer->psc;
  
  if (mfp_feature) fprintf(stderr,
	  "Resume timer-%c @%u cti:%u cpp:%u "
	  "tdr:%u/%u psw:%u(%u) => %dhz\n", 
	  ptimer->def.letter, bogoc, ptimer->cti,
	  cpp(ptimer->tdr_res),
	  (int)ptimer->tdr_cur,(int)ptimer->tdr_res,
	  prediv_width[ptimer->tcr],ptimer->tcr,
	  timerfrq(ptimer->tdr_res));
}
示例#13
0
/* Resume a stopped timer: tcr 0->!0
 */
static inline
void resume_timer(mfp_timer_t * const ptimer, int tcr, bogoc68_t bogoc)
{
  ptimer->tcr = tcr;
  ptimer->cti = bogoc + ptimer->tdr_cur * prediv_width[tcr] - ptimer->psc;

  TRACE68(mfp_cat,
          MYHD "timer-%c  -- resume @%u cti:%u cpp:%u "
          "tdr:%u/%u psw:%u(%u) -- %uhz\n",
          ptimer->def.letter, (unsigned) bogoc, (unsigned) ptimer->cti,
          (unsigned) cpp(ptimer->tdr_res),
          (unsigned) ptimer->tdr_cur, (unsigned) ptimer->tdr_res,
          (unsigned) prediv_width[ptimer->tcr], (unsigned) ptimer->tcr,
          (unsigned) timerfrq(ptimer->tdr_res));
}
示例#14
0
文件: input.c 项目: cheusov/nbase
/*
 * Eat all of the lines in the input file, attempting to categorize
 * them by their various flavors
 */
void
eaterrors(int *r_errorc, Eptr **r_errorv)
{
	Errorclass errorclass = C_SYNC;
	char *line;
	const char *inbuffer;
	size_t inbuflen;

    for (;;) {
	if ((inbuffer = fgetln(errorfile, &inbuflen)) == NULL)
		break;
	line = Calloc(inbuflen + 1, sizeof(char));
	memcpy(line, inbuffer, inbuflen);
	line[inbuflen] = '\0';
	wordvbuild(line, &cur_wordc, &cur_wordv);

	/*
	 * for convenience, convert cur_wordv to be 1 based, instead
	 * of 0 based.
	 */
	cur_wordv -= 1;
	if (cur_wordc > 0 &&
	   ((( errorclass = onelong() ) != C_UNKNOWN)
	   || (( errorclass = cpp() ) != C_UNKNOWN)
	   || (( errorclass = gcc45ccom() ) != C_UNKNOWN)
	   || (( errorclass = pccccom() ) != C_UNKNOWN)
	   || (( errorclass = richieccom() ) != C_UNKNOWN)
	   || (( errorclass = lint0() ) != C_UNKNOWN)
	   || (( errorclass = lint1() ) != C_UNKNOWN)
	   || (( errorclass = lint2() ) != C_UNKNOWN)
	   || (( errorclass = lint3() ) != C_UNKNOWN)
	   || (( errorclass = make() ) != C_UNKNOWN)
	   || (( errorclass = f77() ) != C_UNKNOWN)
	   || ((errorclass = pi() ) != C_UNKNOWN)
	   || (( errorclass = ri() )!= C_UNKNOWN)
	   || (( errorclass = mod2() )!= C_UNKNOWN)
	   || (( errorclass = troff() )!= C_UNKNOWN))
	) ;
	else
		errorclass = catchall();
	if (cur_wordc)
		erroradd(cur_wordc, cur_wordv+1, errorclass, C_UNKNOWN);
    }
#ifdef FULLDEBUG
    printf("%d errorentrys\n", nerrors);
#endif
    arrayify(r_errorc, r_errorv, er_head);
}
示例#15
0
QList<HeaderPath> GccToolChain::gccHeaderPaths(const Utils::FileName &gcc, const QStringList &env, const QString &sysrootPath)
{
    QList<HeaderPath> systemHeaderPaths;
    QStringList arguments;
    if (!sysrootPath.isEmpty())
        arguments.append(QString::fromLatin1("--sysroot=%1").arg(sysrootPath));
    arguments << QLatin1String("-xc++")
              << QLatin1String("-E")
              << QLatin1String("-v")
              << QLatin1String("-");

    QByteArray line;
    QByteArray data = runGcc(gcc, arguments, env);
    QBuffer cpp(&data);
    cpp.open(QIODevice::ReadOnly);
    while (cpp.canReadLine()) {
        line = cpp.readLine();
        if (line.startsWith("#include"))
            break;
    }

    if (!line.isEmpty() && line.startsWith("#include")) {
        HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
        while (cpp.canReadLine()) {
            line = cpp.readLine();
            if (line.startsWith("#include")) {
                kind = HeaderPath::GlobalHeaderPath;
            } else if (! line.isEmpty() && QChar(QLatin1Char(line.at(0))).isSpace()) {
                HeaderPath::Kind thisHeaderKind = kind;

                line = line.trimmed();

                const int index = line.indexOf(" (framework directory)");
                if (index != -1) {
                    line.truncate(index);
                    thisHeaderKind = HeaderPath::FrameworkHeaderPath;
                }

                systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
            } else if (line.startsWith("End of search list.")) {
                break;
            } else {
                qWarning("%s: Ignoring line: %s", __FUNCTION__, line.constData());
            }
        }
    }
    return systemHeaderPaths;
}
示例#16
0
文件: errorinput.c 项目: kcrca/kcrca
void
eaterrors(int *r_errorc, Eptr **r_errorv)
{
	Errorclass	errorclass = C_SYNC;

	for (;;) {
		if (fgets(inbuffer, BUFSIZ, errorfile) == NULL)
			break;
		wordvbuild(inbuffer, &wordc, &wordv);
		/*
		 * for convenience, convert wordv to be 1 based, instead
		 * of 0 based.
		 */
		wordv -= 1;
		/*
		 * check for sunf77 errors has to be done before
		 * pccccom to be able to distingush between the two
		 */
		if ((wordc > 0) &&
		    (((errorclass = onelong()) != C_UNKNOWN) ||
		    ((errorclass = cpp()) != C_UNKNOWN) ||
		    ((errorclass = sunf77()) != C_UNKNOWN) ||
		    ((errorclass = pccccom()) != C_UNKNOWN) ||
		    ((errorclass = richieccom()) != C_UNKNOWN) ||
		    ((errorclass = lint0()) != C_UNKNOWN) ||
		    ((errorclass = lint1()) != C_UNKNOWN) ||
		    ((errorclass = lint2()) != C_UNKNOWN) ||
		    ((errorclass = lint3()) != C_UNKNOWN) ||
		    ((errorclass = make()) != C_UNKNOWN) ||
		    ((errorclass = f77()) != C_UNKNOWN) ||
		    ((errorclass = pi()) != C_UNKNOWN) ||
		    ((errorclass = ri()) != C_UNKNOWN) ||
		    ((errorclass = troff()) != C_UNKNOWN) ||
		    ((errorclass = mod2()) != C_UNKNOWN) ||
		    ((errorclass = troff()) != C_UNKNOWN))) {
		    /* EMPTY */
		} else {
			errorclass = catchall();
		}
		if (wordc)
			erroradd(wordc, wordv+1, errorclass, C_UNKNOWN);
	}
#ifdef FULLDEBUG
	printf("%d errorentrys\n", nerrors);
#endif
	arrayify(r_errorc, r_errorv, er_head);
}
示例#17
0
static QList<HeaderPath> gccHeaderPathes(const QString &gcc, const QStringList &env)
{
    QList<HeaderPath> systemHeaderPaths;
    QStringList arguments;
    arguments << QLatin1String("-xc++")
              << QLatin1String("-E")
              << QLatin1String("-v")
              << QLatin1String("-");

    QByteArray line;
    QByteArray data = runGcc(gcc, arguments, env);
    QBuffer cpp(&data);
    while (cpp.canReadLine()) {
        line = cpp.readLine();
        if (line.startsWith("#include"))
            break;
    }

    if (!line.isEmpty() && line.startsWith("#include")) {
        HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
        while (cpp.canReadLine()) {
            line = cpp.readLine();
            if (line.startsWith("#include")) {
                kind = HeaderPath::GlobalHeaderPath;
            } else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) {
                HeaderPath::Kind thisHeaderKind = kind;

                line = line.trimmed();

                const int index = line.indexOf(" (framework directory)");
                if (index != -1) {
                    line.truncate(index);
                    thisHeaderKind = HeaderPath::FrameworkHeaderPath;
                }

                systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
            } else if (line.startsWith("End of search list.")) {
                break;
            } else {
                qWarning() << "ignore line:" << line;
            }
        }
    }
    return systemHeaderPaths;
}
示例#18
0
    virtual void onDraw(SkCanvas* canvas)
    {
        this->drawBG(canvas);

        SkAutoCanvasRestore ar(canvas, true);

        canvas->translate(  SkScalarHalf(this->width() - fClip.width()),
                            SkScalarHalf(this->height() - fClip.height()));

        //     canvas->scale(SK_Scalar1*3, SK_Scalar1*3, 0, 0);

        SkPaint paint;

        //    paint.setAntiAliasOn(true);
        paint.setStyle(SkPaint::kStroke_Style);

        canvas->drawRect(fClip, paint);

#if 1
        paint.setColor(0xFF555555);
        paint.setStrokeWidth(SkIntToScalar(2));
//        paint.setPathEffect(new SkCornerPathEffect(SkIntToScalar(30)))->unref();
        canvas->drawPath(fPath, paint);
//        paint.setPathEffect(NULL);
#endif

        SkPath  tmp;
        SkIRect iclip;
        fClip.round(&iclip);

        SkCullPointsPath    cpp(iclip, &tmp);

        cpp.moveTo(fPoints[0].fX, fPoints[0].fY);
        for (int i = 0; i < fPtCount; i++)
            cpp.lineTo(fPoints[i].fX, fPoints[i].fY);

        paint.setColor(SK_ColorRED);
        paint.setStrokeWidth(SkIntToScalar(3));
        paint.setStrokeJoin(SkPaint::kRound_Join);
        canvas->drawPath(tmp, paint);

        this->inval(NULL);
    }
示例#19
0
文件: cxml.c 项目: RushOnline/bouquet
/* helper function called by the function below */
static void c_xml_var_helper(symbol_t* sp, node_t *align, int dims, node_t **dim)
{
    if (align != NULL) {
        c_out(" aligned=\\\"");
        c_expression(align, 0);
        c_out("\\\"");
    }

    if (sp->ptype->ident != CHAR) 
        c_out("%s", (sp->modifiers & M_LITTLE ? " big=\\\"false\\\"" : ""));
    
    if (cpp()) {
        c_out(" bitLen=\\\"%%d\\\">");
        /* output the content (between the element tags) in the correct format */
		if (sp->ptype->ident <= INT) {
			if (sp->ptype->ident == CHAR) 
                c_out("%%c");
			else if (sp->modifiers & M_UNSIGNED) 
                c_out("%%u");
            else 
                c_out("%%d");
		}
		else if (sp->ptype->ident <= DOUBLE) 
            c_out("%%g");
		else
            fatal("Internal error CX%d: Expected simple type", __LINE__);

        c_out("</%s>\", %sparse, %s", sp->name, prefix, sp->name);
        if (dims > 0)
            c_array_proper(sp, dims);
        c_out(");\n");
    }
    else if (java()) {
        c_out(" bitLen=\\\"");
        c_out("\" + %sparse + \"\\\">", prefix);
        /* output the content (between the element tags) in the correct format */
        c_out("\" + %s", sp->name);
		if (dims > 0) 
            c_array_proper(sp, dims);
		c_out(" + \"</%s>\");\n", sp->name);
    }
}
示例#20
0
文件: mfpemul.c 项目: slippyex/OSME
/* Control register changes, adjust ``cti'' (cycle to next interrupt)
 *
 *    This case is a bit tricky : Changing timer prescale on the fly
 *    may have unpredictable result mostly because we dunno how
 *    prescaler works exactly. Here I assume the prescaler is
 *    resetted.
 *
 *    !!! chipmon of synergy does !!!
 *
 */
static __inline
void reconf_timer(mfp_timer_t * const ptimer, int tcr, const bogoc68_t bogoc)
{
  uint68_t        frq = timerfrq(ptimer->tdr_res); /* old frequency       */
  const bogoc68_t cti = ptimer->cti - bogoc;       /* cycles to interrupt */
  const uint68_t  psw = prediv_width[ptimer->tcr]; /* cycles count-down   */
  const uint68_t  cnt = cti/psw;                   /* count-down          */
  const uint68_t  psr = cti % psw;
  const uint68_t  psc = psw-psr;

  /* cnt%ptimer->tdr_res+1; no MODULO since TDR may have change and anyway
     cti was calculated with 1 timer cycle !!! */
  const uint68_t  tdr = cnt+1;
  const cycle68_t new_psw = prediv_width[(int)tcr];
  

  if (bogoc > ptimer->cti) {
    if (mfp_feature) fprintf(stderr,
	    "Reconf timer-%c @%u > cti:%u !!!CYCLE OUT OF RANGE!!!\n",
	    ptimer->def.letter, bogoc, ptimer->cti);
    ptimer->cti = bogoc + psw * ptimer->tdr_res;
  } else {

    ptimer->cti = bogoc + psr + (tdr-1) * new_psw;
    ptimer->cti = bogoc + /* psr + */ (tdr/* -1 */) * new_psw;

/*     if (ptimer->cti != cti_verif) { */
/*       if (mfp_feature) fprintf(stderr, */
/* 	      "Reconf timer-%c @%u psw:%u->%u psc:%u  cti:%u!=%u !!!\n", */
/* 	      ptimer->def.letter, bogoc, psw, new_psw, psc, */
/* 	      cti_verif, ptimer->cti); */
/*     } */
  }

  ptimer->tcr = tcr;

  if (mfp_feature) fprintf(stderr, "Reconf timer-%c @%u cti:%u cpp:%u=> %d->%dhz\n", 
	  ptimer->def.letter, bogoc,
	  ptimer->cti, cpp(ptimer->tdr_res),
	  frq,timerfrq(ptimer->tdr_res));
}
示例#21
0
文件: cxml.c 项目: RushOnline/bouquet
/* helper function called by the function below */
static void c_xml_map_var_helper(symbol_t* sp, int simple)
{
    if (sp->ptype->ident != CHAR) 
        c_out("%s", (sp->modifiers & M_LITTLE ? " big=\\\"false\\\"" : ""));
    
    if (cpp()) {
        c_out(" bitLen=\\\"%%d\\\">");
        /* output the content (between the element tags) in the correct format */
		if (sp->ptype->ident <= INT) {
			if (sp->ptype->ident == CHAR) 
                c_out("%%c");
			else if (sp->modifiers & M_UNSIGNED) 
                c_out("%%u");
            else 
                c_out("%%d");
		}
		else if (sp->ptype->ident <= DOUBLE) 
            c_out("%%g");
		else
            fatal("Internal error CX%d: Expected simple type", __LINE__);
 
        if (simple)
            c_out("</%s>\", %sesc_bits, *%sarg);\n", "value", prefix, prefix);
        else
            c_out("</%s>\", %sesc_bits, %sarg%s%s);\n", sp->name, prefix, prefix, c_scope(), sp->name);
    }
    else if (java()) {
        c_out(" bitLen=\\\"");
        c_out("\" + %sesc_bits + \"\\\">", prefix);
        /* output the content (between the element tags) in the correct format */
        if (simple)
            c_out("\" + %sarg", prefix);
        else
            c_out("\" + %sarg%s%s", prefix, c_scope(), sp->name);

        c_out(" + \"</%s>\");\n", (simple ? "value" : sp->name));
    }
}
bool RSReflectionCpp::reflect(const string &OutputPathBase,
                              const string &InputFileName,
                              const string &OutputBCFileName) {
    mInputFileName = InputFileName;
    mOutputPath = OutputPathBase;
    mOutputBCFileName = OutputBCFileName;
    mClassName = string("ScriptC_") + stripRS(InputFileName);

    makeHeader("android::renderscriptCpp::ScriptC");
    std::vector< std::string > header(mText);
    mText.clear();

    makeImpl("android::renderscriptCpp::ScriptC");
    std::vector< std::string > cpp(mText);
    mText.clear();


    RSReflectionBase::writeFile(mClassName + ".h", header);
    RSReflectionBase::writeFile(mClassName + ".cpp", cpp);


    return false;
}
示例#23
0
文件: mfpemul.c 项目: slippyex/OSME
void mfp_adjust_bogoc(mfp_t * const mfp, const bogoc68_t bogoc)
{
  mfp_timer_t *ptimer;

  if (!bogoc) return;
  for (ptimer = mfp->timers; ptimer != mfp->timers+4; ++ptimer) {
    if (ptimer->tcr) {
      if (ptimer->cti < bogoc) {
	if (mfp_feature) fprintf(stderr, "Adjust timer-%c cti:%u cycle:%u",
		ptimer->def.letter,ptimer->cti, bogoc);
      }
      while (ptimer->cti < bogoc) {
	/* $$$ !!! SHOULD NOT HAPPEN !!! */
	++ptimer->int_lost;
	ptimer->cti += cpp(ptimer->tdr_res);
      }
      if (ptimer->int_lost) {
	if (mfp_feature) fprintf(stderr, " ->%d lost\n",ptimer->int_lost);
	ptimer->int_lost = 0;
      }
      ptimer->cti -= bogoc;
    }
  }
}
示例#24
0
文件: sdiff.c 项目: andreiw/polaris
static void
cmdin(void)
{
	char	*cp, *ename;
	int	notacc;

	(void) fclose(left);
	(void) fclose(right);
	notacc = 1;
	while (notacc) {
		(void) putc(PROMPT, stdout);
		if ((cp = fgets(inbuf, 10, stdin)) == NULL) {
			(void) putc('\n', stdout);
			break;
		}
		switch (*cp) {

		case 's':
			silent = 1;
			break;

		case 'v':
			silent = 0;
			break;

		case 'q':
			sremove();
			exit(rcode);
			/* NOTREACHED */
			break;

		case 'l':
			cpp(ltemp, left, odes);
			notacc = 0;
			break;

		case 'r':
			cpp(rtemp, right, odes);
			notacc = 0;
			break;

		case 'e':
			while (*++cp == ' ')
				;
			switch (*cp) {
			case 'l':
			case '<':
				notacc = 0;
				ename = ltemp;
				edit(ename);
				break;

			case 'r':
			case '>':
				notacc = 0;
				ename = rtemp;
				edit(ename);
				break;

			case 'b':
			case '|':
				if ((tempdes = fopen(temp, "w")) == NULL)
					error(gettext(
						"Cannot open temp file %s"),
						temp);
				cpp(ltemp, left, tempdes);
				cpp(rtemp, right, tempdes);
				(void) fclose(tempdes);
				notacc = 0;
				ename = temp;
				edit(ename);
				break;

			case '\n':
				if ((tempdes = fopen(temp, "w")) == NULL)
					error(gettext(
						"Cannot open temp file %s"),
						temp);
				(void) fclose(tempdes);
				notacc = 0;
				ename = temp;
				edit(ename);
				break;
			default:
				(void) fprintf(stderr, gettext(
					"Illegal command %s reenter\n"),
					cp);
				break;
			}
			if (notacc == 0)
				cpp(ename, tempdes, odes);
			break;

		default:
			(void) fprintf(stderr, gettext(
				"Illegal command reenter\n"));
			break;
		}
	}
}
示例#25
0
void build_program(const std::string &path, const std::string &opts, 
    int platform_id) {
  const std::vector<cl::platform> &platforms =
    cl::platform::platforms();
  cl::platform platform = platforms[platform_id];
  std::cout << "building to platform " << platform_id << ": "
    << platform.name() << "\n";

  std::vector<cl::device> devices = platform.devices();
  std::cout << "building on the following devices:\n";
  for(unsigned i=0; i<devices.size(); ++i) {
    std::cout << i << ": " << devices[i].name() << ", ";
    std::cout << "driver version: " <<
      devices[i].driver_version() << "\n";
  }

  cl::context context(platform, devices.size(), &devices[0]);

  // FIXME add support for windows paths?
  const size_t last_slash = path.find_last_of('/');
  const std::string &filename = path.substr(last_slash+1);
  const size_t first_dot = filename.find_first_of('.');
  const std::string &base_name = filename.substr(0, first_dot);
  std::string base_name_cap = base_name;

  for(unsigned i=0; i < base_name_cap.size(); ++i)
    base_name_cap[i] = toupper(base_name_cap[i]);

  std::ifstream infile(path.c_str());
  std::stringstream build_stream;
  // TODO add preliminary stuff to hpp_stream and cpp_stream

  std::stringstream hpp_stream;
  hpp_stream << "#ifndef _" << base_name_cap << "_SOURCE_HPP_\n";
  hpp_stream << "#define _" << base_name_cap << "_SOURCE_HPP_\n";
  hpp_stream << "/* this file is automatically produced by clc */\n";
  hpp_stream << "extern const char *" << base_name << "_source;\n";
  hpp_stream << "#endif\n";

  std::stringstream cpp_stream;
  cpp_stream << "#include \"" << filename << ".hpp\"\n";
  cpp_stream << "const char *" << base_name << "_source = ";

  std::string line;
  while(std::getline(infile, line)) {
    build_stream << line << "\n";
    cpp_stream << "\n  \"";
    for(unsigned i=0; i<line.size(); ++i) {
      if(line[i] == '"') {
        cpp_stream << "\\\"";
      } else if(line[i] == '\\') {
        cpp_stream << "\\\\";
      } else {
        cpp_stream << line[i];
      }
    }
    cpp_stream << "\\n\"";
  }
  cpp_stream << ";\n";
  infile.close();

  std::cout << "attempting to compile " << path << "... ";
  cl::program p(context, build_stream.str());
  try {
    p.build(opts);
    std::cout << "success!" << std::endl;

    const std::string &header_path = path + ".hpp";
    std::ofstream header(header_path.c_str());
    header << hpp_stream.str();
    header.close();

    const std::string &cpp_path = path + ".cpp";
    std::ofstream cpp(cpp_path.c_str());
    cpp << cpp_stream.str();
    cpp.close();

    std::cout << "cpp-ready files written to "
      << header_path << " and " << cpp_path << "\n";
  } catch(const cl::cl_error &err) {
    std::cout << "compilation failed!" << std::endl;
  }
  std::cout << "\nbuild log:\n" << p.build_log(platform.devices()[0])
    << "\n";
}
示例#26
0
文件: cmap.c 项目: RushOnline/bouquet
/* generate map definition */
void map_decl(symbol_t *sp, list_t *stmts)
{
    FILE *tmp;

    if (sp == NULL) return;
    if (sp->ptype == NULL) 
        fatal("Internal error CM%d: Map without type information", __LINE__);
	
    if (cpp())
        c_out("\nclass %s {\n", sp->name);
    else if (java())
        c_out("\npublic class %s {\n", sp->name); 
    else if (xsd()) {
        c_out("\n<xsd:complexType name=\"%s\">\n", sp->name);
    	c_identlevel++;
		c_outi("<xsd:sequence>\n");
    }
    
    c_identlevel++;

    /* if doing C++, declare nextvlc()/getvlc()/putvlc() and switch output files */
    if (cpp()) {
        /* nextvlc(), getvlc() */
        if (gen_get) {
            c_outi("public: static int nextvlc(%s &%sbs, %s%s *%sarg, int *%sparse=NULL, int *%scode=NULL);\n",
                   bitstream_class, prefix, 
                   ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                   sp->ptype->name, prefix, prefix, prefix);
            c_outi("public: static int getvlc(%s &%sbs, %s%s *%sarg, int *%sparse=NULL, int *%scode=NULL);\n",
                   bitstream_class, prefix, 
                   ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                   sp->ptype->name, prefix, prefix, prefix);
        }
        /* putvlc() */
        if (gen_put) {
			if (sp->ptype->ident == CLASS_TYPE)
				/* if CLASS_TYPE pass a pointer to argument */
				c_outi("public: static int putvlc(%s &%sbs, %s%s *%sarg, int *%sparse=NULL, int *%scode=NULL);\n",
                       bitstream_class, prefix, 
                       ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                       sp->ptype->name, prefix, prefix, prefix);
			else
				/* otherwise, just value */
				c_outi("public: static int putvlc(%s &%sbs, %s%s %sarg, int *%sparse=NULL, int *%scode=NULL);\n",
                       bitstream_class, prefix, 
                       ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                       sp->ptype->name, prefix, prefix, prefix);

        }
        /* putxml() */
        if (gen_putxml) {
            c_outi("public: static int putxml(%s &%sbs, short int bAttr, %s%s *%sarg, int *%sparse=NULL, int *%scode=NULL);\n",
                   bitstream_class, prefix, 
                   ((sp->modifiers & M_UNSIGNED) ? "unsigned " : ""),
                   sp->ptype->name, prefix, prefix, prefix);
        }
        c_identlevel = 0;
        tmp = ofp;
        ofp = ofp2;
    }

    if (cpp() || java()) {
	    /* generate getvlc function; no next, if the map uses escape */
	    if (gen_get && !sp->escape) 
            c_map_next(sp, stmts);
        /* generate getvlc function */
        if (gen_get) 
            c_map_get(sp, stmts);
        /* generate putvlc function */
        if (gen_put) 
            c_map_put(sp, stmts);
        /* generate putxml function */
        if (gen_putxml) 
            c_map_putxml(sp, stmts);
    }
	else if (xsd()) 
        c_map_xsd(sp, stmts);

    /* switch back to .h file */
    if (cpp()) {
        c_identlevel = 1;
        ofp = tmp;
    }

    c_identlevel--;

    if (cpp()) 
        c_out("};\n");
    else if (java())
        c_out("}\n");
    else if (xsd()) {
		c_outi("</xsd:sequence>\n");
		c_identlevel--;
        c_out("</xsd:complexType>\n");
    }
}
示例#27
0
文件: cmap.c 项目: RushOnline/bouquet
/* Core code for putxml - checks for a match against the map codes.  The routine uses 
 * two variables: _data and _size, that contain the matched code.  If no match is found, then 
 * the last code entry is used.  If we get a hit, the _hit variable is assigned 1, otherwise 
 * it is left untouched (previously set to 0).
 */
static void c_map_putxml_core(symbol_t *sp, list_t *stmts)
{
    list_t *lp = stmts;
    int size;

    /* sanity check */
    if (lp->e1 == NULL || lp->e1->op != BIT_LITERAL || lp->e1->left.bit == NULL)
        fatal("Internal error CM%d: Expected code entry with bit literal", __LINE__);
    
    size = lp->e1->left.bit->len;
    
    /* get data */
    c_outi("%sdata = %sbs.nextbits(%d);\n", prefix, prefix, size);
    c_outi("switch (%sdata) {\n", prefix);
    while (lp != NULL) {
        /* sanity check */
        if (lp->e1 == NULL || lp->e1->op != BIT_LITERAL || lp->e1->left.bit == NULL)
            fatal("Internal error CM%d: Expected code entry with bit literal", __LINE__);

        /* did the size change? */
        if (lp->e1->left.bit->len != size) {
            c_outi("default:\n");
            c_identlevel++;
            c_map_putxml_core(sp, lp);
            c_identlevel--;
            break;
        }

        /* check for match */
        c_outi("case %d:\n", lp->e1->left.bit->val);
        c_identlevel++;

        /* skip bits, if we are doing get - must be done here so that escapes read correctly */
        c_outi("%sbs.skipbits(%d);\n", prefix, size);

        /* output code element for the XML document */
        c_outi("if (bAttr) {\n");
        c_identlevel++; 
        
        if (cpp())
            c_outi("%s(", xml_func3);
        else if (java())
            c_outi("XML.%s(", xml_func3);
        c_out("\"<code type=\\\"flBit\\\" bitLen=\\\"%d\\\">%d</code>\");\n", lp->e1->left.bit->len, lp->e1->left.bit->val);
        
        c_identlevel--; 
        c_outi("}\n");
        c_outi("else {\n");
        c_identlevel++; 

        if (cpp())
            c_outi("%s(", xml_func3);
        else if (java())
            c_outi("XML.%s(", xml_func3);
        c_out("\"<code bitLen=\\\"%d\\\">%d</code>\");\n", lp->e1->left.bit->len, lp->e1->left.bit->val);
  
        c_identlevel--; 
        c_outi("}\n");

        /* output assignment code */
        c_map_putxml_assign(sp, lp);
        
        /* save size */
        c_outi("%ssize = %d;\n", prefix, lp->e1->left.bit->len);

        c_outi("break;\n");
        c_identlevel--;

        /* if at the end, set hit to 0 and use last entry */
        if (lp->next == NULL) {
            c_outi("default:\n");
            c_identlevel++;
            if (cpp())
                c_outi("%shit = 0;\n", prefix);
			else if (java())
                c_outi("%shit = false;\n", prefix);
            c_identlevel--;
        }
        /* next code */
        lp = lp->next;
    }
    /* close switch statement */
    c_outi("}\n");
}
示例#28
0
文件: cmap.c 项目: RushOnline/bouquet
/* output assignment statements for a class map entry */
static void c_map_putxml_assign_class(symbol_t *sp, list_t *entry)
{
    list_t *p;

    /* find the statements for this class */
    list_t *stmts = find_class_stmts(sp->ptype);
    if (stmts == NULL) 
        fatal("Internal error CM%d: Cannot find declaration of class '%s'", __LINE__, sp->name);

    if (entry->sub1->type == ESC_FTYPE || entry->sub1->type == ESC_MAP)
        p = entry->sub1;
    else
        p = entry->sub1->sub1;

    /* output the beginning of the value element for the XML document */ 
    if (cpp())
        c_outi("%s(", xml_func4);
    else if (java())
        c_outi("XML.%s(", xml_func4);
    c_out("\"value\", 0);\n");

    /* traverse declarations and output assignment code for each variable */
	while (stmts != NULL) {
        switch (stmts->type) {
        case DECL:
			if (p == NULL) return;
            if (p->type == ESC_FTYPE || p->type == ESC_MAP) {
                c_outi("%sesc_bits = ", prefix);
                c_expression(p->e3, 0);
                c_out(";\n");
            }
            else
                c_outi("%sesc_bits = 0;\n", prefix);

            c_outi("%sarg%s%s = ", prefix, c_scope(), stmts->sp->name);

            /* figure out if we have simple assignment or escape */
            if (entry->sub1->type == ESC_FTYPE || entry->sub1->type == ESC_MAP)
                c_map_get_assign_esc(p);
            else {
		        if (stmts->sp->ptype->ident == FLOAT && p->e1->type == DOUBLE)
                    c_out("(float)");
                c_expression(p->e1, 0);
            }
            c_out(";\n");
       
            /* output an element for each class member value, which corresponds to the code */
            c_xml_map_var_simple(stmts->sp, 0);

            p = p->next;
            break;
            
        default:
            break;
        }
        stmts = stmts->next;
    }

    /* output the end of the value element for the xml document */ 
    if (cpp())
        c_outi("%s(", xml_func5);
    else if (java())
        c_outi("XML.%s(", xml_func5);
    c_out("\"</value>\");\n");
}
示例#29
0
文件: cmap.c 项目: RushOnline/bouquet
/* Core code for putvlc - checks for a match against the map codes.  The routine uses 
 * two variables: _data and _size, that contain the matched code.  If no match is found, then 
 * the last code entry is used.  If we get a hit, the _hit variable is assigned 1, otherwise 
 * it is left untouched (previously set to 0).
 */
static void c_map_put_core(symbol_t *sp, list_t *stmts)
{
    list_t *lp = stmts;
    list_t *last = NULL;
	int size;    
     
    /* put data */
    while (lp != NULL) {
        /* sanity check */
        if (lp->e1 == NULL || lp->e1->op != BIT_LITERAL || lp->e1->left.bit == NULL)
            fatal("Internal error CM%d: Expected code entry with bit literal", __LINE__);
		
        if (lp->sub1->type == ESC_FTYPE || lp->sub1->type == ESC_MAP) {
            /* save one and only escape code for last */
            last = lp;
            lp = lp->next;
            continue;
        }

		/* get bit length */
		size = lp->e1->left.bit->len;
		
        /* check for match */
        c_outi("if (");
        c_map_put_compare(sp, lp->sub1);
        c_out(") {\n");
        c_identlevel++;

		/* put bits */
        if (!lp->sp) {
            if (java() && sp->ptype->modifiers & M_LONG) 
                c_outi("%sbs.putlong(%d,%d);\n", prefix, lp->e1->left.bit->val, size);
            else
                c_outi("%sbs.putbits(%d,%d);\n", prefix, lp->e1->left.bit->val, size);
        }
        else {
            if (java() && sp->ptype->modifiers & M_LONG) 
                c_outi("%sbs.%sputlong(%d,%d);\n", prefix, 
			           (sp->ptype->id->modifiers & M_LITTLE ? "little_" : ""), lp->e1->left.bit->val, size);
            else
                c_outi("%sbs.%sputbits(%d,%d);\n", prefix, 
			           (sp->ptype->id->modifiers & M_LITTLE ? "little_" : ""), lp->e1->left.bit->val, size);
        }

        /* save size */
        c_outi("%ssize = %d;\n", prefix, lp->e1->left.bit->len);
        /* save data */
		c_outi("%sdata = %d;\n", prefix, lp->e1->left.bit->val);
       
        /* return code and size, if requested */
        if (cpp()) {
            c_outi("if (%sparse != NULL) *%sparse = %ssize;\n", prefix, prefix, prefix);
            c_outi("if (%scode != NULL) *%scode = %sdata;\n", prefix, prefix, prefix);
		    c_outi("return %shit;\n", prefix);
	    }
        else if (java()) 
            c_outi("return new %s(%shit, %sdata, %ssize, %sarg);\n", map_result, prefix, prefix, prefix, prefix);

        c_identlevel--;
        c_outi("}\n");
	    
        /* next code */
        lp = lp->next;
    }
    /* no escape code */
    if (last == NULL) {
        if (cpp()) {
            c_outi("%shit = 0;\n", prefix);
            c_outi("if (%sparse != NULL) *%sparse = %ssize;\n", prefix, prefix, prefix);
            c_outi("if (%scode != NULL) *%scode = %sdata;\n", prefix, prefix, prefix);
		    c_outi("return %shit;\n", prefix);
		}
        else if (java()) {
            c_outi("%shit = false;\n", prefix);
            c_outi("return new %s(%shit, %sdata, %ssize, %sarg);\n", map_result, prefix, prefix, prefix, prefix);
        }
    }
    else {
		/* get bit length */
		size = last->e1->left.bit->len;

		/* put bits */
        if (!last->sp) {
            if (java() && sp->ptype->modifiers & M_LONG) 
                c_outi("%sbs.putlong(%d,%d);\n", prefix, last->e1->left.bit->val, size);
            else
                c_outi("%sbs.putbits(%d,%d);\n", prefix, last->e1->left.bit->val, size);
        }
        else {
            if (java() && sp->ptype->modifiers & M_LONG) 
                c_outi("%sbs.%sputlong(%d,%d);\n", prefix, 
			           (sp->ptype->id->modifiers & M_LITTLE ? "little_" : ""), last->e1->left.bit->val, size);
            else
                c_outi("%sbs.%sputbits(%d,%d);\n", prefix, 
			           (sp->ptype->id->modifiers & M_LITTLE ? "little_" : ""), last->e1->left.bit->val, size);
        }

        /* save size */
        c_outi("%ssize = %d;\n", prefix, last->e1->left.bit->len);
        /* save data */
		c_outi("%sdata = %d;\n", prefix, last->e1->left.bit->val);

        if (sp->ptype->ident != CLASS_TYPE)
            c_map_put_esc_simple(sp, last->sub1);
        else
            c_map_put_esc_class(sp, last->sub1);

        if (cpp()) {
            c_outi("if (%sparse != NULL) *%sparse = %ssize;\n", prefix, prefix, prefix);
            c_outi("if (%scode != NULL) *%scode = %sdata;\n", prefix, prefix, prefix);
		    c_outi("return %shit;\n", prefix);
		}
        else if (java()) {
            c_outi("return new %s(%shit, %sdata, %ssize, %sarg);\n", map_result, prefix, prefix, prefix, prefix);
        }
    }
}
示例#30
0
void RpcGenerator::generateServiceProxyCc(google::protobuf::compiler::GeneratorContext * generator_context,
    const google::protobuf::ServiceDescriptor *descriptor) const
{
  string header(descriptor->name());
  header += ".pb.h";
  string cpp(descriptor->name());
  cpp += "_Proxy.pb.cc";

  io::ZeroCopyOutputStream *output = generator_context->Open(cpp.c_str());
  io::Printer cppPrinter(output, '$');

  cppPrinter.Print("#include \"$header$\"\n", "header", header.c_str());
  cppPrinter.Print("#include \"$class$_Handler.pb.h\"\n\n", "class", descriptor->name());
  cppPrinter.Print("#include <google/protobuf/stubs/common.h>\n");
  cppPrinter.Print("using google::protobuf::uint64;\n");

  // Add constructor implemention
  cppPrinter.Print("$service$_Proxy::$service$_Proxy(ProtoCall::Runtime::RpcChannel *channel)\n",
      "service", descriptor->full_name());

  cppPrinter.Print(" : m_channel(channel)\n{\n\n}\n\n");

  for(int j=0; j<descriptor->method_count(); j++) {
    const MethodDescriptor *method = descriptor->method(j);

    cppPrinter.Print("void $service$_Proxy::", "service", descriptor->full_name());
    this->generateMethodSignature(method, cppPrinter);
    cppPrinter.Print("\n{\n");

    cppPrinter.Indent();
    cppPrinter.Print("// Add RPC code here\n");
    string inputType = method->input_type()->name();
    string outputType = method->output_type()->name();
    cppPrinter.Print("rpc::Message msg;\n");
    cppPrinter.Print("rpc::Request *request = msg.mutable_request();\n");
    if (!isVoidType(inputType) || !isVoidType(outputType)) {
      cppPrinter.Print("uint64 id = this->m_channel->nextRequestId();\n");
      cppPrinter.Print("request->set_id(id);\n");
      cppPrinter.Print("$service$_Handler *handler = new $service$_Handler();\n",
          "service", descriptor->name());
      cppPrinter.Print("m_channel->registerResponseCallback(id, output, handler, done);\n");
    }
    cppPrinter.Print("$input_type$ *ext = request->MutableExtension($full_name$_request);\n",
        "input_type", inputType, "full_name", toExtensionName(method->full_name()));

    if (!isVoidType(inputType))
      cppPrinter.Print("ext->CopyFrom(*input);\n");

    // Send the message
    this->generateErrorCheck("m_channel->send(&msg)", cppPrinter);

    // Now check if we have any vtk objects to send
    this->generateSentVtkBlock("input", "m_channel",
        method->input_type(), cppPrinter);

    // Now check if we have any external objects to send
    this->generateSentExternalBlock("input", "m_channel",
        method->input_type(), cppPrinter);

    cppPrinter.Outdent();

    cppPrinter.Print("}\n\n");
  }

  //this->GenerateCallMethod(descriptor, cppPrinter);
}