Mercurial > projects > qtd
comparison d2/qtd/ArrayOpsPrimitive.d @ 357:9784459f0750
An attempt (failed due to optlink) to improve locality of declarations exported from QtD executables
Q_CLASSINFO implementation
Now Qtd can be built on Windows
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Wed, 02 Jun 2010 19:38:05 +0300 |
parents | 96a75b1e5b26 |
children |
comparison
equal
deleted
inserted
replaced
356:12cec2d14e1c | 357:9784459f0750 |
---|---|
1 /** | 1 /** |
2 * | 2 Copyright: Copyright QtD Team, 2008-2010 |
3 * Copyright: Copyright QtD Team, 2008-2009 | 3 License: Boost License 1.0 |
4 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a> | 4 */ |
5 * | |
6 * Copyright QtD Team, 2008-2009 | |
7 * Distributed under the Boost Software License, Version 1.0. | |
8 * (See accompanying file boost-license-1.0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 * | |
10 */ | |
11 | 5 |
12 module qtd.ArrayOpsPrimitive; | 6 module qtd.ArrayOpsPrimitive; |
13 | 7 import qtd.Core; |
14 import qt.QGlobal; | |
15 | 8 |
16 // int | 9 // int |
17 private extern(C) void qtd_allocate_int_array(int[]* arr, size_t len) | 10 mixin (qtdExport("void", "allocate_int_array", "int[]* arr, size_t len", |
18 { | 11 q{ |
19 *arr = new int[len]; | 12 *arr = new int[len]; |
20 } | 13 })); |
21 | 14 |
22 private extern(C) void qtd_assign_int_array_element(int[]* arr, size_t pos, int elem) | 15 mixin (qtdExport("void", "assign_int_array_element", "int[]* arr, size_t pos, int elem", |
23 { | 16 q{ |
24 (*arr)[pos] = elem; | 17 (*arr)[pos] = elem; |
25 } | 18 })); |
26 | 19 |
27 private extern(C) void qtd_get_int_from_array(int* arr, size_t pos, int* elem) | 20 mixin (qtdExport("void", "get_int_from_array", "int* arr, size_t pos, int* elem", |
28 { | 21 q{ |
29 *elem = arr[pos]; | 22 *elem = arr[pos]; |
30 } | 23 })); |
31 | 24 |
32 // uint | 25 // uint |
33 private extern(C) void qtd_allocate_uint_array(int[]* arr, size_t len) | 26 mixin (qtdExport("void", "allocate_uint_array", "int[]* arr, size_t len", |
34 { | 27 q{ |
35 *arr = new int[len]; | 28 *arr = new int[len]; |
36 } | 29 })); |
37 | 30 |
38 private extern(C) void qtd_assign_uint_array_element(int[]* arr, size_t pos, uint elem) | 31 mixin (qtdExport("void", "assign_uint_array_element", "int[]* arr, size_t pos, uint elem", |
39 { | 32 q{ |
40 (*arr)[pos] = elem; | 33 (*arr)[pos] = elem; |
41 } | 34 })); |
42 | 35 |
43 private extern(C) void qtd_get_uint_from_array(uint* arr, size_t pos, uint* elem) | 36 mixin (qtdExport("void", "get_uint_from_array", "uint* arr, size_t pos, uint* elem", |
44 { | 37 q{ |
45 *elem = arr[pos]; | 38 *elem = arr[pos]; |
46 } | 39 })); |
47 | 40 |
48 // double | 41 // double |
49 private extern(C) void qtd_allocate_double_array(double[]* arr, size_t len) | 42 mixin (qtdExport("void", "allocate_double_array", "double[]* arr, size_t len", |
50 { | 43 q{ |
51 *arr = new double[len]; | 44 *arr = new double[len]; |
52 } | 45 })); |
53 | 46 |
54 private extern(C) void qtd_assign_double_array_element(double[]* arr, size_t pos, double elem) | 47 mixin (qtdExport("void", "assign_double_array_element", "double[]* arr, size_t pos, double elem", |
55 { | 48 q{ |
56 (*arr)[pos] = elem; | 49 (*arr)[pos] = elem; |
57 } | 50 })); |
58 | 51 |
59 private extern(C) void qtd_get_double_from_array(double* arr, size_t pos, double* elem) | 52 mixin (qtdExport("void", "get_double_from_array", "double* arr, size_t pos, double* elem", |
60 { | 53 q{ |
61 *elem = arr[pos]; | 54 *elem = arr[pos]; |
62 } | 55 })); |
63 | 56 |
64 // string | 57 // string |
65 private extern(C) void qtd_allocate_string_array(string[]* arr, size_t len) | 58 mixin (qtdExport("void", "allocate_string_array", "string[]* arr, size_t len", |
66 { | 59 q{ |
67 *arr = new string[len]; | 60 *arr = new string[len]; |
68 } | 61 })); |
69 | 62 |
70 private extern(C) void qtd_assign_string_array_element(string[]* arr, size_t pos, string* elem) | 63 mixin (qtdExport("void", "assign_string_array_element", "string[]* arr, size_t pos, string* elem", |
71 { | 64 q{ |
72 } | 65 })); |
73 | 66 |
74 private extern(C) void* qtd_string_from_array(string[]* arr, size_t pos) | 67 mixin (qtdExport("void*", "string_from_array", "string[]* arr, size_t pos", |
75 { | 68 q{ |
76 return &((*arr)[pos]); | 69 return &((*arr)[pos]); |
77 } | 70 })); |
78 /* | |
79 private extern(C) void qtd_get_string_from_array(string* arr, size_t pos, char** elem, size_t* elem_size) | |
80 { | |
81 *elem = arr[pos].ptr; | |
82 *elem_size = arr[pos].length; | |
83 } | |
84 */ | |
85 | 71 |
86 private extern(C) void qtd_get_string_from_array(string* arr, size_t pos, string* elem) | 72 mixin (qtdExport("void", "get_string_from_array", "string* arr, size_t pos, string* elem", |
87 { | 73 q{ |
88 *elem = arr[pos]; | 74 *elem = arr[pos]; |
89 } | 75 })); |
90 | 76 |
91 version(cpp_shared) | |
92 { | |
93 extern (C) void qtd_core_ArrayOps_initCallBacks(void* callbacks); | |
94 | |
95 static this() { | |
96 void*[13] callbacks; | |
97 | |
98 callbacks[0] = &qtd_allocate_int_array; | |
99 callbacks[1] = &qtd_assign_int_array_element; | |
100 callbacks[2] = &qtd_get_int_from_array; | |
101 | |
102 callbacks[3] = &qtd_allocate_uint_array; | |
103 callbacks[4] = &qtd_assign_uint_array_element; | |
104 callbacks[5] = &qtd_get_uint_from_array; | |
105 | |
106 callbacks[6] = &qtd_allocate_double_array; | |
107 callbacks[7] = &qtd_assign_double_array_element; | |
108 callbacks[8] = &qtd_get_double_from_array; | |
109 | |
110 callbacks[9] = &qtd_allocate_string_array; | |
111 callbacks[10] = &qtd_assign_string_array_element; | |
112 callbacks[11] = &qtd_string_from_array; | |
113 callbacks[12] = &qtd_get_string_from_array; | |
114 | |
115 qtd_core_ArrayOps_initCallBacks(callbacks.ptr); | |
116 } | |
117 } |