Beispiel #1
1
void
vec4_tes_visitor::nir_emit_intrinsic(nir_intrinsic_instr *instr)
{
   const struct brw_tes_prog_data *tes_prog_data =
      (const struct brw_tes_prog_data *) prog_data;

   switch (instr->intrinsic) {
   case nir_intrinsic_load_tess_coord:
      /* gl_TessCoord is part of the payload in g1 channels 0-2 and 4-6. */
      emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_F),
               src_reg(brw_vec8_grf(1, 0))));
      break;
   case nir_intrinsic_load_tess_level_outer:
      if (tes_prog_data->domain == BRW_TESS_DOMAIN_ISOLINE) {
         emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_F),
                  swizzle(src_reg(ATTR, 1, glsl_type::vec4_type),
                          BRW_SWIZZLE_ZWZW)));
      } else {
         emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_F),
                  swizzle(src_reg(ATTR, 1, glsl_type::vec4_type),
                          BRW_SWIZZLE_WZYX)));
      }
      break;
   case nir_intrinsic_load_tess_level_inner:
      if (tes_prog_data->domain == BRW_TESS_DOMAIN_QUAD) {
         emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_F),
                  swizzle(src_reg(ATTR, 0, glsl_type::vec4_type),
                          BRW_SWIZZLE_WZYX)));
      } else {
         emit(MOV(get_nir_dest(instr->dest, BRW_REGISTER_TYPE_F),
                  src_reg(ATTR, 1, glsl_type::float_type)));
      }
      break;
   case nir_intrinsic_load_primitive_id:
      emit(TES_OPCODE_GET_PRIMITIVE_ID,
           get_nir_dest(instr->dest, BRW_REGISTER_TYPE_UD));
      break;

   case nir_intrinsic_load_input:
   case nir_intrinsic_load_per_vertex_input: {
      src_reg indirect_offset = get_indirect_offset(instr);
      unsigned imm_offset = instr->const_index[0];
      src_reg header = input_read_header;
      bool is_64bit = nir_dest_bit_size(instr->dest) == 64;
      unsigned first_component = nir_intrinsic_component(instr);
      if (is_64bit)
         first_component /= 2;

      if (indirect_offset.file != BAD_FILE) {
         header = src_reg(this, glsl_type::uvec4_type);
         emit(TES_OPCODE_ADD_INDIRECT_URB_OFFSET, dst_reg(header),
              input_read_header, indirect_offset);
      } else {
         /* Arbitrarily only push up to 24 vec4 slots worth of data,
          * which is 12 registers (since each holds 2 vec4 slots).
          */
         const unsigned max_push_slots = 24;
         if (imm_offset < max_push_slots) {
            const glsl_type *src_glsl_type =
               is_64bit ? glsl_type::dvec4_type : glsl_type::ivec4_type;
            src_reg src = src_reg(ATTR, imm_offset, src_glsl_type);
            src.swizzle = BRW_SWZ_COMP_INPUT(first_component);

            const brw_reg_type dst_reg_type =
               is_64bit ? BRW_REGISTER_TYPE_DF : BRW_REGISTER_TYPE_D;
            emit(MOV(get_nir_dest(instr->dest, dst_reg_type), src));

            prog_data->urb_read_length =
               MAX2(prog_data->urb_read_length,
                    DIV_ROUND_UP(imm_offset + (is_64bit ? 2 : 1), 2));
            break;
         }
      }

      if (!is_64bit) {
         dst_reg temp(this, glsl_type::ivec4_type);
         vec4_instruction *read =
            emit(VEC4_OPCODE_URB_READ, temp, src_reg(header));
         read->offset = imm_offset;
         read->urb_write_flags = BRW_URB_WRITE_PER_SLOT_OFFSET;

         src_reg src = src_reg(temp);
         src.swizzle = BRW_SWZ_COMP_INPUT(first_component);

         /* Copy to target.  We might end up with some funky writemasks landing
          * in here, but we really don't want them in the above pseudo-ops.
          */
         dst_reg dst = get_nir_dest(instr->dest, BRW_REGISTER_TYPE_D);
         dst.writemask = brw_writemask_for_size(instr->num_components);
         emit(MOV(dst, src));
      } else {
         /* For 64-bit we need to load twice as many 32-bit components, and for
          * dvec3/4 we need to emit 2 URB Read messages
          */
         dst_reg temp(this, glsl_type::dvec4_type);
         dst_reg temp_d = retype(temp, BRW_REGISTER_TYPE_D);

         vec4_instruction *read =
            emit(VEC4_OPCODE_URB_READ, temp_d, src_reg(header));
         read->offset = imm_offset;
         read->urb_write_flags = BRW_URB_WRITE_PER_SLOT_OFFSET;

         if (instr->num_components > 2) {
            read = emit(VEC4_OPCODE_URB_READ, byte_offset(temp_d, REG_SIZE),
                        src_reg(header));
            read->offset = imm_offset + 1;
            read->urb_write_flags = BRW_URB_WRITE_PER_SLOT_OFFSET;
         }

         src_reg temp_as_src = src_reg(temp);
         temp_as_src.swizzle = BRW_SWZ_COMP_INPUT(first_component);

         dst_reg shuffled(this, glsl_type::dvec4_type);
         shuffle_64bit_data(shuffled, temp_as_src, false);

         dst_reg dst = get_nir_dest(instr->dest, BRW_REGISTER_TYPE_DF);
         dst.writemask = brw_writemask_for_size(instr->num_components);
         emit(MOV(dst, src_reg(shuffled)));
      }
      break;
   }
   default:
      vec4_visitor::nir_emit_intrinsic(instr);
   }
}
Beispiel #2
0
void BaseTrackPlayerImpl::slotFinishLoading(TrackPointer pTrackInfoObject)
{
    m_replaygainPending = false;
    // Read the tags if required
    if (!m_pLoadedTrack->getHeaderParsed()) {
        m_pLoadedTrack->parse(false);
    }

    // m_pLoadedTrack->setPlayedAndUpdatePlaycount(true); // Actually the song is loaded but not played

    // Update the BPM and duration values that are stored in ControlObjects
    m_pDuration->set(m_pLoadedTrack->getDuration());
    m_pBPM->slotSet(m_pLoadedTrack->getBpm());
    m_pKey->slotSet(m_pLoadedTrack->getKey());
    m_pReplayGain->slotSet(m_pLoadedTrack->getReplayGain());

    // Update the PlayerInfo class that is used in EngineShoutcast to replace
    // the metadata of a stream
    PlayerInfo::instance().setTrackInfo(getGroup(), m_pLoadedTrack);

    // Reset the loop points.
    m_pLoopInPoint->slotSet(-1);
    m_pLoopOutPoint->slotSet(-1);

    const QList<Cue*> trackCues = pTrackInfoObject->getCuePoints();
    QListIterator<Cue*> it(trackCues);
    while (it.hasNext()) {
        Cue* pCue = it.next();
        if (pCue->getType() == Cue::LOOP) {
            int loopStart = pCue->getPosition();
            int loopEnd = loopStart + pCue->getLength();
            if (loopStart != -1 && loopEnd != -1 && even(loopStart) && even(loopEnd)) {
                m_pLoopInPoint->slotSet(loopStart);
                m_pLoopOutPoint->slotSet(loopEnd);
                break;
            }
        }
    }
    if(m_pConfig->getValueString(ConfigKey("[Mixer Profile]", "EqAutoReset"), 0).toInt()) {
        if (m_pLowFilter != NULL) {
            m_pLowFilter->set(1.0);
        }
        if (m_pMidFilter != NULL) {
            m_pMidFilter->set(1.0);
        }
        if (m_pHighFilter != NULL) {
            m_pHighFilter->set(1.0);
        }
        if (m_pLowFilterKill != NULL) {
            m_pLowFilterKill->set(0.0);
        }
        if (m_pMidFilterKill != NULL) {
            m_pMidFilterKill->set(0.0);
        }
        if (m_pHighFilterKill != NULL) {
            m_pHighFilterKill->set(0.0);
        }
        m_pPreGain->set(1.0);
    }
    int reset = m_pConfig->getValueString(ConfigKey(
            "[Controls]", "SpeedAutoReset"),
            QString("%1").arg(RESET_PITCH)).toInt();
    switch (reset) {
      case RESET_PITCH_AND_SPEED:
        // Note: speed may affect pitch
        if (m_pSpeed != NULL) {
            m_pSpeed->set(0.0);
        }
        // Fallthrough intended
      case RESET_PITCH:
        if (m_pPitchAdjust != NULL) {
            m_pPitchAdjust->set(0.0);
        }
    }
    emit(newTrackLoaded(m_pLoadedTrack));
}
Beispiel #3
0
//Generate compare and branch quads
void gen_cond(node* expr, qnode* t, qnode* f) {
	//printf("Processing conditional\n");
	if(expr->type == BINOP_NODE) {
		switch(expr->u.binop.type) {
			case LT_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BRLT, NULL, t, f);
				return;
			case GT_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BRGT, NULL, t, f);
				return;
			case LTEQ_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BRLE, NULL, t, f);
				return;
			case GTEQ_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BRGE, NULL, t, f);
				return;
			case EQEQ_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BREQ, NULL, t, f);
				return;
			case NOTEQ_OP:
				emit(O_CMP, NULL, gen_rvalue(expr->u.binop.left, NULL), gen_rvalue(expr->u.binop.right, NULL));
				emit(O_BRNE, NULL, t, f);
				return;
			case LOGOR_OP: { //short circuit OR
				block* temp = currentBlock;
				block* bi = bb_newBlock(functionCount, ++blockCount, currentBlock); //intermediate block
				currentBlock->next = bi;
				t->u.block->prev = bi;
				bi->next = t->u.block;
				bi->prev = currentBlock;
				gen_cond(expr->u.binop.left, t, blockToQnode(bi)); //test left expr
				if(currentBlock != temp) {
					currentBlock->next = bi;
				}
				currentBlock = bi;
				gen_cond(expr->u.binop.right, t, f); //test right expr
				//currentBlock = temp;
				return;
			}
			case LOGAND_OP: { //short circuit AND
				block* temp = currentBlock;
				block* bi = bb_newBlock(functionCount, ++blockCount, currentBlock); //intermediate block
				currentBlock->next = bi;
				t->u.block->prev = bi;
				bi->next = t->u.block;
				bi->prev = currentBlock;
				gen_cond(expr->u.binop.left, blockToQnode(bi), f); //test left expr
				if(currentBlock != temp) {
					currentBlock->next = bi;
				}
				currentBlock = bi;
				gen_cond(expr->u.binop.right, t, f); //test right expr
				//currentBlock = temp;
				return;
			}
			default: {
				break;
			}
		}
	}
	//gen_cond for non-conditional expr
	qnode* val = gen_rvalue(expr, NULL);
	qnode* zero = qnode_new(Q_CONSTANT);
	zero->name = strdup("0");
	zero->u.value = 0;
	emit(O_CMP, NULL, val, zero);
	emit(O_BRNE, NULL, t, f);
}
Beispiel #4
0
static void emit_decode_nohash(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char* sn = ls->structname->shortname;
    if(0 == g_ptr_array_size(ls->members)) {
        emit(0, "int %s::_decodeNoHash(const void *, int, int)", sn);
        emit(0, "{");
        emit(1,     "return 0;");
        emit(0, "}");
        emit(0, "");
        return;
    }
    emit(0, "int %s::_decodeNoHash(const void *buf, int offset, int maxlen)", sn);
    emit(0, "{");
    emit(1,     "int pos = 0, tlen;");
    emit(0, "");
    for (unsigned int m = 0; m < g_ptr_array_size(ls->members); m++) {
        lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m);

        if (0 == g_ptr_array_size(lm->dimensions) && lcm_is_primitive_type(lm->type->lctypename)) {
            if(!strcmp(lm->type->lctypename, "string")) {
                emit(1, "int32_t __%s_len__;", lm->membername);
                emit(1, "tlen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &__%s_len__, 1);", lm->membername);
                emit(1, "if(tlen < 0) return tlen; else pos += tlen;");
                emit(1, "if(__%s_len__ > maxlen - pos) return -1;", lm->membername);
                emit(1, "this->%s.assign(((const char*)buf) + offset + pos, __%s_len__ - 1);", lm->membername, lm->membername);
                emit(1, "pos += __%s_len__;", lm->membername);
            } else {
                emit(1, "tlen = __%s_decode_array(buf, offset + pos, maxlen - pos, &this->%s, 1);", lm->type->lctypename, lm->membername);
                emit(1, "if(tlen < 0) return tlen; else pos += tlen;");
            }
        } else {
            _decode_recursive(lcm, f, lm, 0);
        }

        emit(0,"");
    }
    emit(1, "return pos;");
    emit(0, "}");
    emit(0, "");
}
Beispiel #5
0
static void emit_encoded_size_nohash(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char *sn = ls->structname->shortname;
    emit(0, "int %s::_getEncodedSizeNoHash() const", sn);
    emit(0, "{");
    if(0 == g_ptr_array_size(ls->members)) {
        emit(1,     "return 0;");
        emit(0,"}");
        emit(0,"");
        return;
    }
    emit(1,     "int enc_size = 0;");
    for (unsigned int m = 0; m < g_ptr_array_size(ls->members); m++) {
        lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m);
        int ndim = g_ptr_array_size(lm->dimensions);

        if(lcm_is_primitive_type(lm->type->lctypename) &&
                strcmp(lm->type->lctypename, "string")) {
            emit_start(1, "enc_size += ");
            for(int n=0; n < ndim - 1; n++) {
                lcm_dimension_t *dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, n);
                emit_continue("%s%s * ", dim_size_prefix(dim->size), dim->size);
            }
            if(ndim > 0) {
                lcm_dimension_t *dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, ndim - 1);
                emit_end("__%s_encoded_array_size(NULL, %s%s);",
                        lm->type->lctypename, dim_size_prefix(dim->size), dim->size);
            } else {
                emit_end("__%s_encoded_array_size(NULL, 1);", lm->type->lctypename);
            }
        } else {
            for(int n=0; n < ndim; n++) {
                lcm_dimension_t *dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, n);
                emit(1+n, "for (int a%d = 0; a%d < %s%s; a%d++) {",
                        n, n, dim_size_prefix(dim->size), dim->size, n);
            }
            emit_start(ndim + 1, "enc_size += this->%s", lm->membername);
            for(int i=0; i<ndim; i++)
                emit_continue("[a%d]", i);
            if(!strcmp(lm->type->lctypename, "string")) {
                emit_end(".size() + 4 + 1;");
            } else {
                emit_end("._getEncodedSizeNoHash();");
            }
            for(int n=ndim-1; n >= 0; n--) {
                emit(1 + n, "}");
            }
        }
    }
    emit(1, "return enc_size;");
    emit(0,"}");
    emit(0,"");
}
Beispiel #6
0
static void emit_compute_hash(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char *sn  = ls->structname->shortname;
    int last_complex_member = -1;
    for (unsigned int m = 0; m < g_ptr_array_size(ls->members); m++) {
        lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m);
        if(!lcm_is_primitive_type(lm->type->lctypename))
            last_complex_member = m;
    }

    if(last_complex_member >= 0) {
        emit(0, "int64_t %s::_computeHash(const __lcm_hash_ptr *p)", sn);
        emit(0, "{");
        emit(1,     "const __lcm_hash_ptr *fp;");
        emit(1,     "for(fp = p; fp != NULL; fp = fp->parent)");
        emit(2,         "if(fp->v == %s::getHash)", sn);
        emit(3,              "return 0;");
        if(g_ptr_array_size(ls->members)) {
            emit(1, "const __lcm_hash_ptr cp = { p, (void*)%s::getHash };", sn);
        }
        emit(0, "");
        emit(1,     "int64_t hash = 0x%016"PRIx64"LL +", ls->hash);

        for (unsigned int m = 0; m <= last_complex_member; m++) {
            lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m);
            char* lm_tnc = dots_to_double_colons(lm->type->lctypename);
            if(!lcm_is_primitive_type(lm->type->lctypename)) {
                emit(2, " %s::_computeHash(&cp)%s",
                        lm_tnc,
                        (m == last_complex_member) ? ";" : " +");
            }
            free(lm_tnc);
        }
        emit(0, "");
    } else {
        emit(0, "int64_t %s::_computeHash(const __lcm_hash_ptr *)", sn);
        emit(0, "{");
        emit(1,     "int64_t hash = 0x%016"PRIx64"LL;", ls->hash);
    }

    emit(1, "return (hash<<1) + ((hash>>63)&1);");
    emit(0, "}");
    emit(0, "");
}
Beispiel #7
0
static void emit_encode(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char* sn = ls->structname->shortname;
    emit(0, "int %s::encode(void *buf, int offset, int maxlen) const", sn);
    emit(0, "{");
    emit(1,     "int pos = 0, tlen;");
    emit(1,     "int64_t hash = getHash();");
    emit(0, "");
    emit(1,     "tlen = __int64_t_encode_array(buf, offset + pos, maxlen - pos, &hash, 1);");
    emit(1,     "if(tlen < 0) return tlen; else pos += tlen;");
    emit(0, "");
    emit(1,     "tlen = this->_encodeNoHash(buf, offset + pos, maxlen - pos);");
    emit(1,     "if (tlen < 0) return tlen; else pos += tlen;");
    emit(0, "");
    emit(1,     "return pos;");
    emit(0, "}");
    emit(0, "");
}
Beispiel #8
0
void ITunesFeature::activate() {
    activate(false);
    emit(enableCoverArtDisplay(false));
}
/***************************************************************************
* Name: preload_distance_bands
*
* Description:	pre-load the array which defines all distance bands
*               defined in the DB.  These are specified in the
*		DISTANCE_BANDS table.
*
* Input:	connection - dataserver conn.
* Output:	none
* Returns:	number of rows loaded, or
*		-1 on ERROR
* Globals:	sDistanceBands
*		giNumDistanceBands
* Stored Proc:	mps_load_distance_bands
*****************************************************************************/
int preload_distance_bands(Arb_connection *connection)
{
  int	which;
  tiny	distance_band_id;
  int	type_id_usg;
  int	jurisdiction;
  char	access_region_origin[szAccessRegion+1];
  int	element_id;
  int	min_distance;
  int	max_distance;

   if( arb_setup_results(&proc_mps_load_distance_bands,
        ARB_TYPE_INT8,   &distance_band_id,
        ARB_TYPE_INT32,  &type_id_usg,
        ARB_TYPE_INT32,  &jurisdiction,
        ARB_TYPE_STRING, access_region_origin, sizeof(access_region_origin),
        ARB_TYPE_INT32,  &element_id,
        ARB_TYPE_INT32,  &min_distance,
        ARB_TYPE_INT32,  &max_distance,
        NO_MORE_ARGS) != SUCCESS) 
   {
        return(-1);
   }

   if( arb_setup_proc_exec(connection, 
        &proc_mps_load_distance_bands, SQL_DEFER_EXECUTE,
        NO_MORE_ARGS) != SUCCESS) 
   {
        return(-1);
   }

   which = 0;
   while( arb_next_row(connection) == ARB_MORE_DATA )
   {
	if(which >= giNumDistanceBands)
	{
           arb_cancel(connection);
	   emit(ERRLOC, MPS_TOO_MANY_ROWS, "proc_mps_load_distance_bands",
		which+1, giNumDistanceBands);
           return(-1);
	}

        sDistanceBands[which].distance_band_id = distance_band_id;
        sDistanceBands[which].type_id_usg = type_id_usg;
        sDistanceBands[which].jurisdiction = jurisdiction;
        strcpy(sDistanceBands[which].access_region_origin,access_region_origin);
        sDistanceBands[which].element_id = element_id;
        sDistanceBands[which].min_distance = min_distance;
        sDistanceBands[which].max_distance = max_distance;

	which++;
   }

   if( arb_query_status(connection) != SUCCESS ) 
   {
        arb_cancel(connection);
	emit(ERRLOC, MPS_DBERR, "proc_mps_load_distance_bands");
        return(-1);
   }

   emit(ERRLOC, MPS_DIST_BANDS_LOAD, which);

   return(which);
}
/***************************************************************************
* Name: preload_state_exclusion
*
* Description:	preload the array which defines all jurisdictions with either
*               state_origin_exclude = true or state_origin_exclude = true
*		in USAGE_JURISDICTION table.
*
* Input:	connection - dataserver conn.
* Output:	none
* Returns:	number of rows loaded, or
*		-1 on ERROR
* Globals:	gsStateExclusion
*		giNumStateExclusion
* Stored Proc:	mps_load_state_exclusion
*****************************************************************************/
int preload_state_exclusion(Arb_connection *connection)
{
   int which;
   USAGE_JURISDICTION_STRUCT tmp;

   if( arb_setup_results(&proc_mps_load_state_exclusion,
        ARB_TYPE_INT32,  &(tmp.seqnum),
        ARB_TYPE_INT32,  &(tmp.type_id_usg),
        ARB_TYPE_INT32,  &(tmp.element_id),
        ARB_TYPE_INT16,  &(tmp.rate_class),
        ARB_TYPE_INT16,  &(tmp.equip_type_code),
        ARB_TYPE_INT16,  &(tmp.equip_class_code),
        ARB_TYPE_INT16,  &(tmp.class_of_service_code),
        ARB_TYPE_STRING, (tmp.point_origin),		szUsagePoint+1,
        ARB_TYPE_STRING, (tmp.point_target),		szUsagePoint+1,
        ARB_TYPE_INT32,  &(tmp.point_class_origin),
        ARB_TYPE_INT32,  &(tmp.point_class_target),
        ARB_TYPE_STRING, (tmp.point_region_origin),	szPointRegion+1,
        ARB_TYPE_STRING, (tmp.point_region_target),	szPointRegion+1,
        ARB_TYPE_STRING, (tmp.state_origin),		szStateAbbr+1,
        ARB_TYPE_STRING, (tmp.state_target),		szStateAbbr+1,
        ARB_TYPE_INT8,   &(tmp.state_origin_exclude),
        ARB_TYPE_INT8,   &(tmp.state_target_exclude),
        ARB_TYPE_STRING, (tmp.access_region_origin),	szAccessRegion+1,
        ARB_TYPE_STRING, (tmp.access_region_target),	szAccessRegion+1,
        ARB_TYPE_INT32,  &(tmp.priority),
        ARB_TYPE_INT16,  &(tmp.exclude_group),
        ARB_TYPE_INT32,  &(tmp.jurisdiction),
        ARB_TYPE_INT16,  &(tmp.country_code_origin),
        ARB_TYPE_INT16,  &(tmp.country_code_target),
        ARB_TYPE_DATELONG,&(tmp.active_dt),
        ARB_TYPE_DATELONG,&(tmp.inactive_dt),
        ARB_TYPE_INT16,  &(tmp.bill_class),
        ARB_TYPE_INT8,   &(tmp.zone_class),
        NO_MORE_ARGS) != SUCCESS )
   {
        return(-1);
   }

   if( arb_setup_proc_exec(connection, 
        &proc_mps_load_state_exclusion, SQL_DEFER_EXECUTE,
        NO_MORE_ARGS) != SUCCESS) 
   {
        return(-1);
   }

   which = 0;
   while( arb_next_row(connection) == ARB_MORE_DATA )
   {
        if( which >= giNumStateExclusion )
        {
            arb_cancel(connection);
	    emit(ERRLOC, MPS_TOO_MANY_ROWS, "proc_mps_load_state_exclusion",
			which+1, giNumStateExclusion);
            return(-1);
        }

        memcpy((char *)&gsStateExclusion[which], (char *)&tmp,
            sizeof(USAGE_JURISDICTION_STRUCT));

        which++;
   }

   if( arb_query_status(connection) != SUCCESS ) 
   {
        arb_cancel(connection);
	emit(ERRLOC, MPS_DBERR, "proc_mps_load_state_exclusion");
        return(-1);
   }

   emit(ERRLOC, MPS_STATE_EXCLUDE, which);

   return(which);
}
Beispiel #11
0
void Button::mousePressedInternal(QMouseEvent* ev, const QPoint& pos) {
    Q_UNUSED(ev);
    Q_UNUSED(pos);

    emit(clicked());
}
Beispiel #12
0
void QgsComposerView::showEvent( QShowEvent* e )
{
  emit( composerViewShow( this ) );
  e->ignore();
}
Beispiel #13
0
void QgsComposerView::hideEvent( QHideEvent* e )
{
  emit( composerViewHide( this ) );
  e->ignore();
}
void HG_(pp_Error) ( const Error* err )
{
    const Bool xml = VG_(clo_xml); /* a shorthand, that's all */

    if (!xml) {
        VG_(umsg)("--------------------------------"
                  "--------------------------------" "\n");
        VG_(umsg)("\n");
    }

    XError *xe = (XError*)VG_(get_error_extra)(err);
    tl_assert(xe);

    if (xml)
        emit( "  <kind>%s</kind>\n", HG_(get_error_name)(err));

    switch (VG_(get_error_kind)(err)) {

    case XE_Misc: {
        tl_assert( HG_(is_sane_Thread)( xe->XE.Misc.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit( "    <text>Thread #%d: %s</text>\n",
                  (Int)xe->XE.Misc.thr->errmsg_index,
                  xe->XE.Misc.errstr );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.Misc.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            if (xe->XE.Misc.auxstr) {
                emit("  <auxwhat>%s</auxwhat>\n", xe->XE.Misc.auxstr);
                if (xe->XE.Misc.auxctx)
                    VG_(pp_ExeContext)( xe->XE.Misc.auxctx );
            }

        } else {

            emit( "Thread #%d: %s\n",
                  (Int)xe->XE.Misc.thr->errmsg_index,
                  xe->XE.Misc.errstr );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            if (xe->XE.Misc.auxstr) {
                emit(" %s\n", xe->XE.Misc.auxstr);
                if (xe->XE.Misc.auxctx)
                    VG_(pp_ExeContext)( xe->XE.Misc.auxctx );
            }

        }
        break;
    }

    case XE_LockOrder: {
        tl_assert( HG_(is_sane_Thread)( xe->XE.LockOrder.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit( "    <text>Thread #%d: lock order \"%p before %p\" "
                  "violated</text>\n",
                  (Int)xe->XE.LockOrder.thr->errmsg_index,
                  (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr,
                  (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.LockOrder.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            if (xe->XE.LockOrder.shouldbe_earlier_ec
                    && xe->XE.LockOrder.shouldbe_later_ec) {
                emit( "  <auxwhat>Required order was established by "
                      "acquisition of lock at %p</auxwhat>\n",
                      (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr );
                VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_earlier_ec );
                emit( "  <auxwhat>followed by a later acquisition "
                      "of lock at %p</auxwhat>\n",
                      (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
                VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_later_ec );
            }
            announce_LockP ( xe->XE.LockOrder.shouldbe_earlier_lk );
            announce_LockP ( xe->XE.LockOrder.shouldbe_later_lk );

        } else {

            emit( "Thread #%d: lock order \"%p before %p\" violated\n",
                  (Int)xe->XE.LockOrder.thr->errmsg_index,
                  (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr,
                  (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
            emit( "\n" );
            emit( "Observed (incorrect) order is: "
                  "acquisition of lock at %p\n",
                  (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr);
            if (xe->XE.LockOrder.actual_earlier_ec) {
                VG_(pp_ExeContext)(xe->XE.LockOrder.actual_earlier_ec);
            } else {
                emit("   (stack unavailable)\n");
            }
            emit( "\n" );
            emit(" followed by a later acquisition of lock at %p\n",
                 (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr);
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            if (xe->XE.LockOrder.shouldbe_earlier_ec
                    && xe->XE.LockOrder.shouldbe_later_ec) {
                emit("\n");
                emit( "Required order was established by "
                      "acquisition of lock at %p\n",
                      (void*)xe->XE.LockOrder.shouldbe_earlier_lk->guestaddr );
                VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_earlier_ec );
                emit( "\n" );
                emit( " followed by a later acquisition of lock at %p\n",
                      (void*)xe->XE.LockOrder.shouldbe_later_lk->guestaddr );
                VG_(pp_ExeContext)( xe->XE.LockOrder.shouldbe_later_ec );
            }
            emit("\n");
            announce_LockP ( xe->XE.LockOrder.shouldbe_earlier_lk );
            announce_LockP ( xe->XE.LockOrder.shouldbe_later_lk );

        }

        break;
    }

    case XE_PthAPIerror: {
        tl_assert( HG_(is_sane_Thread)( xe->XE.PthAPIerror.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit(
                "    <text>Thread #%d's call to %pS failed</text>\n",
                (Int)xe->XE.PthAPIerror.thr->errmsg_index,
                xe->XE.PthAPIerror.fnname );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.PthAPIerror.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            emit( "  <what>with error code %ld (%s)</what>\n",
                  xe->XE.PthAPIerror.err, xe->XE.PthAPIerror.errstr );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

        } else {

            emit( "Thread #%d's call to %pS failed\n",
                  (Int)xe->XE.PthAPIerror.thr->errmsg_index,
                  xe->XE.PthAPIerror.fnname );
            emit( "   with error code %ld (%s)\n",
                  xe->XE.PthAPIerror.err, xe->XE.PthAPIerror.errstr );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

        }

        break;
    }

    case XE_UnlockBogus: {
        tl_assert( HG_(is_sane_Thread)( xe->XE.UnlockBogus.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit( "    <text>Thread #%d unlocked an invalid "
                  "lock at %p</text>\n",
                  (Int)xe->XE.UnlockBogus.thr->errmsg_index,
                  (void*)xe->XE.UnlockBogus.lock_ga );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.UnlockBogus.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

        } else {

            emit( "Thread #%d unlocked an invalid lock at %p\n",
                  (Int)xe->XE.UnlockBogus.thr->errmsg_index,
                  (void*)xe->XE.UnlockBogus.lock_ga );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

        }

        break;
    }

    case XE_UnlockForeign: {
        tl_assert( HG_(is_sane_LockP)( xe->XE.UnlockForeign.lock ) );
        tl_assert( HG_(is_sane_Thread)( xe->XE.UnlockForeign.owner ) );
        tl_assert( HG_(is_sane_Thread)( xe->XE.UnlockForeign.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit( "    <text>Thread #%d unlocked lock at %p "
                  "currently held by thread #%d</text>\n",
                  (Int)xe->XE.UnlockForeign.thr->errmsg_index,
                  (void*)xe->XE.UnlockForeign.lock->guestaddr,
                  (Int)xe->XE.UnlockForeign.owner->errmsg_index );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.UnlockForeign.thr->errmsg_index );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.UnlockForeign.owner->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            announce_LockP ( xe->XE.UnlockForeign.lock );

        } else {

            emit( "Thread #%d unlocked lock at %p "
                  "currently held by thread #%d\n",
                  (Int)xe->XE.UnlockForeign.thr->errmsg_index,
                  (void*)xe->XE.UnlockForeign.lock->guestaddr,
                  (Int)xe->XE.UnlockForeign.owner->errmsg_index );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            announce_LockP ( xe->XE.UnlockForeign.lock );

        }

        break;
    }

    case XE_UnlockUnlocked: {
        tl_assert( HG_(is_sane_LockP)( xe->XE.UnlockUnlocked.lock ) );
        tl_assert( HG_(is_sane_Thread)( xe->XE.UnlockUnlocked.thr ) );

        if (xml) {

            emit( "  <xwhat>\n" );
            emit( "    <text>Thread #%d unlocked a "
                  "not-locked lock at %p</text>\n",
                  (Int)xe->XE.UnlockUnlocked.thr->errmsg_index,
                  (void*)xe->XE.UnlockUnlocked.lock->guestaddr );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.UnlockUnlocked.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            announce_LockP ( xe->XE.UnlockUnlocked.lock);

        } else {

            emit( "Thread #%d unlocked a not-locked lock at %p\n",
                  (Int)xe->XE.UnlockUnlocked.thr->errmsg_index,
                  (void*)xe->XE.UnlockUnlocked.lock->guestaddr );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
            announce_LockP ( xe->XE.UnlockUnlocked.lock);

        }

        break;
    }

    case XE_Race: {
        Addr      err_ga;
        const HChar* what;
        Int       szB;
        what      = xe->XE.Race.isWrite ? "write" : "read";
        szB       = xe->XE.Race.szB;
        err_ga = VG_(get_error_address)(err);

        tl_assert( HG_(is_sane_Thread)( xe->XE.Race.thr ));
        if (xe->XE.Race.h2_ct)
            tl_assert( HG_(is_sane_Thread)( xe->XE.Race.h2_ct ));

        if (xml) {

            /* ------ XML ------ */
            emit( "  <xwhat>\n" );
            emit( "    <text>Possible data race during %s of size %d "
                  "at %p by thread #%d</text>\n",
                  what, szB, (void*)err_ga, (Int)xe->XE.Race.thr->errmsg_index );
            emit( "    <hthreadid>%d</hthreadid>\n",
                  (Int)xe->XE.Race.thr->errmsg_index );
            emit( "  </xwhat>\n" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

            if (xe->XE.Race.h2_ct) {
                tl_assert(xe->XE.Race.h2_ct_accEC); // assured by update_extra
                emit( "  <xauxwhat>\n");
                emit( "    <text>This conflicts with a previous %s of size %d "
                      "by thread #%d</text>\n",
                      xe->XE.Race.h2_ct_accIsW ? "write" : "read",
                      xe->XE.Race.h2_ct_accSzB,
                      xe->XE.Race.h2_ct->errmsg_index );
                emit( "    <hthreadid>%d</hthreadid>\n",
                      xe->XE.Race.h2_ct->errmsg_index);
                emit("  </xauxwhat>\n");
                VG_(pp_ExeContext)( xe->XE.Race.h2_ct_accEC );
            }

            if (xe->XE.Race.h1_ct) {
                emit( "  <xauxwhat>\n");
                emit( "    <text>This conflicts with a previous access "
                      "by thread #%d, after</text>\n",
                      xe->XE.Race.h1_ct->errmsg_index );
                emit( "    <hthreadid>%d</hthreadid>\n",
                      xe->XE.Race.h1_ct->errmsg_index );
                emit("  </xauxwhat>\n");
                if (xe->XE.Race.h1_ct_mbsegstartEC) {
                    VG_(pp_ExeContext)( xe->XE.Race.h1_ct_mbsegstartEC );
                } else {
                    emit( "  <auxwhat>(the start of the thread)</auxwhat>\n" );
                }
                emit( "  <auxwhat>but before</auxwhat>\n" );
                if (xe->XE.Race.h1_ct_mbsegendEC) {
                    VG_(pp_ExeContext)( xe->XE.Race.h1_ct_mbsegendEC );
                } else {
                    emit( "  <auxwhat>(the end of the thread)</auxwhat>\n" );
                }
            }

        } else {

            /* ------ Text ------ */
            announce_combined_LockP_vecs( xe->XE.Race.locksHeldW,
                                          xe->XE.Race.h2_ct_locksHeldW );

            emit( "Possible data race during %s of size %d "
                  "at %p by thread #%d\n",
                  what, szB, (void*)err_ga, (Int)xe->XE.Race.thr->errmsg_index );

            tl_assert(xe->XE.Race.locksHeldW);
            show_LockP_summary_textmode( xe->XE.Race.locksHeldW, "" );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );

            if (xe->XE.Race.h2_ct) {
                tl_assert(xe->XE.Race.h2_ct_accEC); // assured by update_extra
                tl_assert(xe->XE.Race.h2_ct_locksHeldW);
                emit( "\n" );
                emit( "This conflicts with a previous %s of size %d "
                      "by thread #%d\n",
                      xe->XE.Race.h2_ct_accIsW ? "write" : "read",
                      xe->XE.Race.h2_ct_accSzB,
                      xe->XE.Race.h2_ct->errmsg_index );
                show_LockP_summary_textmode( xe->XE.Race.h2_ct_locksHeldW, "" );
                VG_(pp_ExeContext)( xe->XE.Race.h2_ct_accEC );
            }

            if (xe->XE.Race.h1_ct) {
                emit( " This conflicts with a previous access by thread #%d, "
                      "after\n",
                      xe->XE.Race.h1_ct->errmsg_index );
                if (xe->XE.Race.h1_ct_mbsegstartEC) {
                    VG_(pp_ExeContext)( xe->XE.Race.h1_ct_mbsegstartEC );
                } else {
                    emit( "   (the start of the thread)\n" );
                }
                emit( " but before\n" );
                if (xe->XE.Race.h1_ct_mbsegendEC) {
                    VG_(pp_ExeContext)( xe->XE.Race.h1_ct_mbsegendEC );
                } else {
                    emit( "   (the end of the thread)\n" );
                }
            }

        }
        VG_(pp_addrinfo) (err_ga, &xe->XE.Race.data_addrinfo);
        break; /* case XE_Race */
        } /* case XE_Race */

    default:
        tl_assert(0);
    } /* switch (VG_(get_error_kind)(err)) */
}
void pc_pp_Error ( const Error* err )
{
   const Bool xml = VG_(clo_xml); /* a shorthand, that's all */

   XError *xe = (XError*)VG_(get_error_extra)(err);
   tl_assert(xe);

   if (xml)
      emit( "  <kind>%s</kind>\n", pc_get_error_name(err));

   switch (VG_(get_error_kind)(err)) {

   //----------------------------------------------------------
   case XE_SorG:

      if (xml) {

         emit( "  <what>Invalid %s of size %ld</what>\n",
               xe->XE.SorG.sszB < 0 ? "write" : "read",
               Word__abs(xe->XE.SorG.sszB) );
         VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
         emit( "  <auxwhat>Address %#lx expected vs actual:</auxwhat>\n",
               xe->XE.SorG.addr );
         emiN( "  <auxwhat>Expected: %pS</auxwhat>\n",
               &xe->XE.SorG.expect[0] );
         emiN( "  <auxwhat>Actual:   %pS</auxwhat>\n", 
               &xe->XE.SorG.actual[0] );

      } else {

         emit( "Invalid %s of size %ld\n", 
               xe->XE.SorG.sszB < 0 ? "write" : "read",
               Word__abs(xe->XE.SorG.sszB) );
         VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
         emit( " Address %#lx expected vs actual:\n", xe->XE.SorG.addr );
         emit( " Expected: %s\n", &xe->XE.SorG.expect[0] );
         emit( " Actual:   %s\n", &xe->XE.SorG.actual[0] );
         if (xe->XE.SorG.delta[0] != 0)
            emit(" Actual:   is %s Expected\n", &xe->XE.SorG.delta[0]);
      }
      break;

   //----------------------------------------------------------
   case XE_Heap: {
      const HChar *place, *legit, *how_invalid;
      Addr a    = xe->XE.Heap.addr;
      Seg* vseg = xe->XE.Heap.vseg;

      tl_assert(is_known_segment(vseg) || NONPTR == vseg);

      if (NONPTR == vseg) {
         // Access via a non-pointer

         if (xml) {

            emit( "  <what>Invalid %s of size %ld</what>\n",
                  readwrite(xe->XE.Heap.sszB),
                  Word__abs(xe->XE.Heap.sszB) );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( "  <auxwhat>Address %#lx is not derived from "
                  "any known block</auxwhat>\n", a );

         } else {

            emit( "Invalid %s of size %ld\n",
                  readwrite(xe->XE.Heap.sszB),
                  Word__abs(xe->XE.Heap.sszB) );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( " Address %#lx is not derived from "
                  "any known block\n", a );

         }

      } else {
         // Access via a pointer, but outside its range.
         Int cmp;
         UWord miss_size;
         Seg__cmp(vseg, a, &cmp, &miss_size);
         if      (cmp  < 0) place = "before";
         else if (cmp == 0) place = "inside";
         else               place = "after";
         how_invalid = ( ( Seg__is_freed(vseg) && 0 != cmp )
                       ? "Doubly-invalid" : "Invalid" );
         legit = ( Seg__is_freed(vseg) ? "once-" : "" );

         if (xml) {

            emit( "  <what>%s %s of size %ld</what>\n",
                  how_invalid,
                  readwrite(xe->XE.Heap.sszB),
                  Word__abs(xe->XE.Heap.sszB) );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( "  <auxwhat>Address %#lx is %lu bytes %s "
                     "the accessing pointer's</auxwhat>\n",
                  a, miss_size, place );
            emit( "  <auxwhat>%slegitimate range, "
                     "a block of size %lu %s</auxwhat>\n",
                  legit, Seg__size(vseg),
                  Seg__is_freed(vseg) ? "free'd" : "alloc'd" );
            VG_(pp_ExeContext)(Seg__where(vseg));

         } else {

            emit( "%s %s of size %ld\n",
                  how_invalid,
                  readwrite(xe->XE.Heap.sszB),
                  Word__abs(xe->XE.Heap.sszB) );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( " Address %#lx is %lu bytes %s the accessing pointer's\n",
                  a, miss_size, place );
            emit( " %slegitimate range, a block of size %lu %s\n",
                  legit, Seg__size(vseg),
                  Seg__is_freed(vseg) ? "free'd" : "alloc'd" );
            VG_(pp_ExeContext)(Seg__where(vseg));

         }
      }

      /* If we have a better description of the address, show it.
         Note that in XML mode, it will already by nicely wrapped up
         in tags, either <auxwhat> or <xauxwhat>, so we can just emit
         it verbatim. */
      if (xml) {

         if (xe->XE.Heap.descr1)
            emiN( "  %pS\n",
                  (HChar*)VG_(indexXA)( xe->XE.Heap.descr1, 0 ) );
         if (xe->XE.Heap.descr2)
            emiN( "  %pS\n",
                  (HChar*)VG_(indexXA)( xe->XE.Heap.descr2, 0 ) );
         if (xe->XE.Heap.datasym[0] != 0)
            emiN( "  <auxwhat>Address 0x%llx is %llu bytes "
                  "inside data symbol \"%pS\"</auxwhat>\n",
                  (ULong)xe->XE.Heap.addr,
                  (ULong)xe->XE.Heap.datasymoff,
                  xe->XE.Heap.datasym );

      } else {

         if (xe->XE.Heap.descr1)
            emit( " %s\n",
                  (HChar*)VG_(indexXA)( xe->XE.Heap.descr1, 0 ) );
         if (xe->XE.Heap.descr2)
            emit( " %s\n",
                  (HChar*)VG_(indexXA)( xe->XE.Heap.descr2, 0 ) ); 
         if (xe->XE.Heap.datasym[0] != 0)
            emit( " Address 0x%llx is %llu bytes "
                  "inside data symbol \"%s\"\n",
                  (ULong)xe->XE.Heap.addr,
                  (ULong)xe->XE.Heap.datasymoff,
                  xe->XE.Heap.datasym );

      }
      break;
   }

   //----------------------------------------------------------
   case XE_Arith: {
      Seg*   seg1   = xe->XE.Arith.seg1;
      Seg*   seg2   = xe->XE.Arith.seg2;
      const HChar*  which;

      tl_assert(BOTTOM != seg1);
      tl_assert(BOTTOM != seg2 && UNKNOWN != seg2);

      if (xml) {

         emit( "  <what>Invalid arguments to %s</what>\n",
               xe->XE.Arith.opname );
         VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
         if (seg1 != seg2) {
            if (NONPTR == seg1) {
               emit( "  <auxwhat>First arg not a pointer</auxwhat>\n" );
            } else if (UNKNOWN == seg1) {
               emit( "  <auxwhat>First arg may be a pointer</auxwhat>\n" );
            } else {
               emit( "  <auxwhat>First arg derived from address %#lx of "
                     "%lu-byte block alloc'd</auxwhat>\n",
                     Seg__addr(seg1), Seg__size(seg1) );
               VG_(pp_ExeContext)(Seg__where(seg1));
            }
            which = "Second arg";
         } else {
            which = "Both args";
         }
         if (NONPTR == seg2) {
            emit( "  <auxwhat>%s not a pointer</auxwhat>\n", which );
         } else {
            emit( "  <auxwhat>%s derived from address %#lx of "
                  "%lu-byte block alloc'd</auxwhat>\n",
                  which, Seg__addr(seg2), Seg__size(seg2) );
            VG_(pp_ExeContext)(Seg__where(seg2));
         }

      } else {

         emit( "Invalid arguments to %s\n",
               xe->XE.Arith.opname );
         VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
         if (seg1 != seg2) {
            if (NONPTR == seg1) {
               emit( " First arg not a pointer\n" );
            } else if (UNKNOWN == seg1) {
               emit( " First arg may be a pointer\n" );
            } else {
               emit( " First arg derived from address %#lx of "
                     "%lu-byte block alloc'd\n",
                     Seg__addr(seg1), Seg__size(seg1) );
               VG_(pp_ExeContext)(Seg__where(seg1));
            }
            which = "Second arg";
         } else {
            which = "Both args";
         }
         if (NONPTR == seg2) {
            emit( " %s not a pointer\n", which );
         } else {
            emit( " %s derived from address %#lx of "
                  "%lu-byte block alloc'd\n",
                  which, Seg__addr(seg2), Seg__size(seg2) );
            VG_(pp_ExeContext)(Seg__where(seg2));
         }

      }

      break;
   }

   //----------------------------------------------------------
   case XE_SysParam: {
      Addr  lo    = xe->XE.SysParam.lo;
      Addr  hi    = xe->XE.SysParam.hi;
      Seg*  seglo = xe->XE.SysParam.seglo;
      Seg*  seghi = xe->XE.SysParam.seghi;
      const HChar* s = VG_(get_error_string) (err);
      const HChar* what;

      tl_assert(BOTTOM != seglo && BOTTOM != seghi);

      if      (Vg_CoreSysCall == xe->XE.SysParam.part) 
                 what = "Syscall param ";
      else    VG_(tool_panic)("bad CorePart");

      if (seglo == seghi) {
         // freed block
         tl_assert(is_known_segment(seglo));
         tl_assert(Seg__is_freed(seglo)); // XXX what if it's now recycled?

         if (xml) {

            emit( "  <what>%s%s contains unaddressable byte(s)</what>\n",
                  what, s );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( "  <auxwhat>Address %#lx is %lu bytes inside a "
                  "%lu-byte block free'd</auxwhat>\n",
                  lo, lo-Seg__addr(seglo), Seg__size(seglo) );
            VG_(pp_ExeContext)(Seg__where(seglo));

         } else {

            emit( " %s%s contains unaddressable byte(s)\n",
                  what, s );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            emit( " Address %#lx is %lu bytes inside a "
                  "%lu-byte block free'd\n",
                  lo, lo-Seg__addr(seglo), Seg__size(seglo) );
            VG_(pp_ExeContext)(Seg__where(seglo));

         }

      } else {
         // mismatch

         if (xml) {

            emit( "  <what>%s%s is non-contiguous</what>\n",
                  what, s );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            if (UNKNOWN == seglo) {
               emit( "  <auxwhat>First byte is "
                        "not inside a known block</auxwhat>\n" );
            } else {
               emit( "  <auxwhat>First byte (%#lx) is %lu bytes inside a "
                     "%lu-byte block alloc'd</auxwhat>\n",
                     lo, lo-Seg__addr(seglo), Seg__size(seglo) );
               VG_(pp_ExeContext)(Seg__where(seglo));
            }
   
            if (UNKNOWN == seghi) {
               emit( "  <auxwhat>Last byte is "
                        "not inside a known block</auxwhat>\n" );
            } else {
               emit( "  <auxwhat>Last byte (%#lx) is %lu bytes inside a "
                     "%lu-byte block alloc'd</auxwhat>\n",
                     hi, hi-Seg__addr(seghi), Seg__size(seghi) );
               VG_(pp_ExeContext)(Seg__where(seghi));
            }

         } else {

            emit( "%s%s is non-contiguous\n",
                  what, s );
            VG_(pp_ExeContext)( VG_(get_error_where)(err) );
   
            if (UNKNOWN == seglo) {
               emit( " First byte is not inside a known block\n" );
            } else {
               emit( " First byte (%#lx) is %lu bytes inside a "
                     "%lu-byte block alloc'd\n",
                     lo, lo-Seg__addr(seglo), Seg__size(seglo) );
               VG_(pp_ExeContext)(Seg__where(seglo));
            }
   
            if (UNKNOWN == seghi) {
               emit( " Last byte is not inside a known block\n" );
            } else {
               emit( " Last byte (%#lx) is %lu bytes inside a "
                     "%lu-byte block alloc'd\n",
                     hi, hi-Seg__addr(seghi), Seg__size(seghi) );
               VG_(pp_ExeContext)(Seg__where(seghi));
            }

         }

      }
      break;
   }

   default:
      VG_(tool_panic)("pp_Error: unrecognised error kind");
   }
}
Beispiel #16
0
bool ARMEventTreat::ProcessEachCollectable(KTKvectorIterator<IKEBarmCollectableHdl> collectableIterator,
					   ARMTreatStrategy* pTreatStrat,
					   ARMCollectorStrategy* pCollectorStrat,
					   ARMScenarioStrategy* pEventScenarioStrat,
					   KTKautoPtr<KTKexception> & pError)
{
    KTKvariant scenarioId, collectorId;
    ARMHistoryLog* hl = ARMHistoryLog::GetARMHistoryLog(_armEntitiesFactory ,pError);
    Arb_connection * pConn=_dbConnectionCust;
    // for each collectable
    char trans_name[100] ="processCollectable";

    KTKvariant presentFlag,warnFlag;
    bool transStatus = false; // status of the transaction
 
    while(collectableIterator.More())
    {
        IKEBarmCollectableHdl collectable = *collectableIterator++;
	
        KTKvariant accountNo = collectable->GetAccountNo();
	//CAMqa89374
        //KTKvariant balance = collectable->GetArmBalanceDue();
        int balance;
        Arb_numeric bal = collectable->GetArmBalanceDue();
        arb_numeric_to_int(&bal,&balance);
        //CAMqa89374

        arb_begin_tran(pConn,trans_name);

	emit( ARMMOD, ARM_EVENT_TREAT_START_EACH_ACCT , collectable->GetAccountNo().AsInt(), collectable->GetBillRefNo().AsInt(),
                                                        collectable->GetBillRefResets().AsInt(), collectable->GetOpenItemId().AsInt()  );


        transStatus  = pEventScenarioStrat->GetExtEventScenarioId(collectable,
                                                        _strategyValueMap[ARMEventTreat::STRAT_GET_EXT_EVENT_SCENARIO],
                                                        scenarioId,
                                                        pError);

        if (transStatus)
        {
          transStatus = pEventScenarioStrat->SetScenarioId(collectable,
                                                           scenarioId,
                                                           pError);

        }

        if (transStatus)
        {
            if (_strategyValueMap[ARMTreat::STRAT_GET_COLLECTOR] == 1)
            {
                  transStatus = pCollectorStrat->CheckCollectorId(scenarioId,
                                                                  accountNo,
                                                                  collectorId,
                                                                  presentFlag,
                                                                  warnFlag,
                                                                  pError);
            if (warnFlag.AsInt() == 1)
		emit (ARMMOD, ARM_INVALID_SCENARIO, accountNo.AsInt(), collectorId.AsInt(), scenarioId.AsInt());
            }
        }
        if (transStatus)
        { 

          if ((_strategyValueMap[ARMTreat::STRAT_GET_COLLECTOR] != 1) || ((_strategyValueMap[ARMTreat::STRAT_GET_COLLECTOR
]  == 1) && (presentFlag.AsInt() == 0)))           
          {
                transStatus = pCollectorStrat->GetCollectorId(scenarioId,
                                                              _strategyValueMap[ARMTreat::STRAT_GET_COLLECTOR],
                                                              collectorId,
                                                              pError);
          }
        }
        if (transStatus)
        {
         transStatus = pCollectorStrat->SetCollectorId(collectable,
                                                       collectorId,
                                                       pError);
        }

        if (transStatus)
        {
         transStatus = pTreatStrat->ArmCollectableSave(collectable, pError);
        }
        if (transStatus)
        {
               pTreatStrat->MakeEventQueue(collectable->GetCollectableId(),
                                           collectable->GetCollectableServ(),
                                           pError); 
        }

        if (!transStatus)
        {
	     emit( ARMMOD, ARM_EVENT_TREAT_FAIL ,accountNo.AsInt() , collectable->GetBillRefNo().AsInt() ,
						 collectable->GetBillRefResets().AsInt(), collectable->GetOpenItemId().AsInt());

             arb_rollback_tran(pConn,trans_name);
             KTKstring scenId = "";
             KTKstring collId = "";
             _ctrlRpt->ControlReportDetail(false, collectable, &scenId, &collId, pError);
             if(!hl->RegisterOccurance(pError, MSTONE_FAIL_EVENTTREAT, collectable))
             {
		emit( ARMMOD, ARM_COMMON_ERR1 , pError->DebugMessages().Data() );
                 pError->DeleteAll();
             }
             continue;
         }
 
           arb_commit_tran(pConn);
 
         KTKstring  scenId, collId;
         scenId=scenarioId.AsString();
         collId=collectorId.AsString();

        // write successful treat to control report
        _ctrlRpt->ControlReportDetail(true, collectable, &scenId, &collId, pError);
         
         // Register commited collectable transaction activities
         if(!hl->RegisterOccurance(pError, MSTONE_SCENARIO_ASSIGNED, collectable, &scenId))
         {
             emit( ARMMOD, ARM_COMMON_ERR1 , pError->DebugMessages().Data() );
             pError->DeleteAll();
         }
         if(!hl->RegisterOccurance(pError, MSTONE_COLLECTOR_ASSIGNED, collectable, &collId))
         {
             emit( ARMMOD, ARM_COMMON_ERR1 , pError->DebugMessages().Data() );
             pError->DeleteAll();
         }

	 //CAMqa89374
         KTKstring balanceCalculated = "#BAL#";
        // balanceCalculated += balance.AsFormattedString();
	CurrencyData _currencyDataTmp;
        //balanceCalculated += balance.AsFormattedString();
        char successAmount[50];
        char newSuccessAmt[50];
        arb_numeric_to_string(&bal,successAmount);
        //_currencyDataTmp.Initialize();
        KTKvariant currencyCode=collectable->GetCurrencyCode(); 
        _currencyDataTmp.FormatCurrency(currencyCode.AsInt(), successAmount, newSuccessAmt, pError);
        balanceCalculated += (char *)newSuccessAmt;

         if(!hl->RegisterOccurance(pError, MSTONE_TREAT_BALANCE, collectable,&balanceCalculated))
         {
		emit( ARMMOD, ARM_COMMON_ERR1 , pError->DebugMessages().Data() );
             pError->DeleteAll();
         }
         //CAMqa89374

         if(!hl->RegisterOccurance(pError, MSTONE_SUCC_EVENTTREAT, collectable))
         {
		emit( ARMMOD, ARM_COMMON_ERR1 , pError->DebugMessages().Data() );
             pError->DeleteAll();
         }
    } 
    return true;
}
void QgsDelimitedTextFile::updateFile()
{
  close();
  emit( fileUpdated() );
}
static int exclusion_check(CDR_DATA_STRUCT *cdr, int **count, int *exclude_flag)
{
  short  j, group_id;
  int    jurisdiction=0;
  tiny   group_failed;
  int    i;
  tiny   match;
  int    element_id;

  /* we scan through all exclusion rows */
  /* remeber for exclusion, we do matching by groups which means that all r
ows
  ** for one group has to be passed to derive on jurisdiction for one group
 */
  group_id = -1;

  **count = 0;
  /* to indicate at least one row is violated in one group */
  group_failed = FALSE; 

  for(i = 0; i < giNumStateExclusion; i++)
  {

    if( !Arbdate_is_null(&(gsStateExclusion[i].inactive_dt)))
    {
      /* check against trans_dt */
      if(Arbdate_compare( &(gsStateExclusion[i].inactive_dt),
        &(cdr->db_trans_dt)) <= 0) /* not a match */
        continue;
    }

    if(Arbdate_compare( &(gsStateExclusion[i].active_dt),
      &(cdr->db_trans_dt)) > 0) /* not a match */
      continue;

    if(group_id == -1)
    {
      group_id = gsStateExclusion[i].exclude_group;
    }
    else
    {
      if(group_id != gsStateExclusion[i].exclude_group)
      {
        if(group_failed == FALSE) /* all checking for one group passed */
        {
          break;
        }
        else
        {
          **count = 0;
          group_failed = FALSE; /* start a new group */
          group_id = gsStateExclusion[i].exclude_group;
        }
      }
      else
      {
        if(group_failed == TRUE)
        {
          **count = 0;
          continue;
        }
        if(jurisdiction!=0)
        {
          if(jurisdiction != gsStateExclusion[i].jurisdiction)
          {
          
            emit(ERRLOC, MPS_JURIS_NO_EQUAL, gsStateExclusion[i].exclude_group);
            set_cdr_error_code(cdr, MPS_JURIS_NO_EQUALX);
            sprintf(gstrJurisErrText,
             "%d,jurisdictions for exclude group %d not equal", 
              MPS_JURIS_NO_EQUALX, gsStateExclusion[i].exclude_group); 
            set_mps_error_struct(gstrJurisErrText,"");
            return SUCCESS;
          }
        }
      }
    }

    if(group_failed == TRUE)
    {
      **count = 0;
      continue;
    }

    if(gsStateExclusion[i].exclude_group != cdr->exclude_group)
    {
        group_failed = TRUE;
        **count = 0;
        continue;
    }


    /* if state_origin and state_target are blanks, check only that 
    ** cdr->state_target != cdr->state_origin */

    if((gsStateExclusion[i].state_origin)[0] == '\0' &&
       (gsStateExclusion[i].state_target)[0] == '\0')
    {
      if(strcmp(cdr->state_origin, cdr->state_target) == 0)
      {
        group_failed = TRUE;
        **count = 0;
        continue;
      }
      else
        continue;
    }

    if(gsStateExclusion[i].state_origin_exclude == TRUE &&
       gsStateExclusion[i].state_target_exclude == FALSE)
    {
      if(strcmp(gsStateExclusion[i].state_origin,
        cdr->state_origin) == 0)
      {
        group_failed = TRUE;
        **count = 0;
        *exclude_flag = 1;
        continue;
      }
      if((gsStateExclusion[i].point_target)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].point_target,
          cdr->point_target_prefix) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if((gsStateExclusion[i].point_region_target)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].point_region_target,
          cdr->point_region_target) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if(gsStateExclusion[i].point_class_target != 0)
      {
        if(gsStateExclusion[i].point_class_target != 
          cdr->point_class_target)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if((gsStateExclusion[i].state_target)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].state_target,
          cdr->state_target) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          *exclude_flag = 1;
          continue;
        }
      }
      if((gsStateExclusion[i].access_region_target)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].access_region_target,
          cdr->access_region_target) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if(gsStateExclusion[i].country_code_target != 0)
      {
        if(gsStateExclusion[i].country_code_target != 
          cdr->country_code_target)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
    }
    else if(gsStateExclusion[i].state_target_exclude == TRUE &&
       gsStateExclusion[i].state_origin_exclude == FALSE)
    {
      if(strcmp(gsStateExclusion[i].state_target,
        cdr->state_target) == 0)
      {
        group_failed = TRUE;
	**count = 0;
        *exclude_flag = 1;
	continue;
      }
      if((gsStateExclusion[i].point_origin)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].point_origin,
          cdr->point_origin_prefix) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if((gsStateExclusion[i].point_region_origin)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].point_region_origin,
          cdr->point_region_origin) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if(gsStateExclusion[i].point_class_origin != 0)
      {
        if(gsStateExclusion[i].point_class_origin != 
          cdr->point_class_origin)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if((gsStateExclusion[i].state_origin)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].state_origin,
          cdr->state_origin) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          *exclude_flag = 1;
          continue;
        }
      }
      if((gsStateExclusion[i].access_region_origin)[0] != '\0')
      {
        if(strcmp(gsStateExclusion[i].access_region_origin,
          cdr->access_region_origin) != 0)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
      if(gsStateExclusion[i].country_code_origin != 0)
      {
        if(gsStateExclusion[i].country_code_origin != 
          cdr->country_code_origin)
        {
          group_failed = TRUE;
          **count = 0;
          continue;
        }
      }
    }
    else
    {
      if(strcmp(gsStateExclusion[i].state_origin,
        cdr->state_origin) == 0)
        group_failed = TRUE;
        *exclude_flag = 1;
      if(strcmp(gsStateExclusion[i].state_target,
        cdr->state_target) == 0)
        group_failed = TRUE;
        *exclude_flag = 1;
    }

    if(gsStateExclusion[i].type_id_usg != 0 && 
       gsStateExclusion[i].type_id_usg != cdr->type_id_usg)
      group_failed = TRUE;

    if(gsStateExclusion[i].rate_class != 0 &&
       gsStateExclusion[i].rate_class != cdr->rate_class)
      group_failed = TRUE;

    if(gsStateExclusion[i].equip_type_code != 0 && 
      gsStateExclusion[i].equip_type_code != cdr->equip_type_code)
      group_failed = TRUE;

    if(gsStateExclusion[i].equip_class_code != 0 && 
      gsStateExclusion[i].equip_class_code != cdr->equip_class_code)
      group_failed = TRUE;

    if(gsStateExclusion[i].class_of_service_code != 0 && 
      gsStateExclusion[i].class_of_service_code != cdr->class_of_service_code)
      group_failed = TRUE;

    if(gsStateExclusion[i].bill_class != 0 && 
      gsStateExclusion[i].bill_class != cdr->bill_class)
      group_failed = TRUE;

    if(gsStateExclusion[i].zone_class != 0 && 
      gsStateExclusion[i].zone_class != cdr->cell_zone_class)
      group_failed = TRUE;

    if(gsStateExclusion[i].element_id != 0)
    {
      match = FALSE;
      for(j = 0; j < cdr->num_element_id; j++)
      {
        if(gsStateExclusion[i].element_id == 
          (cdr->element_id_ptr[j]).element_id)
        {
          element_id = gsStateExclusion[i].element_id;
          match = TRUE;
          break;
        }
      }
      if(match == FALSE)
        group_failed = TRUE;
    }

    if ( group_failed == FALSE )
    {
       **count = 1;
       jurisdiction = gsStateExclusion[i].jurisdiction;
    }
    else
    {
       **count = 0;
    }
  }

  if(**count)
  {
    cdr->jurisdiction = jurisdiction;
    if (cdr->element_id == 0)
      cdr->element_id = element_id;
    cdr->num_element_id = 1;
  }

  return(SUCCESS);
}
Beispiel #19
0
/** Emit header file **/
static void emit_header_start(lcmgen_t *lcmgen, FILE *f, lcm_struct_t *ls)
{
    char *tn = ls->structname->lctypename;
    char *sn = ls->structname->shortname;
    char *tn_ = dots_to_underscores(tn);

    emit_auto_generated_warning(f);

    fprintf(f, "#include <lcm/lcm_coretypes.h>\n");
    fprintf(f, "\n");
    fprintf(f, "#ifndef __%s_hpp__\n", tn_);
    fprintf(f, "#define __%s_hpp__\n", tn_);
    fprintf(f, "\n");

    // do we need to #include <vector> and/or <string>?
    int emit_include_vector = 0;
    int emit_include_string = 0;
    for (unsigned int mind = 0; mind < g_ptr_array_size(ls->members); mind++) {
        lcm_member_t *lm = (lcm_member_t *)g_ptr_array_index(ls->members, mind);
        if (g_ptr_array_size(lm->dimensions) != 0 &&
            !lcm_is_constant_size_array(lm) && !emit_include_vector) {
            emit(0, "#include <vector>");
            emit_include_vector = 1;
        }
        if(!emit_include_string &&
            !strcmp(lm->type->lctypename, "string")) {
            emit(0, "#include <string>");
            emit_include_string = 1;
        }
    }

    // include header files for other LCM types
    for (unsigned int mind = 0; mind < g_ptr_array_size(ls->members); mind++) {
        lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, mind);

        if (!lcm_is_primitive_type(lm->type->lctypename) &&
            strcmp(lm->type->lctypename, ls->structname->lctypename)) {
            char *other_tn = dots_to_slashes (lm->type->lctypename);
            emit(0, "#include \"%s%s%s.hpp\"",
                    getopt_get_string(lcmgen->gopt, "cpp-include"),
                    strlen(getopt_get_string(lcmgen->gopt, "cpp-include"))>0 ? G_DIR_SEPARATOR_S : "",
                    other_tn);
            free(other_tn);
        }
    }

    fprintf(f, "\n");
    emit_package_namespace_start(lcmgen, f, ls);

    // define the class
    emit(0, "");
    emit_comment(f, 0, ls->comment);
    emit(0, "class %s", sn);
    emit(0, "{");

    // data members
    if(g_ptr_array_size(ls->members)) {
        emit(1, "public:");
        for (unsigned int mind = 0; mind < g_ptr_array_size(ls->members); mind++) {
            lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, mind);

            emit_comment(f, 2, lm->comment);
            char* mapped_typename = map_type_name(lm->type->lctypename);
            int ndim = g_ptr_array_size(lm->dimensions);
            if (ndim == 0) {
                emit(2, "%-10s %s;", mapped_typename, lm->membername);
            } else {
                if (lcm_is_constant_size_array(lm)) {
                    emit_start(2, "%-10s %s", mapped_typename, lm->membername);
                    for (unsigned int d = 0; d < ndim; d++) {
                        lcm_dimension_t *ld = (lcm_dimension_t *) g_ptr_array_index(lm->dimensions, d);
                        emit_continue("[%s]", ld->size);
                    }
                    emit_end(";");
                } else {
                    emit_start(2, "");
                    for (unsigned int d = 0; d < ndim; d++)
                        emit_continue("std::vector< ");
                    emit_continue("%s", mapped_typename);
                    for (unsigned int d = 0; d < ndim; d++)
                        emit_continue(" >");
                    emit_end(" %s;", lm->membername);
                }
            }
            free(mapped_typename);
            if (mind < g_ptr_array_size(ls->members) - 1) {
                emit(0, "");
            }
        }
        emit(0, "");
    }

    // constants
    if (g_ptr_array_size(ls->constants) > 0) {
        emit(1, "public:");
        for (unsigned int i = 0; i < g_ptr_array_size(ls->constants); i++) {
            lcm_constant_t *lc = (lcm_constant_t *) g_ptr_array_index(ls->constants, i);
            assert(lcm_is_legal_const_type(lc->lctypename));

            emit_comment(f, 2, lc->comment);
            // For int32_t only, we emit enums instead of static const
            // values because the former can be passed by reference while
            // the latter cannot.
            if (!strcmp(lc->lctypename, "int32_t")) {
              emit(2, "enum { %s = %s };", lc->membername, lc->val_str);
            } else {
              const char *suffix = "";
              if (!strcmp(lc->lctypename, "int64_t"))
                suffix = "LL";
              char* mapped_typename = map_type_name(lc->lctypename);
              emit(2, "static const %-8s %s = %s%s;", mapped_typename,
                  lc->membername, lc->val_str, suffix);
              free(mapped_typename);
            }
        }
        emit(0, "");
    }

    emit(1, "public:");
    emit(2, "/**");
    emit(2, " * Encode a message into binary form.");
    emit(2, " *");
    emit(2, " * @param buf The output buffer.");
    emit(2, " * @param offset Encoding starts at thie byte offset into @p buf.");
    emit(2, " * @param maxlen Maximum number of bytes to write.  This should generally be");
    emit(2, " *  equal to getEncodedSize().");
    emit(2, " * @return The number of bytes encoded, or <0 on error.");
    emit(2, " */");
    emit(2, "inline int encode(void *buf, int offset, int maxlen) const;");
    emit(0, "");
    emit(2, "/**");
    emit(2, " * Check how many bytes are required to encode this message.");
    emit(2, " */");
    emit(2, "inline int getEncodedSize() const;");
    emit(0, "");
    emit(2, "/**");
    emit(2, " * Decode a message from binary form into this instance.");
    emit(2, " *");
    emit(2, " * @param buf The buffer containing the encoded message.");
    emit(2, " * @param offset The byte offset into @p buf where the encoded message starts.");
    emit(2, " * @param maxlen The maximum number of bytes to reqad while decoding.");
    emit(2, " * @return The number of bytes decoded, or <0 if an error occured.");
    emit(2, " */");
    emit(2, "inline int decode(const void *buf, int offset, int maxlen);");
    emit(0, "");
    emit(2, "/**");
    emit(2, " * Retrieve the 64-bit fingerprint identifying the structure of the message.");
    emit(2, " * Note that the fingerprint is the same for all instances of the same");
    emit(2, " * message type, and is a fingerprint on the message type definition, not on");
    emit(2, " * the message contents.");
    emit(2, " */");
    emit(2, "inline static int64_t getHash();");
    emit(0, "");
    emit(2, "/**");
    emit(2, " * Returns \"%s\"", ls->structname->shortname);
    emit(2, " */");
    emit(2, "inline static const char* getTypeName();");

    emit(0, "");
    emit(2, "// LCM support functions. Users should not call these");
    emit(2, "inline int _encodeNoHash(void *buf, int offset, int maxlen) const;");
    emit(2, "inline int _getEncodedSizeNoHash() const;");
    emit(2, "inline int _decodeNoHash(const void *buf, int offset, int maxlen);");
    emit(2, "inline static int64_t _computeHash(const __lcm_hash_ptr *p);");
    emit(0, "};");
    emit(0, "");

    free(tn_);
}
static void
llvm_pipeline_generic( struct draw_pt_middle_end *middle,
                       const struct draw_fetch_info *fetch_info,
                       const struct draw_prim_info *in_prim_info )
{
   struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle;
   struct draw_context *draw = fpme->draw;
   struct draw_geometry_shader *gshader = draw->gs.geometry_shader;
   struct draw_prim_info gs_prim_info;
   struct draw_vertex_info llvm_vert_info;
   struct draw_vertex_info gs_vert_info;
   struct draw_vertex_info *vert_info;
   struct draw_prim_info ia_prim_info;
   struct draw_vertex_info ia_vert_info;
   const struct draw_prim_info *prim_info = in_prim_info;
   boolean free_prim_info = FALSE;
   unsigned opt = fpme->opt;
   unsigned clipped = 0;

   llvm_vert_info.count = fetch_info->count;
   llvm_vert_info.vertex_size = fpme->vertex_size;
   llvm_vert_info.stride = fpme->vertex_size;
   llvm_vert_info.verts =
      (struct vertex_header *)MALLOC(fpme->vertex_size *
                                     align(fetch_info->count,  lp_native_vector_width / 32));
   if (!llvm_vert_info.verts) {
      assert(0);
      return;
   }

   if (draw->collect_statistics) {
      draw->statistics.ia_vertices += fetch_info->count;
      draw->statistics.ia_primitives +=
         u_decomposed_prims_for_vertices(prim_info->prim, prim_info->count);
      draw->statistics.vs_invocations += fetch_info->count;
   }

   if (fetch_info->linear)
      clipped = fpme->current_variant->jit_func( &fpme->llvm->jit_context,
                                       llvm_vert_info.verts,
                                       (const char **)draw->pt.user.vbuffer,
                                       fetch_info->start,
                                       fetch_info->count,
                                       fpme->vertex_size,
                                       draw->pt.vertex_buffer,
                                       draw->instance_id);
   else
      clipped = fpme->current_variant->jit_func_elts( &fpme->llvm->jit_context,
                                            llvm_vert_info.verts,
                                            (const char **)draw->pt.user.vbuffer,
                                            fetch_info->elts,
                                            fetch_info->count,
                                            fpme->vertex_size,
                                            draw->pt.vertex_buffer,
                                            draw->instance_id);

   /* Finished with fetch and vs:
    */
   fetch_info = NULL;
   vert_info = &llvm_vert_info;


   if ((opt & PT_SHADE) && gshader) {
      struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
      draw_geometry_shader_run(gshader,
                               draw->pt.user.gs_constants,
                               draw->pt.user.gs_constants_size,
                               vert_info,
                               prim_info,
                               &vshader->info,
                               &gs_vert_info,
                               &gs_prim_info);

      FREE(vert_info->verts);
      vert_info = &gs_vert_info;
      prim_info = &gs_prim_info;
   } else {
      if (draw_prim_assembler_is_required(draw, prim_info, vert_info)) {
         draw_prim_assembler_run(draw, prim_info, vert_info,
                                 &ia_prim_info, &ia_vert_info);

         if (ia_vert_info.count) {
            FREE(vert_info->verts);
            vert_info = &ia_vert_info;
            prim_info = &ia_prim_info;
            free_prim_info = TRUE;
         }
      }
   }

   /* stream output needs to be done before clipping */
   draw_pt_so_emit( fpme->so_emit, vert_info, prim_info );

   /*
    * if there's no position, need to stop now, or the latter stages
    * will try to access non-existent position output.
    */
   if (draw_current_shader_position_output(draw) != -1) {
      if ((opt & PT_SHADE) && gshader) {
         clipped = draw_pt_post_vs_run( fpme->post_vs, vert_info );
      }
      if (clipped) {
         opt |= PT_PIPELINE;
      }

      /* Do we need to run the pipeline? Now will come here if clipped
       */
      if (opt & PT_PIPELINE) {
         pipeline( fpme, vert_info, prim_info );
      }
      else {
         emit( fpme->emit, vert_info, prim_info );
      }
   }
   FREE(vert_info->verts);
   if (free_prim_info) {
      FREE(prim_info->primitive_lengths);
   }
}
Beispiel #21
0
static void emit_decode(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char* sn = ls->structname->shortname;
    emit(0, "int %s::decode(const void *buf, int offset, int maxlen)", sn);
    emit(0, "{");
    emit(1,     "int pos = 0, thislen;");
    emit(0, "");
    emit(1,     "int64_t msg_hash;");
    emit(1,     "thislen = __int64_t_decode_array(buf, offset + pos, maxlen - pos, &msg_hash, 1);");
    emit(1,     "if (thislen < 0) return thislen; else pos += thislen;");
    emit(1,     "if (msg_hash != getHash()) return -1;");
    emit(0, "");
    emit(1,     "thislen = this->_decodeNoHash(buf, offset + pos, maxlen - pos);");
    emit(1,     "if (thislen < 0) return thislen; else pos += thislen;");
    emit(0, "");
    emit(1,  "return pos;");
    emit(0, "}");
    emit(0, "");
}
Beispiel #22
0
void PukeController::messageHandler(int fd, PukeMessage *pm) { /*FOLD00*/
  widgetId wI, wIret;
  wI.fd = fd;
  wI.iWinId = pm->iWinId;

  commandStruct *cs;

  cs = qidCommandTable[pm->iCommand];

  if(cs != NULL){
    (this->*(cs->cmd))(fd,pm);
  }
  else if(pm->iCommand == PUKE_WIDGET_CREATE){
    wIret = wI;
    wIret.iWinId = createWidget(wI, pm).iWinId; // Create the acutal pw
    
    PukeMessage pmRet;
    pmRet.iCommand = PUKE_WIDGET_CREATE_ACK;
    pmRet.iWinId = wIret.iWinId;
    pmRet.iArg = 0;
    pmRet.cArg = strdup(pm->cArg);
//    printf("Got: %s Copied: %s\n", pm->cArg, pmRet.cArg);
    pmRet.iTextSize = strlen(pm->cArg);
    emit outputMessage(fd, &pmRet);
    free(pmRet.cArg);
  }
  else if(pm->iCommand == PUKE_WIDGET_LOAD){
    PukeMessage pmRet = *pm;
    KDynamicHandle handle;
//    const char *error;
    PObject *(*wc)(CreateArgs &ca);
    widgetCreate *wC;

    if(pm->iTextSize == 0){
      emit(errorCommandFailed(-pm->iCommand, 1));
      return;
    }

    // coolo: I concider this a major hack, but KApplication doesn't provide the libpath ;(
    handle = KDynamicLibrary::loadLibrary(kapp->kde_bindir() + "/../lib/ksirc/lib" + QString(pm->cArg), KDynamicLibrary::ResolveLazy);
    if (!handle) {
      emit(errorCommandFailed(-pm->iCommand, 1));
      return;
    }
    wc =  (PObject *(*)(CreateArgs &ca) )
        KDynamicLibrary::getSymbol(handle, "createWidget");

    wC = new("widgetCreate") widgetCreate;
    wC->wc = wc;
    wC->dlhandle = handle;
    widgetCF.insert(pm->iArg, wC);
//    warning("new("widget:") widget: %d with wc: %p and handle: %p", pm->iArg, wc, handle);

    pmRet.iCommand = -pm->iCommand;
    pmRet.iTextSize = 0;
    emit outputMessage(fd, &pmRet);
  }
  else if(pm->iCommand == PUKE_WIDGET_UNLOAD){
//    const char *error;
    if(widgetCF[pm->iArg]){
        /*
      dlclose(widgetCF[pm->iArg]->dlhandle);
      if ((error = dlerror()) != NULL)  {
	fputs(error, stderr);
	pm->iCommand = -pm->iCommand;
	pm->iArg = -1;
	emit outputMessage(fd, pm);
	return;
        }
        */
      KDynamicLibrary::unloadLibrary(widgetCF[pm->iArg]->dlhandle);
      widgetCF.remove(pm->iArg);
      pm->iCommand = -pm->iCommand;
      emit outputMessage(fd, pm);
    }
  }
  else{
    if(checkWidgetId(&wI) == TRUE){
      WidgetList[wI.fd]->find(wI.iWinId)->pwidget->messageHandler(fd, pm);
    }
    else{
      PukeMessage pmRet;
      pmRet.iCommand = PUKE_INVALID;
      pmRet.iWinId = wI.iWinId;
      pmRet.iArg = 0;
      pmRet.iTextSize = 0;
      emit outputMessage(fd, &pmRet);
    }
  }
}
Beispiel #23
0
static void emit_encode_nohash(lcmgen_t *lcm, FILE *f, lcm_struct_t *ls)
{
    const char* sn = ls->structname->shortname;
    if(0 == g_ptr_array_size(ls->members)) {
        emit(0, "int %s::_encodeNoHash(void *, int, int) const", sn);
        emit(0, "{");
        emit(1,     "return 0;");
        emit(0, "}");
        emit(0, "");
        return;
    }
    emit(0, "int %s::_encodeNoHash(void *buf, int offset, int maxlen) const", sn);
    emit(0, "{");
    emit(1,     "int pos = 0, tlen;");
    emit(0, "");
    for (unsigned int m = 0; m < g_ptr_array_size(ls->members); m++) {
        lcm_member_t *lm = (lcm_member_t *) g_ptr_array_index(ls->members, m);
        int num_dims = g_ptr_array_size(lm->dimensions);

        if (0 == num_dims) {
            if (lcm_is_primitive_type(lm->type->lctypename)) {
                if(!strcmp(lm->type->lctypename, "string")) {
                    emit(1, "char* %s_cstr = (char*) this->%s.c_str();", lm->membername, lm->membername);
                    emit(1, "tlen = __string_encode_array(buf, offset + pos, maxlen - pos, &%s_cstr, 1);",
                            lm->membername);
                } else {
                emit(1, "tlen = __%s_encode_array(buf, offset + pos, maxlen - pos, &this->%s, 1);",
                    lm->type->lctypename, lm->membername);
                }
                emit(1, "if(tlen < 0) return tlen; else pos += tlen;");
          } else {
            _encode_recursive(lcm, f, lm, 0, 0);
          }
        } else {
            lcm_dimension_t *last_dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, num_dims - 1);

            // for non-string primitive types with variable size final
            // dimension, add an optimization to only call the primitive encode
            // functions only if the final dimension size is non-zero.
            if(lcm_is_primitive_type(lm->type->lctypename) &&
                    strcmp(lm->type->lctypename, "string") &&
                    !is_dim_size_fixed(last_dim->size)) {
                emit(1, "if(%s%s > 0) {", dim_size_prefix(last_dim->size), last_dim->size);
                _encode_recursive(lcm, f, lm, 0, 1);
                emit(1, "}");
            } else {
                _encode_recursive(lcm, f, lm, 0, 0);
            }
        }

        emit(0,"");
    }
    emit(1, "return pos;");
    emit(0,"}");
    emit(0,"");
}
Beispiel #24
0
void MV_Controller::newValuesReceivedFromModel_slot(sensors newValues)
{
    emit(this->newValuesReceivedFromModel_signal(newValues));
}
Beispiel #25
0
static void _decode_recursive(lcmgen_t* lcm, FILE* f, lcm_member_t* lm, int depth)
{
    // primitive array
    if (depth+1 == g_ptr_array_size(lm->dimensions) &&
        lcm_is_primitive_type(lm->type->lctypename) &&
        strcmp(lm->type->lctypename, "string")) {
        lcm_dimension_t *dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, depth);

        int decode_indent = 1 + depth;
        if(!lcm_is_constant_size_array(lm)) {
            emit(1 + depth, "if(%s%s) {", dim_size_prefix(dim->size), dim->size);
            emit_start(2 + depth, "this->%s", lm->membername);
            for(int i=0; i<depth; i++)
                emit_continue("[a%d]", i);
            emit_end(".resize(%s%s);", dim_size_prefix(dim->size), dim->size);
            decode_indent++;
        }

        emit_start(decode_indent, "tlen = __%s_decode_array(buf, offset + pos, maxlen - pos, &this->%s",
                lm->type->lctypename, lm->membername);
        for(int i=0; i<depth; i++)
            emit_continue("[a%d]", i);
        emit_end("[0], %s%s);", dim_size_prefix(dim->size), dim->size);
        emit(decode_indent, "if(tlen < 0) return tlen; else pos += tlen;");
        if(!lcm_is_constant_size_array(lm)) {
            emit(1 + depth, "}");
        }
    } else if(depth == g_ptr_array_size(lm->dimensions)) {
        if(!strcmp(lm->type->lctypename, "string")) {
            emit(1 + depth, "int32_t __elem_len;");
            emit(1 + depth, "tlen = __int32_t_decode_array(buf, offset + pos, maxlen - pos, &__elem_len, 1);");
            emit(1 + depth, "if(tlen < 0) return tlen; else pos += tlen;");
            emit(1 + depth, "if(__elem_len > maxlen - pos) return -1;");
            emit_start(1 + depth, "this->%s", lm->membername);
            for(int i=0; i<depth; i++)
                emit_continue("[a%d]", i);
            emit_end(".assign(((const char*)buf) + offset + pos, __elem_len -  1);");
            emit(1 + depth, "pos += __elem_len;");
        } else {
            emit_start(1 + depth, "tlen = this->%s", lm->membername);
            for(int i=0; i<depth; i++)
                emit_continue("[a%d]", i);
            emit_end("._decodeNoHash(buf, offset + pos, maxlen - pos);");
            emit(1 + depth, "if(tlen < 0) return tlen; else pos += tlen;");
        }
    } else {
        lcm_dimension_t *dim = (lcm_dimension_t*) g_ptr_array_index(lm->dimensions, depth);

        if(!lcm_is_constant_size_array(lm)) {
            emit_start(1+depth, "this->%s", lm->membername);
            for(int i=0; i<depth; i++) {
                emit_continue("[a%d]", i);
            }
            emit_end(".resize(%s%s);", dim_size_prefix(dim->size), dim->size);
        }
        emit(1+depth, "for (int a%d = 0; a%d < %s%s; a%d++) {",
                depth, depth, dim_size_prefix(dim->size), dim->size, depth);

        _decode_recursive(lcm, f, lm, depth+1);

        emit(1+depth, "}");
    }
}
Beispiel #26
0
void MV_Controller::statusUpdateFromModel_slot(Status flags)
{
    emit(this->statusUpdateFromModel_signal(flags));
}
Beispiel #27
0
qnode* gen_rvalue(node* n, qnode* target) {
	switch(n->type) {
		case IDENT_NODE: {
			qnode* q = qnode_new(Q_IDENT);
			q->name = n->u.ident.id;
			q->u.ast = n;
			q->pos = &(n->u.ident.pos);
			if(n->next->type == SCALAR_NODE || n->next->type == POINTER_NODE) {	
				if(target && target->type == Q_IDENT) {
					if(target->u.ast->next->type == SCALAR_NODE) {
						emit(O_MOV, target, q, NULL);
					}
				}
				return q;
			} else if(n->next->type == ARRAY_NODE) {
				//qnode* dest = new_temp();
				//emit(O_LEA, dest, q, NULL);
				if(!target) target = new_temp();
				emit(O_LEA, target, q, NULL);
				return target;
			} else if(n->next->type == FUNCTION_NODE) {
				return q;
			} else {
				fprintf(stderr, "RVAL Unimplemented IDENT\n");
			}
			break;
		}
		case NUMBER_NODE: {
			qnode* q = qnode_new(Q_CONSTANT);
			sprintf(q->name, "%lli", n->u.number.value);
			q->u.value = n->u.number.value;
			if(target && target->type == Q_IDENT) {
				if(target->u.ast->next->type == SCALAR_NODE) {
					emit(O_MOV, target, q, NULL);
				}
			}
			return q;
			break;
		}
		case UNOP_NODE: {
			switch(n->u.unop.type) {
				case DEREF_OP: {
					//because of the AST structure, this is a bit messy
					// if(n->u.unop.operand->type == BINOP_NODE && n->u.unop.operand->u.binop.type == PLUS_OP) {
					// 	node* l = n->u.unop.operand->u.binop.left;
					// 	if(l->type == IDENT_NODE && l->next && l->next->type == ARRAY_NODE) {
					// 		return gen_rvalue(n->u.unop.operand, target);
					// 	}
					// }
					qnode* addr = gen_rvalue(n->u.unop.operand, NULL);
					if(!target) target = new_temp();
					emit(O_LOAD, target, addr, NULL);
					return target;
				}
				case POSTINC_OP: {
					qnode* q = gen_rvalue(n->u.unop.operand, NULL);
					if(!target) target = new_temp();
					emit(O_MOV, target, q, NULL);
					emit(O_INC, NULL, q, NULL);
					return target;
				}
				case POSTDEC_OP: {
					qnode* q = gen_rvalue(n->u.unop.operand, NULL);
					if(!target) target = new_temp();
					emit(O_MOV, target, q, NULL);
					emit(O_DEC, NULL, q, NULL);
					return target;
				}
				case PREINC_OP: {
					qnode* q = gen_rvalue(n->u.unop.operand, NULL);
					emit(O_INC, NULL, q, NULL);
					return q;
				}
				case PREDEC_OP: {
					qnode* q = gen_rvalue(n->u.unop.operand, NULL);
					emit(O_DEC, NULL, q, NULL);
					return q;
				}
				case LOGNOT_OP: {					
					block* bt = bb_newBlock(functionCount, ++blockCount, currentBlock);
					block* bf = bb_newBlock(functionCount, ++blockCount, bt);
					block* bn = bb_newBlock(functionCount, ++blockCount, bf);
					if(!target) target = new_temp();
					
					qnode* zero = qnode_new(Q_CONSTANT);
					zero->name = strdup("0");
					zero->u.value = 0;
					qnode* one = qnode_new(Q_CONSTANT);
					one->name = strdup("1");
					one->u.value = 1;
										
					gen_cond(n->u.unop.operand, blockToQnode(bt), blockToQnode(bf));
					currentBlock->next = bt; //reset next block in case it has changed
					bt->prev = currentBlock;
					currentBlock = bt;
					emit(O_MOV, target, zero, NULL);
					emit(O_BR, NULL, blockToQnode(bn), NULL);
					currentBlock = bf;
					emit(O_MOV, target, one, NULL);
					emit(O_BR, NULL, blockToQnode(bn), NULL);
					currentBlock = bn;
					return target;
				}
				case ADDR_OP: {
					if(!target) target = new_temp();
					emit(O_LEA, target, gen_rvalue(n->u.unop.operand, NULL), NULL);
					return target;
				}
				case NEG_OP: {
					if(!target) target = new_temp();
					qnode* val = gen_rvalue(n->u.unop.operand, NULL);
					qnode* one = qnode_new(Q_CONSTANT);
					one->name = strdup("-1");
					one->u.value = -1;
					emit(O_MUL, target, one, val);
					return target;
				}
				case POS_OP: {
					return gen_rvalue(n->u.unop.operand, NULL); //not much to do...
				}
				case SIZEOF_OP: {
					int size = 0;
					if(n->u.unop.operand->type == IDENT_NODE) {
						if(n->u.unop.operand->next->type == ARRAY_NODE) { //compute size
							node* a = n->u.unop.operand->next;
							size = a->u.array.length;
							while(a->next && a->next->type == ARRAY_NODE) {//multidimensional
								a = a->next;
								size *= a->u.array.length;
							}
							size *= sizeof(int);
						} else { //assume its an int or ptr (same size)
							size = sizeof(int);
						}
					} else if(n->u.unop.operand->type == POINTER_NODE) {
						size = sizeof(void*);
					} else if(n->u.unop.operand->type == SCALAR_NODE) {
						size = sizeof(int); //only supporting ints
					} else {
						fprintf(stderr, "RVAL unimplemented SIZEOF (type %i)\n", n->u.unop.operand->type);
						exit(1);
					}
					qnode* q = qnode_new(Q_CONSTANT);
					sprintf(q->name, "%i", size);
					q->u.value = size;
					if(target && target->type == Q_IDENT) {
						if(target->u.ast->next->type == SCALAR_NODE) {
							emit(O_MOV, target, q, NULL);
						}
					}
					return q;
				}
				default:
					fprintf(stderr, "RVAL Unimplemented UNOP %i\n", n->u.unop.type);
			}
			break;
		}
		case BINOP_NODE: {
			//boolean expression
			if((n->u.binop.type >= LT_OP && n->u.binop.type <= NOTEQ_OP) || n->u.binop.type >= LOGOR_OP) {
				if(!target) target = new_temp();
				block* temp = currentBlock;
				block* bt = bb_newBlock(functionCount, ++blockCount, currentBlock);
				block* bf = bb_newBlock(functionCount, ++blockCount, bt);
				block* bn = bb_newBlock(functionCount, ++blockCount, bf);
				
				//create qnodes for the above blocks
				qnode* trueBlock = blockToQnode(bt);
				qnode* falseBlock = blockToQnode(bf);
				qnode* nextBlock = blockToQnode(bn);

				//qnodes for zero and one
				qnode* zero = qnode_new(Q_CONSTANT);
				zero->name = strdup("0");
				zero->u.value = 0;
				qnode* one = qnode_new(Q_CONSTANT);
				one->name = strdup("1");
				one->u.value = 1;

				gen_cond(n, trueBlock, falseBlock); //evaluate expression
				currentBlock = bt; //true
				emit(O_MOV, target, one, NULL);
				emit(O_BR, NULL, nextBlock, NULL);
				currentBlock = bf; //false
				emit(O_MOV, target, zero, NULL);
				emit(O_BR, NULL, nextBlock, NULL);
				
				currentBlock = bn;
				return target;
			} else {
				node* bLeft = n->u.binop.left;
				qnode* left = gen_rvalue(n->u.binop.left, NULL);
				qnode* right = gen_rvalue(n->u.binop.right, NULL);
				if(bLeft->type == IDENT_NODE && bLeft->next->type == ARRAY_NODE) {
					qnode* size = qnode_new(Q_CONSTANT);
					int nextType = bLeft->next->next->type;
					if(nextType == SCALAR_NODE) {
						size->u.value = (long long) sizeof(int);
					} else if(nextType == POINTER_NODE) {
						size->u.value = (long long) sizeof(int*);
					} else if(nextType == ARRAY_NODE) {
						node* arr = bLeft->next->next;
						size->u.value = 1;
						while(arr) {
							size->u.value *= (long long) sizeof(int*)*arr->u.array.length;
							if(arr->next && arr->next->type == ARRAY_NODE) {
								arr = arr->next;
							} else {
								break;
							}
						}
					} else {
						fprintf(stderr, "QUAD ERROR, unimplemented sizeof\n");
					}
					qnode* temp = new_temp();
					sprintf(size->name, "%li", size->u.value);
					emit(O_MUL, temp, right, size);
					right = temp;
				}
				if(!target) target = new_temp();
				emit(getBinop(n->u.binop.type), target, left, right);
				return target;
			}
		}
		case CALL_NODE: {
			if(n->u.call.function) {
				int argnum = n->u.call.argnum;
				qnode* num = qnode_new(Q_CONSTANT);
				num->name = malloc(64);
				sprintf(num->name, "%i", argnum);
				num->u.value = argnum;
				emit(O_ARGNUM, NULL, num, NULL);
				if(argnum) { //Generate argument quad
					node* argptr = n->u.call.args;
					while(argptr) {
						emit(O_ARGDEF, NULL, gen_rvalue(argptr->u.list.start, NULL), NULL);
						if(argptr->next) {
							argptr = argptr->next;
						} else {
							break;
						}
					}
				}
				if(!target) target = new_temp();
				emit(O_CALL, target, gen_rvalue(n->u.call.function, NULL), NULL);
				return target;
			} else {
				fprintf(stderr, "Error: Call Node RVALUE\n");
			}
			break;
		}
		case STRING_NODE: {
			qnode* str = qnode_new(Q_STRING);
			str->name = malloc(64);
			sprintf(str->name, ".S%i", stringCount++);
			str->u.ast = n;
			if(target && target->type == Q_IDENT) {
				if(target->u.ast->next->type == POINTER_NODE) {
					emit(O_MOV, target, str, NULL);
					return target;
				}
			} else {
				return str;
			}
		}
		default:
			fprintf(stderr, "Error: Cannot generate RVALUE for AST node type %i\n", n->type);
			exit(1);
	}
	return NULL;
}
Beispiel #28
0
bool ARMEventTreat::Run (KTKautoPtr<KTKexception> & pError)
{
    KTKvector<IKEBarmCollectableHdl> collectable;
	
    KTKautoPtr<ARMTreatStrategy> pTreatStrat = (ARMTreatStrategy*) _strategyMap[ARMEventTreat::STRAT_GET_COLLECTIBLES];
    KTKautoPtr<ARMCollectorStrategy> pCollectorStrat = (ARMCollectorStrategy*) _strategyMap[ARMEventTreat::STRAT_GET_COLLECTOR];
    KTKautoPtr<ARMScenarioStrategy> pEventScenarioStrat = (ARMScenarioStrategy*) _strategyMap[ARMEventTreat::STRAT_GET_EXT_EVENT_SCENARIO];


        if (pTreatStrat.GetPtr() == NULL)
        {
        emit( ARMMOD, ARM_COMMON_ERR1 , "Bad Treat Strategy pointer " );
        }

        if (pCollectorStrat.GetPtr() == NULL)
        {
        emit( ARMMOD, ARM_COMMON_ERR1 , "Bad Collector Strategy pointer " );
        }

        if (pEventScenarioStrat.GetPtr() == NULL)
        {
        emit( ARMMOD, ARM_COMMON_ERR1 , "Bad  Event Scenario Strategy pointer " );
        }
       KTKstring processName = _armEntitiesFactory->GetProcessName();
        processName.LowerCase();


        KTKstring armLevel = _armEntitiesFactory->GetArmLevel();
        KTKvariant serverId = _armEntitiesFactory->GetServerId();
        KTKstring module = "ARM";
        KTKstring task = " Event Treat";

        // Initialize Control Report File
        _ctrlRpt = new ARMTreatCtrlRpt();
        _ctrlRpt->InitializeControlReport(&module, &task, &processName, &armLevel, &serverId);

    IARMEntitiesFactoryHdl entityFactory = _armEntitiesFactory; 
    if (!entityFactory.IsNotNull() )
    {
	emit (ARMMOD, ARM_COMMON_ERR1 , "We have a null entityFactory.");
    }

    emit(ARMMOD, ARM_BEGIN_EVENT_TREAT );

    if(!pTreatStrat->Initialize(entityFactory, pError)||
       !pEventScenarioStrat->Initialize(entityFactory, pError)||
       !pCollectorStrat->Initialize(entityFactory, pError))
    {
             _ctrlRpt->WriteToControlReport("ERROR: Could not initialize a strategy.");
	     std::cout << pError->DebugMessages();
             pError->DeleteAll();
                if(_ctrlRpt)
                { delete _ctrlRpt;
                _ctrlRpt=NULL; }
                return false;
    }
       if (_strategyValueMap[ARMTreat::STRAT_GET_COLLECTOR] == 1)
        if(!pCollectorStrat ->GetCollectorCount(pError))
        {
                _ctrlRpt->WriteToControlReport("ERROR: Could not get collector count.");
                std::cout << pError->DebugMessages();
                pError->DeleteAll();
                if(_ctrlRpt)
                { delete _ctrlRpt;
                _ctrlRpt=NULL; }
                return false;
        }

    //build collectable
    if(!GetCollectables(collectable, pError))
    {
        _ctrlRpt->WriteToControlReport("ERROR: Could not get event treat collectables.");
    	std::cout << pError->DebugMessages();
        pError->DeleteAll();
                if(_ctrlRpt)
                { delete _ctrlRpt;
                _ctrlRpt=NULL; }
        return false;
    }

    KTKvectorIterator<IKEBarmCollectableHdl> collectableIterator(collectable);

	//DENqa69519
	SignalProcessStatus _sps(APN_PROCESS, 
				collectable.NumberOfEntries(),
				LDB_OP, _dbConnectionCust); 
    // for each collectable
    if(!this->ProcessEachCollectable(collectableIterator,
				     pTreatStrat.GetPtr(),
				     pCollectorStrat.GetPtr(),
				     pEventScenarioStrat.GetPtr(),
				     pError))
    {
        _ctrlRpt->WriteToControlReport("ERROR: Failed to process an event treat collectable.");
        std::cout << pError->DebugMessages();
        pError->DeleteAll();
                if(_ctrlRpt)
                { delete _ctrlRpt;
                _ctrlRpt=NULL; }
        return false;
    }
    _ctrlRpt->ControlReportTrailer(pError);

                if(_ctrlRpt)
                { delete _ctrlRpt;
                _ctrlRpt=NULL; }
    return true;
}
void MPhysics2DPanningPrivate::_q_integrator(const QVariant &value)
{
    Q_Q(MPhysics2DPanning);
    Q_UNUSED(value);

    qreal accX, accY;
    qreal tempPosX;
    qreal tempPosY;

    tempPosX = posX;
    tempPosY = posY;

    if (pointerPressed) {
        positions.push_front(sceneLastPos);
    }

    if (integrationStepTimer.isValid()) {
        integrationStepDeltaTime = integrationStepTimer.restart();
    } else {
        integrationStepDeltaTime = CatchUpTime;
        integrationStepTimer.start();
    }

    if (panDirection.testFlag(Qt::Horizontal)) {
        q->integrateAxis(Qt::Horizontal,
                         posX,
                         velX,
                         accX,
                         pointerSpringX,
                         pointerPressed
                         );
    } else {
        posX = 0.0f;
        velX = 0.0f;
        accX = 0.0f;
    }

    if (panDirection.testFlag(Qt::Vertical)) {
        q->integrateAxis(Qt::Vertical,
                         posY,
                         velY,
                         accY,
                         pointerSpringY,
                         pointerPressed
                         );

    } else {
        posY = 0.0f;
        velY = 0.0f;
        accY = 0.0f;
    }

    // Integration stop condition.
    if (qAbs(accX) < 1 &&
        qAbs(accY) < 1 &&
        qAbs(velX) < MinimumBorderSpeed &&
        qAbs(velY) < MinimumBorderSpeed &&
        !pointerPressed) {

        bool inRangeX = (panDirection.testFlag(Qt::Horizontal) == false) ||
                        (posX >= range.left() && posX <= range.right());

        bool inRangeY = (panDirection.testFlag(Qt::Vertical) == false) ||
                        (posY >= range.top()  && posY <= range.bottom());

        if (!inRangeX)
            velX = ( posX < range.left() ? 1 : -1) * MinimumBorderSpeed;
        if (!inRangeY)
            velY = ( posY < range.top() ? 1 : -1) * MinimumBorderSpeed;

        if (inRangeX && inRangeY) {
            panningAnimation->stop();
            emit q->panningStopped();
        }
    }

    if (tempPosX != posX || tempPosY != posY) {
        emit(q->positionChanged(QPointF(posX, posY)));
    }
}
Beispiel #30
0
void BaseTrackPlayerImpl::slotLoadTrack(TrackPointer track, bool bPlay) {
    // Before loading the track, ensure we have access. This uses lazy
    // evaluation to make sure track isn't NULL before we dereference it.
    if (!track.isNull() && !Sandbox::askForAccess(track->getCanonicalLocation())) {
        // We don't have access.
        return;
    }

    //Disconnect the old track's signals.
    if (m_pLoadedTrack) {
        // Save the loops that are currently set in a loop cue. If no loop cue is
        // currently on the track, then create a new one.
        int loopStart = m_pLoopInPoint->get();
        int loopEnd = m_pLoopOutPoint->get();
        if (loopStart != -1 && loopEnd != -1 &&
            even(loopStart) && even(loopEnd) && loopStart <= loopEnd) {
            Cue* pLoopCue = NULL;
            QList<Cue*> cuePoints = m_pLoadedTrack->getCuePoints();
            QListIterator<Cue*> it(cuePoints);
            while (it.hasNext()) {
                Cue* pCue = it.next();
                if (pCue->getType() == Cue::LOOP) {
                    pLoopCue = pCue;
                }
            }
            if (!pLoopCue) {
                pLoopCue = m_pLoadedTrack->addCue();
                pLoopCue->setType(Cue::LOOP);
            }
            pLoopCue->setPosition(loopStart);
            pLoopCue->setLength(loopEnd - loopStart);
        }

        // WARNING: Never. Ever. call bare disconnect() on an object. Mixxx
        // relies on signals and slots to get tons of things done. Don't
        // randomly disconnect things.
        // m_pLoadedTrack->disconnect();
        disconnect(m_pLoadedTrack.data(), 0, m_pBPM, 0);
        disconnect(m_pLoadedTrack.data(), 0, this, 0);
        disconnect(m_pLoadedTrack.data(), 0, m_pKey, 0);

        m_pReplayGain->slotSet(0);

        // Causes the track's data to be saved back to the library database.
        emit(unloadingTrack(m_pLoadedTrack));
    }

    m_pLoadedTrack = track;
    if (m_pLoadedTrack) {
        // Listen for updates to the file's BPM
        connect(m_pLoadedTrack.data(), SIGNAL(bpmUpdated(double)),
                m_pBPM, SLOT(slotSet(double)));

        connect(m_pLoadedTrack.data(), SIGNAL(keyUpdated(double)),
                m_pKey, SLOT(slotSet(double)));

        // Listen for updates to the file's Replay Gain
        connect(m_pLoadedTrack.data(), SIGNAL(ReplayGainUpdated(double)),
                this, SLOT(slotSetReplayGain(double)));
    }

    // Request a new track from the reader
    emit(loadTrack(track, bPlay));
}