]> err.no Git - sope/blob - Recycler/NGJavaScript/NGJavaScriptFunction.m
necessary changes
[sope] / Recycler / NGJavaScript / NGJavaScriptFunction.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "NGJavaScriptFunction.h"
24 #include "NGJavaScriptContext.h"
25 #include "NGJavaScriptObject.h"
26 #include "NGJavaScriptObjectMappingContext.h"
27 #include "NSString+JS.h"
28 #include "common.h"
29
30 @implementation NGJavaScriptFunction
31
32 /* accessors */
33
34 - (NSString *)functionName {
35   return [NSString stringWithCString:JS_GetFunctionName(self->handle)];
36 }
37
38 /* typing */
39
40 - (BOOL)isJavaScriptFunction {
41   return YES;
42 }
43 - (BOOL)isScriptFunction {
44   return YES;
45 }
46
47 /* compilation */
48
49 - (NSString *)decompileBodyWithIndent:(unsigned)_indent
50   inContext:(NGJavaScriptContext *)_ctx
51 {
52   JSString *s;
53
54   s = JS_DecompileFunctionBody([_ctx handle], self->handle, _indent);
55   return [NSString stringWithJavaScriptString:s];
56 }
57
58 - (NSString *)decompileWithIndent:(unsigned)_indent
59   inContext:(NGJavaScriptContext *)_ctx
60 {
61   JSString *s;
62
63   s = JS_DecompileFunction([_ctx handle], self->handle, _indent);
64   return [NSString stringWithJavaScriptString:s];
65 }
66
67 /* NSCoding */
68
69 - (id)initWithCoder:(NSCoder *)_coder {
70   NSAssert(NO, @"decoding of functions not supported yet ...");
71   return nil;
72 }
73 - (void)encodeWithCoder:(NSCoder *)_coder {
74   NSAssert(NO, @"encoding of functions not supported yet ...");
75 }
76
77 @end /* NGJavaScriptFunction */
78
79 @implementation NSObject(JSFuncTyping)
80
81 - (BOOL)isJavaScriptFunction {
82   return NO;
83 }
84
85 @end /* NSObject(JSFuncTyping) */