OLD | NEW |
1 #include "runtime.h" | 1 #include "runtime.h" |
2 #include "../intrusive_ptr.h" | 2 #include "../intrusive_ptr.h" |
3 #include "../String.h" | 3 #include "../String.h" |
4 | 4 |
5 extern "C" | 5 extern "C" |
6 { | 6 { |
7 void BINDINGS_EXPORTED InitString(DependentString* str, | 7 void BINDINGS_EXPORTED InitString(DependentString* str, |
8 String::value_type* data, String::size_type len) | 8 String::value_type* data, String::size_type len) |
9 { | 9 { |
10 // String is already allocated on stack, we merely need to call | 10 // String is already allocated on stack, we merely need to call |
11 // constructor. | 11 // constructor. |
12 new (str) DependentString(data, len); | 12 new (str) DependentString(data, len); |
13 } | 13 } |
14 | 14 |
| 15 void BINDINGS_EXPORTED InitOwnedString(OwnedString* str) |
| 16 { |
| 17 // String is already allocated on stack, we merely need to call |
| 18 // constructor. |
| 19 new (str) OwnedString(); |
| 20 } |
| 21 |
15 void BINDINGS_EXPORTED DestroyString(OwnedString* str) | 22 void BINDINGS_EXPORTED DestroyString(OwnedString* str) |
16 { | 23 { |
17 // Stack memory will be freed automatically, we need to call | 24 // Stack memory will be freed automatically, we need to call |
18 // destructor explicitly however. | 25 // destructor explicitly however. |
19 str->~OwnedString(); | 26 str->~OwnedString(); |
20 } | 27 } |
21 | 28 |
22 String::size_type BINDINGS_EXPORTED GetStringLength( | 29 String::size_type BINDINGS_EXPORTED GetStringLength( |
23 const String& str) | 30 const String& str) |
24 { | 31 { |
25 return str.length(); | 32 return str.length(); |
26 } | 33 } |
27 | 34 |
28 const String::value_type* BINDINGS_EXPORTED GetStringData( | 35 const String::value_type* BINDINGS_EXPORTED GetStringData( |
29 const String& str) | 36 const String& str) |
30 { | 37 { |
31 return str.data(); | 38 return str.data(); |
32 } | 39 } |
33 | 40 |
34 void BINDINGS_EXPORTED ReleaseRef(ref_counted* ptr) | 41 void BINDINGS_EXPORTED ReleaseRef(ref_counted* ptr) |
35 { | 42 { |
36 ptr->ReleaseRef(); | 43 ptr->ReleaseRef(); |
37 } | 44 } |
38 } | 45 } |
OLD | NEW |