Esempio n. 1
0
OBJECT_PTR eval_sub_array(OBJECT_PTR array, OBJECT_PTR start, OBJECT_PTR length)
{
  OBJECT_PTR ret;
  int st = get_int_value(start);
  int len = get_int_value(length);

  uintptr_t *raw_ptr;

  uintptr_t orig_ptr, ptr;

  int i;

  //see comment in main.c for why we're not using object_alloc()
  //posix_memalign((void **)&raw_ptr, 16, sizeof(unsigned int *));
  //*((int *)raw_ptr) = len;

  orig_ptr = array & POINTER_MASK;

  ptr = object_alloc(len + 1, ARRAY_TAG);

  //set_heap(ptr, 0, convert_int_to_object(len));
  //set_heap(ptr, 0, (uintptr_t)raw_ptr + INTEGER_TAG);
  *((uintptr_t *)ptr) = len;

  for(i=1; i<=len; i++)
    set_heap(ptr, i, get_heap(orig_ptr, st + i));

  ret = ptr;

  log_function_exit("eval_sub_array");

  return ret + ARRAY_TAG;
}
 /**
  * @see cmd_line_base
  */
 virtual bool process_specific_cmd(const string & cmd) {
     //Set the number of incoming pool threads
     if (begins_with(cmd, PROGRAM_SET_INT_CMD)) {
         try {
             int32_t num_inc_threads = get_int_value(cmd, PROGRAM_SET_INT_CMD);
             ASSERT_CONDITION_THROW((num_inc_threads <= 0),
                     "The number of worker threads is to be > 0!");
             //Set the number of threads
             m_server.set_num_inc_threads(num_inc_threads);
             //Remember the new number of threads
             m_params.m_num_req_threads = num_inc_threads;
         } catch (std::exception &ex) {
             LOG_ERROR << ex.what() << "\nEnter '" << PROGRAM_HELP_CMD << "' for help!" << END_LOG;
         }
         return false;
     } else {
         //Set the number of outgoing pool threads
         if (begins_with(cmd, PROGRAM_SET_ONT_CMD)) {
             int32_t num_out_threads = get_int_value(cmd, PROGRAM_SET_ONT_CMD);
             ASSERT_CONDITION_THROW((num_out_threads <= 0),
                     "The number of worker threads is to be > 0!");
             //Set the number of threads
             m_server.set_num_out_threads(num_out_threads);
             //Remember the new number of threads
             m_params.m_num_resp_threads = num_out_threads;
             return false;
         } else {
             return true;
         }
     }
 }
Esempio n. 3
0
int CProxyConfParser::set_value(const char *pkey, const char *pvalue, void *pconf)
{
	CProxyServerConf *pproxy_conf = (CProxyServerConf *)pconf;
#ifdef _DEBUG
	assert(pproxy_conf);
#endif //_DEBUG

	if(strcmp(pkey, "master_flag") == 0)
	{
		pproxy_conf->bmaster_flag = get_bool_value(pvalue);
	}
	else if(strcmp(pkey, "vnode_count") == 0)
	{
		pproxy_conf->nvnode_count = get_int_value(pvalue);
	}
	else if(strcmp(pkey, "replica_count") == 0)
	{
		pproxy_conf->nreplica_count = get_int_value(pvalue);
	}
	else if(strcmp(pkey, "namespace_power") == 0)
	{
		pproxy_conf->nnamespace_power = get_int_value(pvalue);
	}
	else
	{
		return CBaseConfParser::set_value(pkey, pvalue, pconf);
	}
	return 0;
}
Esempio n. 4
0
/* FiXME: Use propsys.PropVariantCompareEx once it's implemented */
static int propvar_cmp(const PROPVARIANT *v1, const PROPVARIANT *v2)
{
    LONGLONG value1, value2;

    if (!get_int_value(v1, &value1)) return -1;
    if (!get_int_value(v2, &value2)) return -1;

    value1 -= value2;
    if (value1) return value1 < 0 ? -1 : 1;
    return 0;
}
Esempio n. 5
0
static int vscode_parse_request(json_value *js, ProtocolMessage *msg,
                                FILE *log) {
  const char *cmd = get_string_value(js, "command", log);
  int found = 0;
  if (cmd == NULL) return VSCODE_UNKNOWN_REQUEST;
  msg->type = VSCODE_REQUEST;
  msg->seq = get_int_value(js, "seq", log, &found);
  strncpy(msg->u.Request.command, cmd, sizeof msg->u.Request.command);
  fprintf(log, "Request --> '%s'", cmd);
  int cmdtype = get_cmdtype(msg->u.Request.command);
  switch (cmdtype) {
    case VSCODE_INITIALIZE_REQUEST:
      return vscode_parse_initialize_request(js, msg, log);
    case VSCODE_DISCONNECT_REQUEST:
    case VSCODE_ATTACH_REQUEST:
    case VSCODE_CONFIGURATION_DONE_REQUEST:
    case VSCODE_THREAD_REQUEST:
      msg->u.Request.request_type = cmdtype;
      break;
    case VSCODE_CONTINUE_REQUEST:
    case VSCODE_NEXT_REQUEST:
    case VSCODE_STEPIN_REQUEST:
    case VSCODE_STEPOUT_REQUEST:
    case VSCODE_PAUSE_REQUEST:
      return vscode_parse_intarg_request(js, msg, cmdtype, "threadId", log);
    case VSCODE_SCOPES_REQUEST:
      return vscode_parse_intarg_request(js, msg, cmdtype, "frameId", log);
    case VSCODE_LAUNCH_REQUEST:
      return vscode_parse_launch_request(js, msg, cmdtype, log);
    case VSCODE_UNKNOWN_REQUEST: break;
    default: msg->u.Request.request_type = cmdtype;
  }
  return cmdtype;
}
Esempio n. 6
0
OBJECT_PTR eval_make_array(OBJECT_PTR size, OBJECT_PTR default_value)
{
  int sz = get_int_value(size);

  uintptr_t *raw_ptr;

  uintptr_t ptr;

  int i;

  assert(IS_INTEGER_OBJECT(size));

  //see comment in main.c for why we're not using object_alloc()
  //posix_memalign((void **)&raw_ptr, 16, sizeof(unsigned int *));
  //*((int *)raw_ptr) = sz;

  ptr = object_alloc(sz+1, ARRAY_TAG);

  //set_heap(ptr, 0, size);
  //set_heap(ptr, 0, (uintptr_t)raw_ptr + INTEGER_TAG);
  *((uintptr_t *)ptr) = sz;

  for(i=0; i<sz; i++)
    set_heap(ptr, i + 1, clone_object(default_value));

  return ptr + ARRAY_TAG;
}
Esempio n. 7
0
static int vscode_parse_intarg_request(json_value *js, ProtocolMessage *msg,
                                       int msgtype, const char *key,
                                       FILE *log) {
  json_value *args = get_object_value(js, "arguments", log);
  if (args == NULL) return VSCODE_UNKNOWN_REQUEST;
  int found = 0;
  msg->u.Request.u.CommonIntRequest.integer =
      get_int_value(args, key, log, &found);
  msg->u.Request.request_type = msgtype;
  return msgtype;
}
Esempio n. 8
0
/* FiXME: Use propsys.PropVariantCompareEx once it's implemented */
static int propvar_cmp(const PROPVARIANT *v1, const PROPVARIANT *v2)
{
    LONGLONG value1, value2;

    if (v1->vt == VT_LPSTR && v2->vt == VT_LPSTR)
    {
        return lstrcmpA(v1->u.pszVal, v2->u.pszVal);
    }

    if (v1->vt == VT_LPWSTR && v2->vt == VT_LPWSTR)
    {
        return lstrcmpiW(v1->u.pwszVal, v2->u.pwszVal);
    }

    if (!get_int_value(v1, &value1)) return -1;
    if (!get_int_value(v2, &value2)) return -1;

    value1 -= value2;
    if (value1) return value1 < 0 ? -1 : 1;
    return 0;
}
Esempio n. 9
0
inline void print_field_value(byte *value, ulint len, field_def_t *field) {
	switch (field->type) {
		case FT_INTERNAL:
    		break;

		case FT_CHAR:
		case FT_TEXT:
            print_string((char*)value, len, field);
			break;

		case FT_UINT:
            printf("%llu", get_uint_value(field, value));
			break;

		case FT_INT:
            printf("%lli", get_int_value(field, value));
			break;

		case FT_FLOAT:
			printf("%f", mach_float_read(value));
			break;

		case FT_DOUBLE:
			printf("%lf", mach_double_read(value));
			break;

		case FT_DATETIME:
			print_datetime(make_longlong(mach_read_from_8(value)));
			break;

		case FT_DATE:
			print_date(mach_read_from_3(value));
			break;

		case FT_TIME:
			print_time(mach_read_from_3(value));
			break;

		case FT_ENUM:
			print_enum(mach_read_from_1(value), field);
			break;

        case FT_DECIMAL:
            print_decimal(value, field);
            break;

		default:
    		printf("undef(%d)", field->type);
	}
}
Esempio n. 10
0
			virtual perf_list_type get_performance_data(object_factory context, std::string alias, node_type warn, node_type crit, node_type minimum, node_type maximum)  {
				perf_list_type ret;
				native_context_type native_context = reinterpret_cast<native_context_type>(context.get());
				if (native_context != NULL && native_context->has_object()) {
					long long warn_value = 0;
					long long crit_value = 0;
					long long current_value = get_int_value(context);
					if (warn)
						warn_value = warn->get_int_value(context);
					if (crit)
						crit_value = crit->get_int_value(context);
					BOOST_FOREACH(int_performance_generator &p, perfgen) {
						if (!p->is_configured())
							p->configure(name_, context);
						p->eval(ret, context, alias, current_value, warn_value, crit_value, native_context->get_object());
					}
				}
Esempio n. 11
0
static gboolean
signal_emit_handler (gpointer p)
{
  CallbackPara *para = (CallbackPara*)p;
  jobject global_ac = para->global_ac;
  JNIEnv *jniEnv = jaw_util_get_jni_env();
  if (jniEnv == NULL)
  {
    if (jaw_debug)
      g_warning("signal_emit_handler: jniEnv == NULL");
    free_callback_para(para);
    return G_SOURCE_REMOVE;
  }

  jobjectArray args = para->args;

  if (global_ac == NULL)
  {
    if (jaw_debug)
      g_warning("signal_emit_handler: global_ac == NULL");
    free_callback_para(para);
    return G_SOURCE_REMOVE;
  }

  JawImpl* jaw_impl = jaw_impl_find_instance(jniEnv, global_ac);

  if (jaw_impl == NULL)
  {
    if (jaw_debug)
      g_warning("signal_emit_handler: jaw_impl == NULL");
    free_callback_para(para);
    return G_SOURCE_REMOVE;
  }

  AtkObject* atk_obj = ATK_OBJECT(jaw_impl);

  switch (para->signal_id)
  {
    case Sig_Text_Caret_Moved:
    {
      gint cursor_pos = get_int_value(jniEnv,
                                      (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
      g_signal_emit_by_name(atk_obj, "text_caret_moved", cursor_pos);
      break;
    }
    case Sig_Text_Property_Changed_Insert:
    {
      gint insert_position = get_int_value(jniEnv,
                                           (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
      gint insert_length = get_int_value(jniEnv,
                                         (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1));
      g_signal_emit_by_name(atk_obj,
                            "text_changed::insert",
                            insert_position,
                            insert_length);
      break;
    }
    case Sig_Text_Property_Changed_Delete:
    {
      gint delete_position = get_int_value(jniEnv,
                                           (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
      gint delete_length = get_int_value(jniEnv,
                                         (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1));
      g_signal_emit_by_name(atk_obj,
                            "text_changed::delete",
                            delete_position,
                            delete_length);
      break;
    }
    case Sig_Object_Children_Changed_Add:
    {
      gint child_index = get_int_value(jniEnv,
                                       (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
      jobject child_ac = (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1);
      JawImpl *child_impl = jaw_impl_get_instance(jniEnv, child_ac);
      if (child_impl == NULL)
      {
        if (jaw_debug)
          g_warning("signal_emit_handler: child_impl == NULL");
        free_callback_para(para);
        return G_SOURCE_REMOVE;
      }
      if (!child_impl)
      {
        break;
      }

      g_signal_emit_by_name(atk_obj,
                            "children_changed::add",
                            child_index,
                            child_impl);
        break;
      }
      case Sig_Object_Children_Changed_Remove:
      {
        gint child_index = get_int_value(jniEnv,
                                         (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
        jobject child_ac = (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1);
        JawImpl *child_impl = jaw_impl_find_instance(jniEnv, child_ac);
        if (!child_impl)
        {
          break;
        }

        g_signal_emit_by_name(atk_obj,
                              "children_changed::remove",
                              child_index,
                              child_impl);
        if (G_OBJECT(atk_obj) != NULL)
          g_object_unref(G_OBJECT(atk_obj));
        break;
      }
      case Sig_Object_Active_Descendant_Changed:
      {
      jobject child_ac = (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0);
      JawImpl *child_impl = jaw_impl_get_instance(jniEnv, child_ac);
      if (child_impl == NULL)
      {
        if (jaw_debug)
          g_warning("signal_emit_handler: child_impl == NULL");
        free_callback_para(para);
        return G_SOURCE_REMOVE;
      }
      if (!child_impl)
      {
        break;
      }

      g_signal_emit_by_name(atk_obj,
                            "active_descendant_changed",
                            child_impl);
      break;
    }
    case Sig_Object_Selection_Changed:
    {
      g_signal_emit_by_name(atk_obj,
                            "selection_changed");
      break;
    }
    case Sig_Object_Visible_Data_Changed:
    {
      g_signal_emit_by_name(atk_obj,
                            "visible_data_changed");
      break;
    }
    case Sig_Object_Property_Change_Accessible_Actions:
    {
      gint oldValue = get_int_value(jniEnv,
                                    (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));
      gint newValue = get_int_value(jniEnv,
                                    (*jniEnv)->GetObjectArrayElement(jniEnv, args, 1));
      AtkPropertyValues values = { NULL };

      // GValues must be initialized
      g_assert (!G_VALUE_HOLDS_INT (&values.old_value));
      g_value_init(&values.old_value, G_TYPE_INT);
      g_assert (G_VALUE_HOLDS_INT (&values.old_value));
      g_value_set_int(&values.old_value, oldValue);
      if (jaw_debug)
        printf ("%d\n", g_value_get_int(&values.old_value));

      g_assert (!G_VALUE_HOLDS_INT (&values.new_value));
      g_value_init(&values.new_value, G_TYPE_INT);
      g_assert (G_VALUE_HOLDS_INT (&values.new_value));
      g_value_set_int(&values.new_value, newValue);
      if (jaw_debug)
        printf ("%d\n", g_value_get_int(&values.new_value));

      values.property_name = "accessible-actions";

      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-actions",
                            &values);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Value:
    {
      g_object_notify(G_OBJECT(atk_obj), "accessible-value");
      break;
    }
    case Sig_Object_Property_Change_Accessible_Description:
    {
      g_object_notify(G_OBJECT(atk_obj), "accessible-description");
      break;
    }
    case Sig_Object_Property_Change_Accessible_Name:
    {
      g_object_notify(G_OBJECT(atk_obj), "accessible-name");
      break;
     }
    case Sig_Object_Property_Change_Accessible_Hypertext_Offset:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-hypertext-offset",
                            NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Caption:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-table-caption",
                            NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Summary:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-table-summary",
                            NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Column_Header:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-table-column-header",
                            NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Column_Description:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-table-column-description",
                            NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Row_Header:
    {
      g_signal_emit_by_name(atk_obj,
      "property_change::accessible-table-row-header",
      NULL);
      break;
    }
    case Sig_Object_Property_Change_Accessible_Table_Row_Description:
    {
      g_signal_emit_by_name(atk_obj,
                            "property_change::accessible-table-row-description",
                            NULL);
      break;
    }
    case Sig_Table_Model_Changed:
    {
      g_signal_emit_by_name(atk_obj,
                            "model_changed");
      break;
    }
    case Sig_Text_Property_Changed:
    {
      JawObject * jaw_obj = JAW_OBJECT(atk_obj);

      gint newValue = get_int_value(jniEnv,
                                    (*jniEnv)->GetObjectArrayElement(jniEnv, args, 0));

      gint prevCount = GPOINTER_TO_INT(g_hash_table_lookup(jaw_obj->storedData,
                                                           "Previous_Count"));
      gint curCount = atk_text_get_character_count(ATK_TEXT(jaw_obj));

      g_hash_table_insert(jaw_obj->storedData,
                          "Previous_Count",
                          GINT_TO_POINTER(curCount));

      if (curCount > prevCount)
      {
        g_signal_emit_by_name(atk_obj,
                              "text_changed::insert",
                              newValue,
                              curCount - prevCount);
      }
      else if (curCount < prevCount)
      {
        g_signal_emit_by_name(atk_obj,
                              "text_changed::delete",
                              newValue,
                              prevCount - curCount);
      }
      break;
    }
    default:
      break;
  }
  free_callback_para(para);
  return G_SOURCE_REMOVE;
}
Esempio n. 12
0
    bool RotateOP::init(const map<string, string>& config) {
        get_int_value(config, "angle", angle_fno_, angle_);

        return is_init();
    }
Esempio n. 13
0
void d_int(solid_vm *vm, char *name)
{
	debug("%s: %d, type of %d", name, get_int_value(get_namespace(get_current_namespace(vm), solid_str(name))), get_namespace(get_current_namespace(vm), solid_str(name))->type);
}
Esempio n. 14
0
int C_control_value::compare_value_with_string(char *reline,char *line)
{   /*check string if thai string is value name then replase it by data in val*/
    int i=0,j=0,len=strlen(line);
    char valname[MAX_VAL_NAME],valname2[MAX_VAL_NAME],replase_val[MAX_VAL_STRING];

    bool exitloopj=false;

    char *tmpline=NULL;
    tmpline=(char *)calloc(strlen(line)+MAX_VAL_STRING,sizeof(char));



    char *tmpline2=NULL;
    int lenstr=strlen(line)+MAX_VAL_STRING;
    tmpline2=(char *)calloc(strlen(line)+MAX_VAL_STRING,sizeof(char));
    strcpy(tmpline,line);
    strcpy(tmpline2,line);

    //printf("xxxxx-->%d %d\n",strlen(line)+1,strlen(tmpline ));
    //printf("test1\n");
    memset(valname,'\0',sizeof(valname));
    memset(valname2,'\0',sizeof(valname2));
    memset(replase_val,'\0',sizeof(replase_val));
    //printf("\n\ni have $ iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii len=%d\n\n",len);

    //printf("test2\n");
    while(i<len){
        if(tmpline[i]=='$'){


            j=1;
            exitloopj=false;
            //printf("==munber all of value =%d==\n",check_howmany_val());
            /*exitloopj dose not use*/
            while(j<=check_howmany_val()&&(exitloopj==false)){
                get_valname(valname,j);
                //printf("loop j=%d\n",j);
                //printf("numval=%d\n",check_howmany_val());
                int replase=-1;
                if(get_kind_by_index(j)==1){ sprintf(replase_val,"%d",get_int_value(j) );}
                else if(get_kind_by_index(j)==2){    get_string_value(j,replase_val); }
                sprintf(valname2,"[%s]",valname);
                //printf("%s -- %s\n",line,tmpline);
                //printf("len of tmpline2 =%d\n",lenstr);
                //printf("valuename=%s replased=%s by=%s\n",valname2,tmpline,replase_val);
                replase=convert.convert_syntax_replase(tmpline2,tmpline,replase_val,valname2);
                //printf("2 %s -- %s\n",line,tmpline);
                //printf("2numval=%d\n",check_howmany_val());
                strcpy(tmpline,tmpline2);
                //printf("3numval=%d\n",check_howmany_val());
                // printf("===============================tmpline2=%s->%d  %s\n",tmpline2,replase,valname2);
                memset(valname,'\0',sizeof(valname));
                memset(valname2,'\0',sizeof(valname2));
                memset(replase_val,'\0',sizeof(replase_val));
                //if(replase>0){/*printf("true\n");*/ exitloopj=true; }
                j++;
            }


        }
        i++;
    }

    //printf("===============================tmpline2=%s-\n",tmpline);
    //printf("test3\n");

    strcpy(reline,tmpline);
    //printf("%d %d->%s\n",strlen(reline),strlen(tmpline),tmpline);
    //printf("test4\n");
    free(tmpline);
    //printf("test5\n");
    free(tmpline2);
    //printf("test6\n");
    return 0;
}
Esempio n. 15
0
    bool SizeupOP::init(const map<string, string>& config) {
        get_int_value(config, "size", size_fno_, size_);

        return is_init();
    }