Use new NSString lisp methods
* src/nsfont.m (ns_otf_to_script): (ns_registry_to_script): (ns_get_req_script): Use NSString conversion methods. * src/nsimage.m ([EmacsImage allocInitFromFile:]): Use NSString conversion methods. * src/nsmenu.m (ns_menu_show): Use NSString conversion methods. * src/nsselect.m (symbol_to_nsstring): (ns_string_to_pasteboard_internal): Use NSString conversion methods. * src/nsterm.m (ns_term_init): ([EmacsView initFrameFromEmacs:]): Use NSString conversion methods. * src/nsxwidget.m (nsxwidget_webkit_uri): (nsxwidget_webkit_title): (js_to_lisp): Use NSString conversion methods. (build_string_with_nsstr): Functionality replaced by NSString extensions.
This commit is contained in:
parent
6af31fd71f
commit
747a923b9a
6 changed files with 16 additions and 36 deletions
|
@ -329,7 +329,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
{
|
||||
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)))]
|
||||
: @"";
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
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);
|
||||
}
|
||||
|
@ -370,8 +370,7 @@ seems to be limited for now (2009/05) to ja, zh, and ko. */
|
|||
{
|
||||
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)))
|
||||
|
|
|
@ -262,7 +262,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file
|
|||
found = ENCODE_FILE (found);
|
||||
|
||||
image = [[EmacsImage alloc] initByReferencingFile:
|
||||
[NSString stringWithUTF8String: SSDATA (found)]];
|
||||
[NSString stringWithLispString: found]];
|
||||
|
||||
image->bmRep = nil;
|
||||
#ifdef NS_IMPL_COCOA
|
||||
|
@ -278,7 +278,7 @@ + (instancetype)allocInitFromFile: (Lisp_Object)file
|
|||
|
||||
[image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
|
||||
|
||||
[image setName: [NSString stringWithUTF8String: SSDATA (file)]];
|
||||
[image setName: [NSString stringWithLispString: file]];
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -970,7 +970,7 @@ - (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -58,7 +58,7 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
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 *
|
||||
|
@ -170,17 +170,12 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
}
|
||||
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)
|
||||
{
|
||||
|
@ -196,7 +191,6 @@ Updated by Christian Limpach (chris@nice.ch)
|
|||
eassert (gtype == NSPasteboardTypeString);
|
||||
[pb setString: nsStr forType: gtype];
|
||||
}
|
||||
[nsStr release];
|
||||
ns_store_pb_change_count (pb);
|
||||
}
|
||||
}
|
||||
|
|
10
src/nsterm.m
10
src/nsterm.m
|
@ -5541,9 +5541,8 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
|
|||
/* 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")));
|
||||
|
@ -5556,14 +5555,14 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
|
|||
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. */
|
||||
|
@ -7619,8 +7618,7 @@ - (instancetype) initFrameFromEmacs: (struct frame *)f
|
|||
[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 */
|
||||
|
|
|
@ -296,8 +296,6 @@ - (void)userContentController:(WKUserContentController *)userContentController
|
|||
|
||||
/* Xwidget webkit commands. */
|
||||
|
||||
static Lisp_Object build_string_with_nsstr (NSString *nsstr);
|
||||
|
||||
bool
|
||||
nsxwidget_is_web_view (struct xwidget *xw)
|
||||
{
|
||||
|
@ -309,14 +307,14 @@ - (void)userContentController:(WKUserContentController *)userContentController
|
|||
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
|
||||
|
@ -350,15 +348,6 @@ - (void)userContentController:(WKUserContentController *)userContentController
|
|||
/* 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
|
||||
|
@ -367,7 +356,7 @@ - (void)userContentController:(WKUserContentController *)userContentController
|
|||
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;
|
||||
|
@ -407,7 +396,7 @@ - (void)userContentController:(WKUserContentController *)userContentController
|
|||
{
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue