2626 * still held if needed.
2727 */
2828
29- export CVec ;
30- export CVec , c_vec_with_dtor;
31- export get, set;
32- export len;
33- export ptr;
34-
3529/**
3630 * The type representing a foreign chunk of memory
3731 *
3832 * Wrapped in a enum for opacity; FIXME #818 when it is possible to have
3933 * truly opaque types, this should be revisited.
4034 */
41- enum CVec < T > {
35+ pub enum CVec < T > {
4236 CVecCtor ( { base : * mut T , len : uint , rsrc : @DtorRes } )
4337}
4438
@@ -70,7 +64,7 @@ fn DtorRes(dtor: Option<fn@()>) -> DtorRes {
7064 * * base - A foreign pointer to a buffer
7165 * * len - The number of elements in the buffer
7266 */
73- unsafe fn CVec < T > ( base : * mut T , len : uint ) -> CVec < T > {
67+ pub unsafe fn CVec < T > ( base : * mut T , len : uint ) -> CVec < T > {
7468 return CVecCtor ( {
7569 base: base,
7670 len: len,
@@ -89,7 +83,7 @@ unsafe fn CVec<T>(base: *mut T, len: uint) -> CVec<T> {
8983 * * dtor - A function to run when the value is destructed, useful
9084 * for freeing the buffer, etc.
9185 */
92- unsafe fn c_vec_with_dtor < T > ( base : * mut T , len : uint , dtor : fn @( ) )
86+ pub unsafe fn c_vec_with_dtor < T > ( base : * mut T , len : uint , dtor : fn @( ) )
9387 -> CVec < T > {
9488 return CVecCtor ( {
9589 base: base,
@@ -107,7 +101,7 @@ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@())
107101 *
108102 * Fails if `ofs` is greater or equal to the length of the vector
109103 */
110- fn get < T : Copy > ( t : CVec < T > , ofs : uint ) -> T {
104+ pub fn get < T : Copy > ( t : CVec < T > , ofs : uint ) -> T {
111105 assert ofs < len ( t) ;
112106 return unsafe { * ptr:: mut_offset ( ( * t) . base , ofs) } ;
113107}
@@ -117,7 +111,7 @@ fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T {
117111 *
118112 * Fails if `ofs` is greater or equal to the length of the vector
119113 */
120- fn set < T : Copy > ( t : CVec < T > , ofs : uint , +v : T ) {
114+ pub fn set < T : Copy > ( t : CVec < T > , ofs : uint , +v : T ) {
121115 assert ofs < len ( t) ;
122116 unsafe { * ptr:: mut_offset ( ( * t) . base , ofs) = v } ;
123117}
@@ -127,18 +121,17 @@ fn set<T: Copy>(t: CVec<T>, ofs: uint, +v: T) {
127121 */
128122
129123/// Returns the length of the vector
130- fn len < T > ( t : CVec < T > ) -> uint {
124+ pub fn len < T > ( t : CVec < T > ) -> uint {
131125 return ( * t) . len ;
132126}
133127
134128/// Returns a pointer to the first element of the vector
135- unsafe fn ptr < T > ( t : CVec < T > ) -> * mut T {
129+ pub unsafe fn ptr < T > ( t : CVec < T > ) -> * mut T {
136130 return ( * t) . base ;
137131}
138132
139133#[ cfg( test) ]
140134mod tests {
141- #[ legacy_exports] ;
142135 use libc:: * ;
143136
144137 fn malloc ( n : size_t ) -> CVec < u8 > {
0 commit comments