+ return string;
+}
+
+// XXX: this is not a safe handle
+class CYString {
+ private:
+ JSStringRef string_;
+
+ public:
+ template <typename Arg0_>
+ CYString(Arg0_ arg0) {
+ string_ = CYCopyJSString(arg0);
+ }
+
+ template <typename Arg0_, typename Arg1_>
+ CYString(Arg0_ arg0, Arg1_ arg1) {
+ string_ = CYCopyJSString(arg0, arg1);
+ }
+
+ ~CYString() {
+ JSStringRelease(string_);
+ }
+
+ operator JSStringRef() const {
+ return string_;
+ }
+};
+
+CFStringRef CYCopyCFString(JSStringRef value) {
+ return JSStringCopyCFString(kCFAllocatorDefault, value);
+}
+
+CFStringRef CYCopyCFString(JSContextRef context, JSValueRef value) {
+ return CYCopyCFString(CYString(context, value));