File: OOLegacyScriptToJavaScriptConverter.h

package info (click to toggle)
oolite 1.77.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 41,264 kB
  • ctags: 5,362
  • sloc: objc: 132,090; ansic: 10,457; python: 2,225; sh: 1,325; makefile: 332; perl: 259; xml: 125; php: 5
file content (60 lines) | stat: -rw-r--r-- 1,746 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
//  OOLegacyScriptToJavaScriptConverter.h
//  ScriptConverter
//
//  Created by Jens Ayton on 2007-11-24.
//  Copyright 2007 Jens Ayton. All rights reserved.
//

#import "OOCocoa.h"
#import "OOProblemReportManager.h"


extern NSString * const kOOScriptMetadataKeyName;
extern NSString * const kOOScriptMetadataKeyAuthor;
extern NSString * const kOOScriptMetadataKeyCopyright;
extern NSString * const kOOScriptMetadataKeyDescription;
extern NSString * const kOOScriptMetadataKeyVersion;
extern NSString * const kOOScriptMetadataKeyLicense;


@interface OOLegacyScriptToJavaScriptConverter: NSObject
{
	NSDictionary				*_metadata;
	id <OOProblemReportManager>	_problemReporter;
	unsigned					_indent;
	NSMutableString				*_result;
	NSMutableDictionary			*_legalizedVariableNames;
	NSMutableSet				*_usedLocalVariableNames;
	OOUInteger					_lastVariableUniqueTag;
	NSMutableDictionary			*_initializers;
	NSMutableDictionary			*_helperFunctions;
	OOUInteger					_initializerLocation;
	BOOL						_EOL;
	BOOL						_secondaryIndent;
	BOOL						_validConversion;
}

+ (NSString *) convertScript:(NSArray *)scriptActions
					metadata:(NSDictionary *)metadata
			 problemReporter:(id <OOProblemReportManager>)problemReporter;

+ (NSDictionary *) convertMultipleScripts:(NSDictionary *)scripts
								 metadata:(NSDictionary *)metadata
						  problemReporter:(id <OOProblemReportManager>)problemReporter;

@end


@interface NSString (OOScriptConverterUtilities)

// Add escape codes for string so that it's a valid JavaScript literal (if you put "" or '' around it).
- (NSString *)escapedForJavaScriptLiteral;

// Remove occurances of */
- (NSString *)escapedForJavaScriptBlockComment;

@end


BOOL OOScriptConverterIsNumberLiteral(NSString *string);