github.com/Konstantin8105/c4go@v0.0.0-20240505174241-768bb1c65a51/tests/code_quality/unsafe.go.expected (about)

     1  //
     2  //	Package - transpiled by c4go
     3  //
     4  //	If you have found any issues, please raise an issue at:
     5  //	https://github.com/Konstantin8105/c4go/
     6  //
     7  
     8  package code_quality
     9  
    10  import "unsafe"
    11  
    12  // str - transpiled function from  C4GO/tests/code_quality/unsafe.c:10
    13  type str struct {
    14  	i int32
    15  }
    16  
    17  type un struct{ memory unsafe.Pointer }
    18  
    19  func (unionVar *un) copy() un {
    20  	var buffer [8]byte
    21  	for i := range // un - transpiled function from  C4GO/tests/code_quality/unsafe.c:14
    22  	buffer {
    23  		buffer[i] = (*((*[8]byte)(unionVar.memory)))[i]
    24  	}
    25  	var newUnion un
    26  	newUnion.memory = unsafe.Pointer(&buffer)
    27  	return newUnion
    28  }
    29  func (unionVar *un) i() *int32 {
    30  	if unionVar.memory == nil {
    31  		var buffer [8]byte
    32  		unionVar.memory = unsafe.Pointer(&buffer)
    33  	}
    34  	return (*int32)(unionVar.memory)
    35  }
    36  func (unionVar *un) d() *float64 {
    37  	if unionVar.memory == nil {
    38  		var buffer [8]byte
    39  		unionVar.memory = unsafe.Pointer(&buffer)
    40  	}
    41  	return (*float64)(unionVar.memory)
    42  }
    43  
    44  // db - transpiled function from  C4GO/tests/code_quality/unsafe.c:19
    45  type db = float64
    46  
    47  // test_char - transpiled function from  C4GO/tests/code_quality/unsafe.c:22
    48  func test_char() {
    49  	// integers
    50  	var t byte
    51  	var pt []byte = c4goUnsafeConvert_byte(&t)
    52  	_ = t
    53  	_ = pt
    54  }
    55  
    56  // test_short - transpiled function from  C4GO/tests/code_quality/unsafe.c:23
    57  func test_short() {
    58  	var t int16
    59  	var pt []int16 = c4goUnsafeConvert_int16(&t)
    60  	_ = t
    61  	_ = pt
    62  }
    63  
    64  // test_int - transpiled function from  C4GO/tests/code_quality/unsafe.c:24
    65  func test_int() {
    66  	var t int32
    67  	var pt []int32 = c4goUnsafeConvert_int32(&t)
    68  	_ = t
    69  	_ = pt
    70  }
    71  
    72  // test_long - transpiled function from  C4GO/tests/code_quality/unsafe.c:25
    73  func test_long() {
    74  	var t int32
    75  	var pt []int32 = c4goUnsafeConvert_int32(&t)
    76  	_ = t
    77  	_ = pt
    78  }
    79  
    80  // test_li - transpiled function from  C4GO/tests/code_quality/unsafe.c:26
    81  func test_li() {
    82  	var t int32
    83  	var pt []int32 = c4goUnsafeConvert_int32(&t)
    84  	_ = t
    85  	_ = pt
    86  }
    87  
    88  // test_ll - transpiled function from  C4GO/tests/code_quality/unsafe.c:27
    89  func test_ll() {
    90  	var t int64
    91  	var pt []int64 = c4goUnsafeConvert_int64(&t)
    92  	_ = t
    93  	_ = pt
    94  }
    95  
    96  // test_lli - transpiled function from  C4GO/tests/code_quality/unsafe.c:28
    97  func test_lli() {
    98  	var t int64
    99  	var pt []int64 = c4goUnsafeConvert_int64(&t)
   100  	_ = t
   101  	_ = pt
   102  }
   103  
   104  // test_f - transpiled function from  C4GO/tests/code_quality/unsafe.c:31
   105  func test_f() {
   106  	// floats
   107  	var t float32
   108  	var pt []float32 = c4goUnsafeConvert_float32(&t)
   109  	_ = t
   110  	_ = pt
   111  }
   112  
   113  // test_d - transpiled function from  C4GO/tests/code_quality/unsafe.c:32
   114  func test_d() {
   115  	var t float64
   116  	var pt []float64 = c4goUnsafeConvert_float64(&t)
   117  	_ = t
   118  	_ = pt
   119  }
   120  
   121  // test_ld - transpiled function from  C4GO/tests/code_quality/unsafe.c:33
   122  func test_ld() {
   123  	var t float64
   124  	var pt []float64 = c4goUnsafeConvert_float64(&t)
   125  	_ = t
   126  	_ = pt
   127  }
   128  
   129  // test_struct - transpiled function from  C4GO/tests/code_quality/unsafe.c:36
   130  func test_struct() {
   131  	// struct
   132  	var t str
   133  	var pt []str = c4goUnsafeConvert_str(&t)
   134  	_ = t
   135  	_ = pt
   136  }
   137  
   138  // test_un - transpiled function from  C4GO/tests/code_quality/unsafe.c:39
   139  func test_un() {
   140  	// union
   141  	var t un
   142  	var pt []un = c4goUnsafeConvert_un(&t)
   143  	_ = t
   144  	_ = pt
   145  }
   146  
   147  // test_typedef - transpiled function from  C4GO/tests/code_quality/unsafe.c:42
   148  func test_typedef() {
   149  	// typedef
   150  	var t db
   151  	var pt []db = c4goUnsafeConvert_float64(&t)
   152  	_ = t
   153  	_ = pt
   154  }
   155  
   156  // c4goUnsafeConvert_byte : created by c4go
   157  func c4goUnsafeConvert_byte(c4go_name *byte) []byte {
   158  	return (*[1000000]byte)(unsafe.Pointer(c4go_name))[:]
   159  }
   160  
   161  // c4goUnsafeConvert_float32 : created by c4go
   162  func c4goUnsafeConvert_float32(c4go_name *float32) []float32 {
   163  	return (*[1000000]float32)(unsafe.Pointer(c4go_name))[:]
   164  }
   165  
   166  // c4goUnsafeConvert_float64 : created by c4go
   167  func c4goUnsafeConvert_float64(c4go_name *float64) []float64 {
   168  	return (*[1000000]float64)(unsafe.Pointer(c4go_name))[:]
   169  }
   170  
   171  // c4goUnsafeConvert_int16 : created by c4go
   172  func c4goUnsafeConvert_int16(c4go_name *int16) []int16 {
   173  	return (*[1000000]int16)(unsafe.Pointer(c4go_name))[:]
   174  }
   175  
   176  // c4goUnsafeConvert_int32 : created by c4go
   177  func c4goUnsafeConvert_int32(c4go_name *int32) []int32 {
   178  	return (*[1000000]int32)(unsafe.Pointer(c4go_name))[:]
   179  }
   180  
   181  // c4goUnsafeConvert_int64 : created by c4go
   182  func c4goUnsafeConvert_int64(c4go_name *int64) []int64 {
   183  	return (*[1000000]int64)(unsafe.Pointer(c4go_name))[:]
   184  }
   185  
   186  // c4goUnsafeConvert_str : created by c4go
   187  func c4goUnsafeConvert_str(c4go_name *str) []str {
   188  	return (*[1000000]str)(unsafe.Pointer(c4go_name))[:]
   189  }
   190  
   191  // c4goUnsafeConvert_un : created by c4go
   192  func c4goUnsafeConvert_un(c4go_name *un) []un {
   193  	return (*[1000000]un)(unsafe.Pointer(c4go_name))[:]
   194  }