Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
NSString(OOJavaScriptExtensions) Category Reference

#include <OOJavaScriptEngine.h>

Instance Methods

(NSString *) - escapedForJavaScriptLiteral
 
(jsval) - oo_jsValueInContext: [implementation]
 
(NSString *) - oo_jsClassName [implementation]
 

Class Methods

(NSString *) + stringWithJavaScriptParameters:count:inContext:
 
(NSString *) + concatenationOfStringsFromJavaScriptValues:count:separator:inContext:
 

Detailed Description

Definition at line 323 of file OOJavaScriptEngine.h.

Method Documentation

◆ concatenationOfStringsFromJavaScriptValues:count:separator:inContext:

+ (NSString *) concatenationOfStringsFromJavaScriptValues: (jsval *) values
count: (size_t) count
separator: (NSString *) separator
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1796 :(jsval *)values count:(size_t)count separator:(NSString *)separator inContext:(JSContext *)context
1797{
1799
1800 size_t i;
1801 NSMutableString *result = nil;
1802 NSString *element = nil;
1803
1804 if (count < 1) return nil;
1805 if (values == NULL) return NULL;
1806
1807 for (i = 0; i != count; ++i)
1808 {
1809 element = OOStringFromJSValueEvenIfNull(context, values[i]);
1810 if (result == nil) result = [[element mutableCopy] autorelease];
1811 else
1812 {
1813 if (separator != nil) [result appendString:separator];
1814 [result appendString:element];
1815 }
1816 }
1817
1818 return result;
1819
1821}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
NSString * OOStringFromJSValueEvenIfNull(JSContext *context, jsval value)
unsigned count
return nil

References OOJSDumpStack(), OOJSPauseTimeLimiter(), OOJSResumeTimeLimiter(), and OOLog.

+ Here is the call graph for this function:

◆ escapedForJavaScriptLiteral

- (NSString *) escapedForJavaScriptLiteral

Definition at line 622 of file OOJavaScriptEngine.m.

1825{
1827
1828 NSMutableString *result = nil;
1829 NSUInteger i, length;
1830 unichar c;
1831 NSAutoreleasePool *pool = nil;
1832
1833 length = [self length];
1834 result = [NSMutableString stringWithCapacity:length];
1835
1836 // Not hugely efficient.
1837 pool = [[NSAutoreleasePool alloc] init];
1838 for (i = 0; i != length; ++i)
1839 {
1840 c = [self characterAtIndex:i];
1841 switch (c)
1842 {
1843 case '\\':
1844 [result appendString:@"\\\\"];
1845 break;
1846
1847 case '\b':
1848 [result appendString:@"\\b"];
1849 break;
1850
1851 case '\f':
1852 [result appendString:@"\\f"];
1853 break;
1854
1855 case '\n':
1856 [result appendString:@"\\n"];
1857 break;
1858
1859 case '\r':
1860 [result appendString:@"\\r"];
1861 break;
1862
1863 case '\t':
1864 [result appendString:@"\\t"];
1865 break;
1866
1867 case '\v':
1868 [result appendString:@"\\v"];
1869 break;
1870
1871 case '\'':
1872 [result appendString:@"\\\'"];
1873 break;
1874
1875 case '\"':
1876 [result appendString:@"\\\""];
1877 break;
1878
1879 default:
1880 [result appendString:[NSString stringWithCharacters:&c length:1]];
1881 }
1882 }
1883 [pool release];
1884 return result;
1885
1887}

◆ oo_jsClassName

- (NSString *) oo_jsClassName
implementation

Definition at line 622 of file OOJavaScriptEngine.m.

1891{
1892 return @"String";
1893}

◆ oo_jsValueInContext:

- (jsval) oo_jsValueInContext: (JSContext *) context
implementation

Definition at line 622 of file OOJavaScriptEngine.m.

1766 :(JSContext *)context
1767{
1769
1770 size_t length = [self length];
1771 unichar *buffer = NULL;
1772 JSString *string = NULL;
1773
1774 if (length == 0)
1775 {
1776 jsval result = JS_GetEmptyStringValue(context);
1777 return result;
1778 }
1779 else
1780 {
1781 buffer = malloc(length * sizeof *buffer);
1782 if (buffer == NULL) return JSVAL_VOID;
1783
1784 [self getCharacters:buffer];
1785
1786 string = JS_NewUCStringCopyN(context, buffer, length);
1787
1788 free(buffer);
1789 return STRING_TO_JSVAL(string);
1790 }
1791
1793}
#define OOJS_PROFILE_EXIT_JSVAL

◆ stringWithJavaScriptParameters:count:inContext:

+ (NSString *) stringWithJavaScriptParameters: (jsval *) params
count: (uintN) count
inContext: (JSContext *) context 

Definition at line 622 of file OOJavaScriptEngine.m.

1744 :(jsval *)params count:(uintN)count inContext:(JSContext *)context
1745{
1747
1748 if (params == NULL && count != 0) return nil;
1749
1750 uintN i;
1751 NSMutableString *result = [NSMutableString stringWithString:@"("];
1752
1753 for (i = 0; i < count; ++i)
1754 {
1755 if (i != 0) [result appendString:@", "];
1756 [result appendString:OOJSDescribeValue(context, params[i], NO)];
1757 }
1758
1759 [result appendString:@")"];
1760 return result;
1761
1763}

The documentation for this category was generated from the following files: