Example #1
0
static wi_string_t * _wi_set_description(wi_runtime_instance_t *instance) {
	wi_set_t				*set = instance;
	_wi_set_bucket_t		*bucket;
	wi_mutable_string_t		*string;
	wi_string_t				*description;
	wi_uinteger_t			i;

	string = wi_mutable_string_with_format(WI_STR("<%@ %p>{count = %lu, mutable = %u, values = (\n"),
		wi_runtime_class_name(set),
		set,
		set->data_count,
		wi_runtime_options(set) & WI_RUNTIME_OPTION_MUTABLE ? 1 : 0);

	for(i = 0; i < set->buckets_count; i++) {
		for(bucket = set->buckets[i]; bucket; bucket = bucket->next) {
			if(set->callbacks.description)
				description = (*set->callbacks.description)(bucket->data);
			else
				description = wi_string_with_format(WI_STR("%p"), bucket->data);

			wi_mutable_string_append_format(string, WI_STR("    %@\n"), description);
		}
	}
	
	wi_mutable_string_append_string(string, WI_STR(")}"));
	
	wi_runtime_make_immutable(string);

	return string;
}
Example #2
0
static wi_string_t * _wi_array_description(wi_runtime_instance_t *instance) {
	wi_array_t			*array = instance;
	wi_string_t			*string, *description;
	void				*data;
	wi_uinteger_t		i;
	
	string = wi_string_with_format(WI_STR("<%@ %p>{count = %lu, values = (\n"),
		wi_runtime_class_name(array),
		array,
		array->data_count);
	
	for(i = 0; i < array->data_count; i++) {
		data = WI_ARRAY(array, i);
		
		if(array->callbacks.description)
			description = (*array->callbacks.description)(data);
		else
			description = wi_string_with_format(WI_STR("%p"), data);
		
		wi_string_append_format(string, WI_STR("    %lu: %@\n"), i, description);
	}
	
	wi_string_append_string(string, WI_STR(")}"));
	
	return string;
}
Example #3
0
static wi_string_t * _wi_p7_message_description(wi_runtime_instance_t *instance) {
	wi_p7_message_t			*p7_message = instance;
	wi_enumerator_t			*enumerator;
	wi_dictionary_t			*fields;
	wi_mutable_string_t		*string;
	wi_string_t				*field_name, *field_value;
	
	string = wi_mutable_string_with_format(WI_STR("<%@ %p>{name = %@, buffer = %@, fields = (\n"),
        wi_runtime_class_name(p7_message),
        p7_message,
		p7_message->name,
		wi_data_with_bytes_no_copy(p7_message->binary_buffer, p7_message->binary_size, false));
	
	fields		= wi_p7_message_fields(p7_message);
	enumerator	= wi_dictionary_key_enumerator(fields);
	
	while((field_name = wi_enumerator_next_data(enumerator))) {
		field_value = wi_dictionary_data_for_key(fields, field_name);

		wi_mutable_string_append_format(string, WI_STR("    %@ = %@\n"),
			field_name, field_value);
	}
	
	wi_mutable_string_append_string(string, WI_STR(")}"));
	
	wi_runtime_make_immutable(string);
	
	return string;
}
Example #4
0
static wi_string_t * _wi_address_description(wi_runtime_instance_t *instance) {
	wi_address_t			*address = instance;
	wi_string_t				*family;
	
	switch(wi_address_family(address)) {
		case WI_ADDRESS_IPV4:
			family = WI_STR("ipv4");
			break;

		case WI_ADDRESS_IPV6:
			family = WI_STR("ipv6");
			break;

		case WI_ADDRESS_NULL:
		default:
			family = WI_STR("none");
			break;
	}
	
	return wi_string_with_format(WI_STR("<%@ %p>{family = %@, address = %@, port = %lu}"),
	   wi_runtime_class_name(address),
	   address,
	   family,
	   wi_address_string(address),
	   wi_address_port(address));
}
Example #5
0
static wi_string_t * _wi_dictionary_description(wi_runtime_instance_t *instance) {
    wi_dictionary_t             *dictionary = instance;
    _wi_dictionary_bucket_t     *bucket;
    wi_mutable_string_t         *string;
    wi_string_t                 *key_description, *value_description;
    wi_uinteger_t               i;

    string = wi_mutable_string_with_format(WI_STR("<%@ %p>{count = %lu, mutable = %u, values = (\n"),
                                           wi_runtime_class_name(dictionary),
                                           dictionary,
                                           dictionary->key_count,
                                           wi_runtime_options(dictionary) & WI_RUNTIME_OPTION_MUTABLE ? 1 : 0);

    for(i = 0; i < dictionary->buckets_count; i++) {
        for(bucket = dictionary->buckets[i]; bucket; bucket = bucket->next) {
            if(dictionary->key_callbacks.description)
                key_description = (*dictionary->key_callbacks.description)(bucket->key);
            else
                key_description = wi_string_with_format(WI_STR("%p"), bucket->key);

            if(dictionary->value_callbacks.description)
                value_description = (*dictionary->value_callbacks.description)(bucket->data);
            else
                value_description = wi_string_with_format(WI_STR("%p"), bucket->data);

            wi_mutable_string_append_format(string, WI_STR("    %@: %@\n"), key_description, value_description);
        }
    }

    wi_mutable_string_append_string(string, WI_STR(")}"));

    wi_runtime_make_immutable(string);

    return string;
}
Example #6
0
static wi_string_t * wd_client_info_description(wi_runtime_instance_t *instance) {
	wd_client_info_t		*client_info = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{%@}"),
		wi_runtime_class_name(client_info),
		client_info,
		wd_client_info_string(client_info));
}
Example #7
0
static wi_string_t * _wi_file_description(wi_runtime_instance_t *instance) {
	wi_file_t		*file = instance;
	
	return wi_string_with_format(WI_STR("<%s %p>{descriptor = %d}"),
	  wi_runtime_class_name(file),
	  file,
	  file->fd);
}
Example #8
0
static wi_string_t * _wi_enumerator_description(wi_runtime_instance_t *instance) {
	wi_enumerator_t			*enumerator = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{collection = %@}"),
		wi_runtime_class_name(enumerator),
		enumerator,
		enumerator->collection);
}
Example #9
0
static wi_string_t * _wi_x509_description(wi_runtime_instance_t *instance) {
	wi_x509_t		*x509 = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{x509 = %p}"),
        wi_runtime_class_name(x509),
		x509,
		x509->x509);
}
Example #10
0
static wi_string_t * _wi_date_description(wi_runtime_instance_t *instance) {
	wi_date_t		*date = instance;
	
	return wi_string_with_format(WI_STR("<%s %p>{interval = %.2f}"),
		wi_runtime_class_name(date),
		date,
		date->interval);
}
Example #11
0
static wi_string_t * _wi_date_description(wi_runtime_instance_t *instance) {
    wi_date_t   *date = instance;
    
    return wi_string_with_format(WI_STR("<%@ %p>{date = %@}"),
        wi_runtime_class_name(date),
        date,
        wi_time_interval_string_with_format(date->interval, WI_STR("%Y-%m-%d %H:%M:%S %z")));
}
Example #12
0
static wi_string_t * wd_transfer_description(wi_runtime_instance_t *instance) {
	wd_transfer_t		*transfer = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{path = %@}"),
		wi_runtime_class_name(transfer),
		transfer,
		transfer->path);
}
Example #13
0
static wi_string_t * _wi_uuid_description(wi_runtime_instance_t *instance) {
	wi_uuid_t		*uuid = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{string = %@}"),
		wi_runtime_class_name(uuid),
		uuid,
		_wi_uuid_string(uuid));
}
Example #14
0
static wi_string_t * _wi_timer_description(wi_runtime_instance_t *instance) {
	wi_timer_t		*timer = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{interval = %.2fs}"),
		wi_runtime_class_name(instance),
		instance,
		timer->interval);
}
static wi_string_t * _wi_string_encoding_description(wi_runtime_instance_t *instance) {
    wi_string_encoding_t   *encoding = instance;
    
    return wi_string_with_format(WI_STR("<%@ %p>{encoding = %@}"),
        wi_runtime_class_name(encoding),
        encoding,
        encoding->target_encoding);
}
Example #16
0
static wi_string_t * wd_chat_description(wi_runtime_instance_t *instance) {
	wd_chat_t		*chat = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{cid = %u, users = %@}"),
		wi_runtime_class_name(chat),
		chat,
		chat->cid,
		chat->users);
}
Example #17
0
static wi_string_t * _wi_socket_description(wi_runtime_instance_t *instance) {
	wi_socket_t		*socket = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{sd = %d, address = %@}"),
		wi_runtime_class_name(socket),
		socket,
		socket->sd,
		socket->address);
}
Example #18
0
static wi_string_t * _wi_p7_socket_description(wi_runtime_instance_t *instance) {
	wi_p7_socket_t		*p7_socket = instance;

	return wi_string_with_format(WI_STR("<%@ %p>{options = 0x%X, socket = %@}"),
		wi_runtime_class_name(p7_socket),
		p7_socket,
		p7_socket->options,
		p7_socket->socket);
}
Example #19
0
static wi_string_t * wr_user_description(wi_runtime_instance_t *instance) {
	wr_user_t		*user = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{uid = %u, nick = %@}"),
		wi_runtime_class_name(user),
		user,
		user->uid,
		user->nick);
}
Example #20
0
static wi_string_t * _wi_process_description(wi_runtime_instance_t *instance) {
	wi_process_t		*process = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{name = %@, arguments = %@}"),
		wi_runtime_class_name(process),
		process,
		process->name,
		process->arguments);
}
Example #21
0
static wi_string_t * wd_tempban_description(wi_runtime_instance_t *instance) {
	wd_tempban_t		*tempban = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{ip = %@, time_remaining = %.0f}"),
		wi_runtime_class_name(tempban),
		tempban,
		tempban->ip,
		wi_time_interval() - tempban->interval);
}
Example #22
0
static wi_string_t * _wi_rsa_description(wi_runtime_instance_t *instance) {
	wi_rsa_t		*rsa = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{key = %p, bits = %lu}"),
        wi_runtime_class_name(rsa),
		rsa,
		rsa->rsa,
		wi_rsa_bits(rsa));
}
Example #23
0
static wi_string_t * wd_tracker_description(wi_runtime_instance_t *instance) {
	wd_tracker_t		*tracker = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{host = %@, category = %@, active = %d}"),
		wi_runtime_class_name(tracker),
		tracker,
		tracker->host,
		tracker->category,
		tracker->active);
}
Example #24
0
static wi_string_t * wd_user_description(wi_runtime_instance_t *instance) {
	wd_user_t		*user = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{nick = %@, login = %@, ip = %@}"),
		wi_runtime_class_name(user),
		user,
		user->nick,
		user->login,
		user->ip);
}
Example #25
0
static wi_string_t * _wi_cipher_description(wi_runtime_instance_t *instance) {
	wi_cipher_t		*cipher = instance;
	
	return wi_string_with_format(WI_STR("<%@ %p>{name = %@, bits = %lu, iv = %@, key = %@}"),
        wi_runtime_class_name(cipher),
		cipher,
		wi_cipher_name(cipher),
		wi_cipher_bits(cipher),
		wi_cipher_iv(cipher),
		wi_cipher_key(cipher));
}
Example #26
0
void wi_test_runtime_info(void) {
	_wi_runtimetest_t		*runtimetest;
	
	WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_name(WI_STR("_wi_runtimetest_t")), &_wi_runtimetest_runtime_class, "");
	WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_id(_wi_runtimetest_runtime_id), &_wi_runtimetest_runtime_class, "");
	
	runtimetest = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42);
	
	WI_TEST_ASSERT_EQUALS(wi_runtime_id(runtimetest), _wi_runtimetest_runtime_id, "");
	WI_TEST_ASSERT_EQUALS(wi_runtime_class(runtimetest), &_wi_runtimetest_runtime_class, "");
	WI_TEST_ASSERT_EQUAL_INSTANCES(wi_runtime_class_name(runtimetest), wi_string_with_cstring(_wi_runtimetest_runtime_class.name), "");
	
	wi_release(runtimetest);
}
Example #27
0
void wi_test_runtime_info(void) {
    _wi_runtimetest_t   *runtimetest;
    
    WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_name(WI_STR("_wi_runtimetest_t")), &_wi_runtimetest_runtime_class, "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_class_with_id(_wi_runtimetest_runtime_id), &_wi_runtimetest_runtime_class, "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_id_for_class(&_wi_runtimetest_runtime_class), _wi_runtimetest_runtime_id, "");
    
    runtimetest = _wi_runtimetest_init_with_value(_wi_runtimetest_alloc(), 42);
    
    WI_TEST_ASSERT_EQUALS(wi_runtime_class(runtimetest), &_wi_runtimetest_runtime_class, "");
    WI_TEST_ASSERT_EQUAL_INSTANCES(wi_runtime_class_name(runtimetest), wi_string_with_utf8_string(_wi_runtimetest_runtime_class.name), "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_id(runtimetest), _wi_runtimetest_runtime_id, "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_options(runtimetest), WI_RUNTIME_OPTION_IMMUTABLE, "");
    
    wi_release(runtimetest);
}
Example #28
0
void wi_test_runtime_invalid(void) {
    WI_TEST_ASSERT_NULL(wi_runtime_class_with_name(WI_STR("foo")), "");
    WI_TEST_ASSERT_NULL(wi_runtime_class_with_id(1337), "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_id_for_class(NULL), WI_RUNTIME_ID_NULL, "");
    
    WI_TEST_ASSERT_NULL(wi_runtime_class("foo"), "");
    WI_TEST_ASSERT_NULL(wi_runtime_class_name("foo"), "");
    WI_TEST_ASSERT_EQUALS(wi_runtime_id("foo"), WI_RUNTIME_ID_NULL, "");

    WI_TEST_ASSERT_NULL(wi_retain(NULL), "");
    WI_TEST_ASSERT_EQUALS(wi_retain_count(NULL), 0U, "");
    WI_TEST_ASSERT_NULL(wi_copy(NULL), "");
    WI_TEST_ASSERT_NULL(wi_mutable_copy(NULL), "");
    WI_TEST_ASSERT_TRUE(wi_is_equal(NULL, NULL), "");
    WI_TEST_ASSERT_FALSE(wi_is_equal(NULL, "foo"), "");
    WI_TEST_ASSERT_FALSE(wi_is_equal(wi_array(), wi_dictionary()), "");
    WI_TEST_ASSERT_NULL(wi_description(NULL), "");
    WI_TEST_ASSERT_EQUALS(wi_hash(NULL), 0U, "");
}
Example #29
0
static wi_string_t * _wi_number_description(wi_runtime_instance_t *instance) {
	wi_number_t				*number = instance;
	wi_mutable_string_t		*string;
	
	string = wi_mutable_string_with_format(WI_STR("<%@ %p>{value = "),
		wi_runtime_class_name(number),
		number);
	
	if(_wi_number_is_float(number))
		wi_mutable_string_append_format(string, WI_STR("%f"), wi_number_double(number));
	else
		wi_mutable_string_append_format(string, WI_STR("%lld"), wi_number_int64(number));
	
	wi_mutable_string_append_string(string, WI_STR("}"));
	
	wi_runtime_make_immutable(string);
	
	return string;
}
Example #30
0
static wi_string_t * _wi_p7_message_description(wi_runtime_instance_t *instance) {
	wi_p7_message_t		*p7_message = instance;
	wi_hash_t			*fields;
	wi_enumerator_t		*enumerator;
	wi_string_t			*description, *xml_string, *field_name;
	
	description = wi_string_init_with_format(wi_string_alloc(), WI_STR("<%@ %p>{name = %@, serialization = %@"),
        wi_runtime_class_name(p7_message),
        p7_message,
		p7_message->name,
		p7_message->serialization == WI_P7_BINARY ? WI_STR("binary") : WI_STR("xml"));
	
	if(p7_message->serialization == WI_P7_BINARY) {
		wi_string_append_format(description, WI_STR(", buffer = %@, fields = (\n"),
			wi_data_with_bytes_no_copy(p7_message->binary_buffer, p7_message->binary_size, false));
	} else {
		if(p7_message->xml_string)
			xml_string = p7_message->xml_string;
		else
			xml_string = wi_string_with_bytes(p7_message->xml_buffer, p7_message->xml_length);
			
		wi_string_append_format(description, WI_STR(", xml = \"%@\", fields = (\n"),
			xml_string);
	}
	
	fields = wi_p7_message_fields(p7_message);
	enumerator = wi_hash_key_enumerator(fields);
	
	while((field_name = wi_enumerator_next_data(enumerator))) {
		wi_string_append_format(description, WI_STR("    %@ = %@\n"),
			field_name, wi_hash_data_for_key(fields, field_name));
	}

	wi_string_append_string(description, WI_STR(")}"));
	
	return wi_autorelease(description);
}