| // Copyright (C) 2015 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| import "gfxapi_test_include.api" |
| import imported "gfxapi_test_import.api" |
| |
| class Tester { |
| imported.Imported A |
| Included B |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Intrinsics tests |
| //////////////////////////////////////////////////////////////// |
| u8[] u8s |
| u16[] u16s |
| u32[] u32s |
| int[] ints |
| string str |
| |
| cmd void cmdClone(u8* src, u32 cnt) { |
| u8s = clone(src[0:cnt]) |
| } |
| |
| cmd void cmdMake(u32 cnt) { |
| u8s = make!u8(cnt) |
| } |
| |
| cmd void cmdCopy(u8* src, u32 cnt) { |
| u8s = make!u8(cnt) |
| copy(u8s, src[0:cnt]) |
| } |
| |
| cmd void cmdCharsliceToString(char* s, u32 len) { |
| str = as!string(s[0:len]) |
| } |
| |
| cmd void cmdCharptrToString(char* s) { |
| str = as!string(s) |
| } |
| |
| cmd void cmdSliceCasts(u16* s, u32 l) { |
| u8s = as!u8[](s[0:l]) |
| u16s = as!u16[](s[0:l]) |
| u32s = as!u32[](s[0:l]) |
| ints = as!int[](s[0:l]) |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Void, no args |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoid() {} |
| |
| //////////////////////////////////////////////////////////////// |
| // Unknown tests |
| //////////////////////////////////////////////////////////////// |
| // TODO: These do not currently compile |
| // int unk |
| // |
| // cmd int cmdUnknownRet() { |
| // i := ? |
| // unk = i |
| // return i |
| // } |
| // |
| // cmd void cmdUnknownPtr(int* p) { |
| // i := ? |
| // unk = i |
| // p[0] = i |
| // } |
| |
| cmd int cmdUnknownRet() { |
| return ? |
| } |
| |
| cmd void cmdUnknownWritePtr(int* p) { |
| p[0] = ? |
| } |
| |
| cmd void cmdUnknownWriteSlice(int* a) { |
| count := 5 |
| slice := a[0:count] |
| for i in (0 .. count) { |
| unknown := as!int(?) |
| slice[i] = unknown |
| } |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with a single input argument |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidU8(u8 a) {} |
| cmd void cmdVoidS8(s8 a) {} |
| cmd void cmdVoidU16(u16 a) {} |
| cmd void cmdVoidS16(s16 a) {} |
| cmd void cmdVoidF32(f32 a) {} |
| cmd void cmdVoidU32(u32 a) {} |
| cmd void cmdVoidS32(s32 a) {} |
| cmd void cmdVoidF64(f64 a) {} |
| cmd void cmdVoidU64(u64 a) {} |
| cmd void cmdVoidS64(s64 a) {} |
| cmd void cmdVoidBool(bool a) {} |
| cmd void cmdVoidString(string a) {} |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with more than one input |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoid3Strings(string a, string b, string c) {} |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with input arrays |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoid3InArrays(u8* a, u32* b, int* c) { |
| u8s = make!u8(10) |
| read(b[5:15]) |
| read(c[5:15]) |
| copy(u8s, a[5:25]) // only 10 elements should be copied |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with input of arrays of pointers |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidInArrayOfPointers(char** a, s32 count) { |
| slice := a[0:count] |
| for i in (0 .. count) { |
| x := slice[i][0] |
| } |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with a single pointer element read |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidReadU8(u8* a) { x := a[0] } |
| cmd void cmdVoidReadS8(s8* a) { x := a[0] } |
| cmd void cmdVoidReadU16(u16* a) { x := a[0] } |
| cmd void cmdVoidReadS16(s16* a) { x := a[0] } |
| cmd void cmdVoidReadF32(f32* a) { x := a[0] } |
| cmd void cmdVoidReadU32(u32* a) { x := a[0] } |
| cmd void cmdVoidReadS32(s32* a) { x := a[0] } |
| cmd void cmdVoidReadF64(f64* a) { x := a[0] } |
| cmd void cmdVoidReadU64(u64* a) { x := a[0] } |
| cmd void cmdVoidReadS64(s64* a) { x := a[0] } |
| cmd void cmdVoidReadBool(bool* a) { x := a[0] } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with multiple pointer element reads |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidReadPtrs(f32* a, u16* b, bool* c) { |
| x := a[0] |
| y := b[0] |
| z := c[0] |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with a single pointer element write |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidWriteU8(u8* a) { a[0] = 1 } |
| cmd void cmdVoidWriteS8(s8* a) { a[0] = 1 } |
| cmd void cmdVoidWriteU16(u16* a) { a[0] = 1 } |
| cmd void cmdVoidWriteS16(s16* a) { a[0] = 1 } |
| cmd void cmdVoidWriteF32(f32* a) { a[0] = 1 } |
| cmd void cmdVoidWriteU32(u32* a) { a[0] = 1 } |
| cmd void cmdVoidWriteS32(s32* a) { a[0] = 1 } |
| cmd void cmdVoidWriteF64(f64* a) { a[0] = 1 } |
| cmd void cmdVoidWriteU64(u64* a) { a[0] = 1 } |
| cmd void cmdVoidWriteS64(s64* a) { a[0] = 1 } |
| cmd void cmdVoidWriteBool(bool* a) { a[0] = true } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with multiple pointer element writes |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoidWritePtrs(f32* a, u16* b, bool* c) { |
| a[0] = 10 |
| b[0] = 20 |
| c[0] = false |
| } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with a return value |
| //////////////////////////////////////////////////////////////// |
| cmd u8 cmdU8() { return 0 } |
| cmd s8 cmdS8() { return 0 } |
| cmd u16 cmdU16() { return 0 } |
| cmd s16 cmdS16() { return 0 } |
| cmd f32 cmdF32() { return 0 } |
| cmd u32 cmdU32() { return 0 } |
| cmd s32 cmdS32() { return 0 } |
| cmd f64 cmdF64() { return 0 } |
| cmd u64 cmdU64() { return 0 } |
| cmd s64 cmdS64() { return 0 } |
| cmd bool cmdBool() { return false } |
| cmd string cmdString() { return "" } |
| cmd void* cmdPointer() { return ? } |
| |
| //////////////////////////////////////////////////////////////// |
| // Commands with remapped arguments |
| //////////////////////////////////////////////////////////////// |
| cmd void cmdVoid3Remapped(remapped a, remapped b, remapped c) {} |
| |
| cmd void cmdVoidInArrayOfRemapped(remapped* a) { read(a[0:5]) } |
| |
| cmd void cmdVoidOutArrayOfRemapped(remapped* a) { write(a[0:5]) } |
| |
| cmd void cmdVoidOutArrayOfUnknownRemapped(remapped* a) { |
| count := 5 |
| slice := a[0:count] |
| for i in (0 .. count) { |
| unknown := as!remapped(?) |
| slice[i] = unknown |
| } |
| } |
| |
| cmd remapped cmdRemapped() { return ? } |