1
1
/*
2
2
* Copyright (C) 2011 Keijiro Takahashi
3
3
* Copyright (C) 2012 GREE, Inc.
4
- *
4
+ *
5
5
* This software is provided 'as-is', without any express or implied
6
6
* warranty. In no event will the authors be held liable for any damages
7
7
* arising from the use of this software.
8
- *
8
+ *
9
9
* Permission is granted to anyone to use this software for any purpose,
10
10
* including commercial applications, and to alter it and redistribute it
11
11
* freely, subject to the following restrictions:
12
- *
12
+ *
13
13
* 1. The origin of this software must not be misrepresented; you must not
14
14
* claim that you wrote the original software. If you use this software
15
15
* in a product, an acknowledgment in the product documentation would be
34
34
typedef void *MonoMethod;
35
35
typedef void *MonoString;
36
36
37
+ #ifdef __cplusplus
37
38
extern " C" {
39
+ #endif
38
40
MonoDomain *mono_domain_get ();
39
- MonoAssembly *mono_domain_assembly_open (
40
- MonoDomain *domain, const char *assemblyName);
41
+ MonoAssembly *mono_domain_assembly_open (MonoDomain *domain, const char *assemblyName);
41
42
MonoImage *mono_assembly_get_image (MonoAssembly *assembly);
42
- MonoMethodDesc *mono_method_desc_new (
43
- const char *methodString, int useNamespace);
43
+ MonoMethodDesc *mono_method_desc_new (const char *methodString, int useNamespace);
44
44
MonoMethodDesc *mono_method_desc_free (MonoMethodDesc *desc);
45
- MonoMethod *mono_method_desc_search_in_image (
46
- MonoMethodDesc *methodDesc, MonoImage *image);
47
- MonoObject *mono_runtime_invoke (
48
- MonoMethod *method, void *obj, void **params, MonoObject **exc);
45
+ MonoMethod *mono_method_desc_search_in_image (MonoMethodDesc *methodDesc, MonoImage *image);
46
+ MonoObject *mono_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObject **exc);
49
47
MonoString *mono_string_new (MonoDomain *domain, const char *text);
48
+ #ifdef __cplusplus
50
49
}
50
+ #endif
51
51
52
52
static BOOL inEditor;
53
53
static MonoDomain *monoDomain;
@@ -73,16 +73,16 @@ static void UnitySendMessage(
73
73
monoDomain = mono_domain_get ();
74
74
monoDesc = mono_method_desc_new (
75
75
" UnitySendMessageDispatcher:Dispatch(string,string,string)" , FALSE );
76
-
76
+
77
77
monoAssembly =
78
78
mono_domain_assembly_open (monoDomain, [assemblyPath UTF8String ]);
79
79
80
80
if (monoAssembly != 0 ) {
81
81
monoImage = mono_assembly_get_image (monoAssembly);
82
82
monoMethod = mono_method_desc_search_in_image (monoDesc, monoImage);
83
83
}
84
-
85
-
84
+
85
+
86
86
if (monoMethod == 0 ) {
87
87
if (inEditor) {
88
88
assemblyPath =
@@ -102,11 +102,11 @@ static void UnitySendMessage(
102
102
}
103
103
}
104
104
}
105
-
105
+
106
106
if (monoMethod == 0 ) {
107
107
return ;
108
108
}
109
-
109
+
110
110
void *args[] = {
111
111
mono_string_new (monoDomain, gameObject),
112
112
mono_string_new (monoDomain, method),
@@ -196,7 +196,7 @@ - (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary
196
196
} else {
197
197
if ([customRequestHeader count ] > 0 ) {
198
198
bool isCustomized = YES ;
199
-
199
+
200
200
// Check for additional custom header.
201
201
for (NSString *key in [customRequestHeader allKeys ])
202
202
{
@@ -213,7 +213,7 @@ - (void)webView:(WebView *)sender decidePolicyForNavigationAction:(NSDictionary
213
213
return ;
214
214
}
215
215
}
216
-
216
+
217
217
[listener use ];
218
218
}
219
219
}
@@ -321,20 +321,20 @@ - (void)update:(int)x y:(int)y deltaY:(float)deltaY buttonDown:(BOOL)buttonDown
321
321
event = [NSEvent mouseEventWithType: NSLeftMouseDown
322
322
location: NSMakePoint (x, y) modifierFlags: nil
323
323
timestamp: GetCurrentEventTime () windowNumber: 0
324
- context: context eventNumber: nil clickCount: 1 pressure: nil ];
324
+ context: context eventNumber: nil clickCount: 1 pressure: 1 ];
325
325
[view mouseDown: event];
326
326
} else {
327
327
event = [NSEvent mouseEventWithType: NSLeftMouseDragged
328
328
location: NSMakePoint (x, y) modifierFlags: nil
329
329
timestamp: GetCurrentEventTime () windowNumber: 0
330
- context: context eventNumber: nil clickCount: 0 pressure: nil ];
330
+ context: context eventNumber: nil clickCount: 0 pressure: 1 ];
331
331
[view mouseDragged: event];
332
332
}
333
333
} else if (buttonRelease) {
334
334
event = [NSEvent mouseEventWithType: NSLeftMouseUp
335
335
location: NSMakePoint (x, y) modifierFlags: nil
336
336
timestamp: GetCurrentEventTime () windowNumber: 0
337
- context: context eventNumber: nil clickCount: 0 pressure: nil ];
337
+ context: context eventNumber: nil clickCount: 0 pressure: 0 ];
338
338
[view mouseUp: event];
339
339
}
340
340
@@ -452,7 +452,7 @@ - (const char *)getCustomRequestHeaderValue:(const char *)headerKey
452
452
if (!result) {
453
453
return NULL ;
454
454
}
455
-
455
+
456
456
const char *s = [result UTF8String ];
457
457
char *r = (char *)malloc (strlen (s) + 1 );
458
458
strcpy (r, s);
@@ -462,7 +462,9 @@ - (const char *)getCustomRequestHeaderValue:(const char *)headerKey
462
462
@end
463
463
464
464
typedef void (*UnityRenderEventFunc)(int eventId);
465
+ #ifdef __cplusplus
465
466
extern " C" {
467
+ #endif
466
468
const char *_CWebViewPlugin_GetAppPath ();
467
469
void *_CWebViewPlugin_Init (
468
470
const char *gameObject, BOOL transparent, int width, int height, const char *ua, BOOL ineditor);
@@ -489,7 +491,9 @@ void _CWebViewPlugin_Update(void *instance, int x, int y, float deltaY,
489
491
void _CWebViewPlugin_RemoveCustomHeader (void *instance, const char *headerKey);
490
492
void _CWebViewPlugin_ClearCustomHeader (void *instance);
491
493
const char *_CWebViewPlugin_GetCustomHeaderValue (void *instance, const char *headerKey);
494
+ #ifdef __cplusplus
492
495
}
496
+ #endif
493
497
494
498
const char *_CWebViewPlugin_GetAppPath ()
495
499
{
0 commit comments