1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

remove u8 and i32 aliases

This commit is contained in:
Alexander Medvednikov
2019-09-01 22:37:22 +03:00
parent d078aa360b
commit 3bd7bcfac3
7 changed files with 27 additions and 51 deletions

View File

@@ -80,6 +80,7 @@ pub fn (nn u32) str() string {
return tos(buf + max - len, len)
}
/*
pub fn (nn u8) str() string {
mut n := nn
if n == u8(0) {
@@ -97,6 +98,7 @@ pub fn (nn u8) str() string {
}
return tos(buf + max - len, len)
}
*/
pub fn (nn i64) str() string {
mut n := nn

View File

@@ -1,22 +1,22 @@
const (
a = 3
u = u64(1)
)
u = u64(1)
)
fn test_const() {
b := (true && true) || false
assert b == true
assert a == 3
assert u == u64(1)
}
b := (true && true) || false
assert b == true
assert a == 3
assert u == u64(1)
}
fn test_str_methods() {
assert i8(1).str() == '1'
assert i8(-1).str() == '-1'
assert i16(1).str() == '1'
assert i16(-1).str() == '-1'
assert i32(1).str() == '1'
assert i32(-1).str() == '-1'
assert int(1).str() == '1'
assert int(-1).str() == '-1'
assert i64(1).str() == '1'
assert i64(-1).str() == '-1'
@@ -35,5 +35,5 @@ fn test_cmp() {
assert 1 ≠ 2
assert 1 ⩽ 2
assert 1 ⩾ 0
}
}
*/

View File

@@ -102,14 +102,6 @@ fn test_various_map_value() {
m4['test'] = i16(0)
assert m4['test'] == i16(0)
mut m5 := map[string]i32
m5['test'] = i32(0)
assert m5['test'] == i32(0)
mut m6 := map[string]u8
m6['test'] = u8(0)
assert m6['test'] == u8(0)
mut m7 := map[string]u16
m7['test'] = u16(0)
assert m7['test'] == u16(0)

View File

@@ -132,9 +132,6 @@ pub fn (s string) int() int {
return C.atoi(s.str)
}
pub fn (s string) i32() i32 {
return C.atol(s.str)
}
pub fn (s string) i64() i64 {
return C.atoll(s.str)
@@ -501,7 +498,7 @@ pub fn (s string) to_upper() string {
pub fn (s string) capitalize() string {
sl := s.to_lower()
cap := sl[0].str().to_upper() + sl.right(1)
return cap
return cap
}
pub fn (s string) title() string {

View File

@@ -5,12 +5,12 @@
module json
#flag -I @VROOT/thirdparty/cJSON
#flag @VROOT/thirdparty/cJSON/cJSON.o
#flag @VROOT/thirdparty/cJSON/cJSON.o
#include "cJSON.h"
struct C.cJSON {
valueint int
valuedouble f32
valuedouble f32
valuestring byteptr
}
@@ -35,13 +35,6 @@ fn jsdecode_i16(root *C.cJSON) i16 {
return i16(root.valueint)
}
fn jsdecode_i32(root *C.cJSON) i32 {
if isnil(root) {
return i32(0)
}
return i32(root.valueint)
}
fn jsdecode_i64(root *C.cJSON) i64 {
if isnil(root) {
return i64(0)
@@ -49,11 +42,11 @@ fn jsdecode_i64(root *C.cJSON) i64 {
return i64(root.valuedouble) //i64 is double in C
}
fn jsdecode_u8(root *C.cJSON) u8 {
fn jsdecode_byte(root *C.cJSON) byte {
if isnil(root) {
return u8(0)
return byte(0)
}
return u8(root.valueint)
return byte(root.valueint)
}
fn jsdecode_u16(root *C.cJSON) u16 {
@@ -124,15 +117,11 @@ fn jsencode_i16(val i16) *C.cJSON {
return C.cJSON_CreateNumber(val)
}
fn jsencode_i32(val i32) *C.cJSON {
return C.cJSON_CreateNumber(val)
}
fn jsencode_i64(val i64) *C.cJSON {
return C.cJSON_CreateNumber(val)
}
fn jsencode_u8(val u8) *C.cJSON {
fn jsencode_byte(val byte) *C.cJSON {
return C.cJSON_CreateNumber(val)
}