{
Lisp_Object script = assq_no_quit (XCAR (otf), Votf_script_alist);
return CONSP (script)
- ? [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (XCDR ((script))))]
+ ? [NSString stringWithLispString: SYMBOL_NAME (XCDR ((script)))]
: @"";
}
if (!strncmp (SSDATA (r), reg, SBYTES (r)))
{
script = XCDR (XCAR (rts));
- return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (script))];
+ return [NSString stringWithLispString: SYMBOL_NAME (script)];
}
rts = XCDR (rts);
}
{
Lisp_Object key = XCAR (tmp), val = XCDR (tmp);
if (EQ (key, QCscript) && SYMBOLP (val))
- return [NSString stringWithUTF8String:
- SSDATA (SYMBOL_NAME (val))];
+ return [NSString stringWithLispString: SYMBOL_NAME (val)];
if (EQ (key, QClang) && SYMBOLP (val))
return ns_lang_to_script (val);
if (EQ (key, QCotf) && CONSP (val) && SYMBOLP (XCAR (val)))
found = ENCODE_FILE (found);
image = [[EmacsImage alloc] initByReferencingFile:
- [NSString stringWithUTF8String: SSDATA (found)]];
+ [NSString stringWithLispString: found]];
image->bmRep = nil;
#ifdef NS_IMPL_COCOA
[image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
- [image setName: [NSString stringWithUTF8String: SSDATA (file)]];
+ [image setName: [NSString stringWithLispString: file]];
return image;
}
}
pmenu = [[EmacsMenu alloc] initWithTitle:
- [NSString stringWithUTF8String: SSDATA (title)]];
+ [NSString stringWithLispString: title]];
[pmenu fillWithWidgetValue: first_wv->contents];
free_menubar_widget_value_tree (first_wv);
unbind_to (specpdl_count, Qnil);
if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
if (EQ (sym, QTEXT)) return NSPasteboardTypeString;
- return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))];
+ return [NSString stringWithLispString: SYMBOL_NAME (sym)];
}
static NSPasteboard *
}
else
{
- char *utfStr;
NSString *type, *nsStr;
NSEnumerator *tenum;
CHECK_STRING (str);
- utfStr = SSDATA (str);
- nsStr = [[NSString alloc] initWithBytesNoCopy: utfStr
- length: SBYTES (str)
- encoding: NSUTF8StringEncoding
- freeWhenDone: NO];
+ nsStr = [NSString stringWithLispString: str];
// FIXME: Why those 2 different code paths?
if (gtype == nil)
{
eassert (gtype == NSPasteboardTypeString);
[pb setString: nsStr forType: gtype];
}
- [nsStr release];
ns_store_pb_change_count (pb);
}
}
/* There are 752 colors defined in rgb.txt. */
if ( cl == nil || [[cl allKeys] count] < 752)
{
- Lisp_Object color_file, color_map, color;
+ Lisp_Object color_file, color_map, color, name;
unsigned long c;
- char *name;
color_file = Fexpand_file_name (build_string ("rgb.txt"),
Fsymbol_value (intern ("data-directory")));
for ( ; CONSP (color_map); color_map = XCDR (color_map))
{
color = XCAR (color_map);
- name = SSDATA (XCAR (color));
+ name = XCAR (color);
c = XFIXNUM (XCDR (color));
[cl setColor:
[NSColor colorForEmacsRed: RED_FROM_ULONG (c) / 255.0
green: GREEN_FROM_ULONG (c) / 255.0
blue: BLUE_FROM_ULONG (c) / 255.0
alpha: 1.0]
- forKey: [NSString stringWithUTF8String: name]];
+ forKey: [NSString stringWithLispString: name]];
}
/* FIXME: Report any errors writing the color file below. */
[self registerForDraggedTypes: ns_drag_types];
tem = f->name;
- name = [NSString stringWithUTF8String:
- NILP (tem) ? "Emacs" : SSDATA (tem)];
+ name = NILP (tem) ? @"Emacs" : [NSString stringWithLispString:tem];
[win setTitle: name];
/* toolbar support */
/* Xwidget webkit commands. */
-static Lisp_Object build_string_with_nsstr (NSString *nsstr);
-
bool
nsxwidget_is_web_view (struct xwidget *xw)
{
nsxwidget_webkit_uri (struct xwidget *xw)
{
XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
- return build_string_with_nsstr (xwWebView.URL.absoluteString);
+ return [xwWebView.URL.absoluteString lispString];
}
Lisp_Object
nsxwidget_webkit_title (struct xwidget *xw)
{
XwWebView *xwWebView = (XwWebView *) xw->xwWidget;
- return build_string_with_nsstr (xwWebView.title);
+ return [xwWebView.title lispString];
}
/* @Note ATS - Need application transport security in 'Info.plist' or
/* TODO: setMagnification:centeredAtPoint. */
}
-/* Build lisp string */
-static Lisp_Object
-build_string_with_nsstr (NSString *nsstr)
-{
- const char *utfstr = [nsstr UTF8String];
- NSUInteger bytes = [nsstr lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
- return make_string (utfstr, bytes);
-}
-
/* Recursively convert an objc native type JavaScript value to a Lisp
value. Mostly copied from GTK xwidget 'webkit_js_to_lisp'. */
static Lisp_Object
if (value == nil || [value isKindOfClass:NSNull.class])
return Qnil;
else if ([value isKindOfClass:NSString.class])
- return build_string_with_nsstr ((NSString *) value);
+ return [(NSString *) value lispString];
else if ([value isKindOfClass:NSNumber.class])
{
NSNumber *nsnum = (NSNumber *) value;
{
NSString *prop_key = (NSString *) [keys objectAtIndex:i];
id prop_value = [nsdict valueForKey:prop_key];
- p->contents[i] = Fcons (build_string_with_nsstr (prop_key),
+ p->contents[i] = Fcons ([prop_key lispString],
js_to_lisp (prop_value));
}
XSETVECTOR (obj, p);