Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 6f609db

Browse files
committed
Rename V8\Exception class and it methods, closes #33
1 parent 508934e commit 6f609db

19 files changed

+88
-87
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ acinclude.m4
1313
aclocal.m4
1414
autom4te.cache
1515
build
16+
confdefs.h
1617
config.guess
1718
config.h
1819
config.h.in

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ if test "$PHP_V8" != "no"; then
161161
v8.cc \
162162
src/php_v8_a.cc \
163163
src/php_v8_enums.cc \
164-
src/php_v8_exception.cc \
164+
src/php_v8_exception_manager.cc \
165165
src/php_v8_ext_mem_interface.cc \
166166
src/php_v8_try_catch.cc \
167167
src/php_v8_message.cc \

package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<file name="src/php_v8_enums.cc" role="src" />
7272
<file name="src/php_v8_enums.h" role="src" />
7373
<file name="src/php_v8_exception.cc" role="src" />
74-
<file name="src/php_v8_exception.h" role="src" />
74+
<file name="src/php_v8_exception_manager.h" role="src" />
7575
<file name="src/php_v8_exceptions.cc" role="src" />
7676
<file name="src/php_v8_exceptions.h" role="src" />
7777
<file name="src/php_v8_ext_mem_interface.cc" role="src" />

src/php_v8_exception.cc src/php_v8_exception_manager.cc

+26-26
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
#include "config.h"
1515
#endif
1616

17-
#include "php_v8_exception.h"
17+
#include "php_v8_exception_manager.h"
1818
#include "php_v8_stack_trace.h"
1919
#include "php_v8_message.h"
2020
#include "php_v8_string.h"
2121
#include "php_v8_value.h"
2222
#include "php_v8_isolate.h"
2323
#include "php_v8.h"
2424

25-
zend_class_entry *php_v8_exception_class_entry;
26-
#define this_ce php_v8_exception_class_entry
25+
zend_class_entry *php_v8_exception_manager_class_entry;
26+
#define this_ce php_v8_exception_manager_class_entry
2727

2828

29-
static PHP_METHOD(Exception, rangeError) {
29+
static PHP_METHOD(ExceptionManager, createRangeError) {
3030
zval *php_v8_message_zv;
3131
zval *php_v8_context_zv;
3232

@@ -49,7 +49,7 @@ static PHP_METHOD(Exception, rangeError) {
4949
php_v8_create_value(return_value, local_value, php_v8_context->php_v8_isolate);
5050
}
5151

52-
static PHP_METHOD(Exception, referenceError) {
52+
static PHP_METHOD(ExceptionManager, createReferenceError) {
5353
zval *php_v8_message_zv;
5454
zval *php_v8_context_zv;
5555

@@ -72,7 +72,7 @@ static PHP_METHOD(Exception, referenceError) {
7272
php_v8_create_value(return_value, local_value, php_v8_context->php_v8_isolate);
7373
}
7474

75-
static PHP_METHOD(Exception, syntaxError) {
75+
static PHP_METHOD(ExceptionManager, createSyntaxError) {
7676
zval *php_v8_message_zv;
7777
zval *php_v8_context_zv;
7878

@@ -95,7 +95,7 @@ static PHP_METHOD(Exception, syntaxError) {
9595
php_v8_create_value(return_value, local_value, php_v8_context->php_v8_isolate);
9696
}
9797

98-
static PHP_METHOD(Exception, typeError) {
98+
static PHP_METHOD(ExceptionManager, createTypeError) {
9999
zval *php_v8_message_zv;
100100
zval *php_v8_context_zv;
101101

@@ -117,7 +117,7 @@ static PHP_METHOD(Exception, typeError) {
117117
php_v8_create_value(return_value, local_value, php_v8_context->php_v8_isolate);
118118
}
119119

120-
static PHP_METHOD(Exception, error) {
120+
static PHP_METHOD(ExceptionManager, createError) {
121121
zval *php_v8_message_zv;
122122
zval *php_v8_context_zv;
123123

@@ -140,7 +140,7 @@ static PHP_METHOD(Exception, error) {
140140
php_v8_create_value(return_value, local_value, php_v8_context->php_v8_isolate);
141141
}
142142

143-
static PHP_METHOD(Exception, createMessage) {
143+
static PHP_METHOD(ExceptionManager, createMessage) {
144144
zval *php_v8_context_zv;
145145
zval *php_v8_exception_zv;
146146

@@ -163,7 +163,7 @@ static PHP_METHOD(Exception, createMessage) {
163163
php_v8_message_create_from_message(return_value, php_v8_context->php_v8_isolate, local_message);
164164
}
165165

166-
static PHP_METHOD(Exception, getStackTrace) {
166+
static PHP_METHOD(ExceptionManager, getStackTrace) {
167167
zval *php_v8_exception_zv;
168168
zval *php_v8_context_zv;
169169

@@ -191,27 +191,27 @@ static PHP_METHOD(Exception, getStackTrace) {
191191
}
192192

193193

194-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_rangeError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
194+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_createRangeError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
195195
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
196196
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
197197
ZEND_END_ARG_INFO()
198198

199-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_referenceError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
199+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_createReferenceError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
200200
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
201201
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
202202
ZEND_END_ARG_INFO()
203203

204-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_syntaxError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
204+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_createSyntaxError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
205205
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
206206
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
207207
ZEND_END_ARG_INFO()
208208

209-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_typeError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
209+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_createTypeError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
210210
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
211211
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
212212
ZEND_END_ARG_INFO()
213213

214-
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_error, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
214+
PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_createError, ZEND_RETURN_VALUE, 2, V8\\ObjectValue, 0)
215215
ZEND_ARG_OBJ_INFO(0, context, V8\\Context, 0)
216216
ZEND_ARG_OBJ_INFO(0, message, V8\\StringValue, 0)
217217
ZEND_END_ARG_INFO()
@@ -226,22 +226,22 @@ PHP_V8_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_getStackTrace, ZEND_RETURN
226226
ZEND_ARG_OBJ_INFO(0, exception, V8\\Value, 0)
227227
ZEND_END_ARG_INFO()
228228

229-
static const zend_function_entry php_v8_exception_methods[] = {
230-
PHP_V8_ME(Exception, rangeError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
231-
PHP_V8_ME(Exception, referenceError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
232-
PHP_V8_ME(Exception, syntaxError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
233-
PHP_V8_ME(Exception, typeError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
234-
PHP_V8_ME(Exception, error, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
235-
PHP_V8_ME(Exception, createMessage, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
236-
PHP_V8_ME(Exception, getStackTrace, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
229+
static const zend_function_entry php_v8_exception_manger_methods[] = {
230+
PHP_V8_ME(ExceptionManager, createRangeError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
231+
PHP_V8_ME(ExceptionManager, createReferenceError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
232+
PHP_V8_ME(ExceptionManager, createSyntaxError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
233+
PHP_V8_ME(ExceptionManager, createTypeError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
234+
PHP_V8_ME(ExceptionManager, createError, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
235+
PHP_V8_ME(ExceptionManager, createMessage, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
236+
PHP_V8_ME(ExceptionManager, getStackTrace, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC)
237237

238238
PHP_FE_END
239239
};
240240

241-
PHP_MINIT_FUNCTION(php_v8_exception) {
241+
PHP_MINIT_FUNCTION(php_v8_exception_manger) {
242242
zend_class_entry ce;
243-
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "Exception", php_v8_exception_methods);
244-
this_ce = zend_register_internal_class_ex(&ce, php_v8_value_class_entry);
243+
INIT_NS_CLASS_ENTRY(ce, PHP_V8_NS, "ExceptionManager", php_v8_exception_manger_methods);
244+
this_ce = zend_register_internal_class(&ce);
245245

246246
return SUCCESS;
247247
}

src/php_v8_exception.h src/php_v8_exception_manager.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
* http://opensource.org/licenses/MIT
1111
*/
1212

13-
#ifndef PHP_V8_EXCEPTION_H
14-
#define PHP_V8_EXCEPTION_H
13+
#ifndef PHP_V8_EXCEPTION_MANGER_H
14+
#define PHP_V8_EXCEPTION_MANGER_H
1515

1616
extern "C" {
1717
#include "php.h"
@@ -21,9 +21,9 @@ extern "C" {
2121
#endif
2222
}
2323

24-
extern zend_class_entry* php_v8_exception_class_entry;
24+
extern zend_class_entry* php_v8_exception_manager_class_entry;
2525

2626

27-
PHP_MINIT_FUNCTION(php_v8_exception);
27+
PHP_MINIT_FUNCTION(php_v8_exception_manger);
2828

29-
#endif //PHP_V8_EXCEPTION_H
29+
#endif //PHP_V8_EXCEPTION_MANGER_H

src/php_v8_script.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
typedef struct _php_v8_script_t php_v8_script_t;
1717

18-
#include "php_v8_exception.h"
18+
#include "php_v8_exception_manager.h"
1919
#include "php_v8_context.h"
2020
#include "php_v8_isolate.h"
2121
#include <v8.h>

src/php_v8_source.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#define PHP_V8_SOURCE_H
1515

1616

17-
#include "php_v8_exception.h"
17+
#include "php_v8_exception_manager.h"
1818
#include "php_v8_context.h"
1919
#include "php_v8_isolate.h"
2020
#include <v8.h>

src/php_v8_unbound_script.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
typedef struct _php_v8_unbound_script_t php_v8_unbound_script_t;
1717

18-
#include "php_v8_exception.h"
18+
#include "php_v8_exception_manager.h"
1919
#include "php_v8_isolate.h"
2020
#include <v8.h>
2121

stubs/src/Exception.php stubs/src/ExceptionManager.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@
2020
* Create new error objects by calling the corresponding error object
2121
* constructor with the message.
2222
*/
23-
class Exception
23+
class ExceptionManager
2424
{
2525
/**
2626
* @param Context $context
2727
* @param \V8\StringValue $message
2828
*
2929
* @return \V8\ObjectValue
3030
*/
31-
public static function rangeError(Context $context, StringValue $message): ObjectValue
31+
public static function createRangeError(Context $context, StringValue $message): ObjectValue
3232
{
3333
}
3434

@@ -38,7 +38,7 @@ public static function rangeError(Context $context, StringValue $message): Objec
3838
*
3939
* @return \V8\ObjectValue
4040
*/
41-
public static function referenceError(Context $context, StringValue $message): ObjectValue
41+
public static function createReferenceError(Context $context, StringValue $message): ObjectValue
4242
{
4343
}
4444

@@ -48,7 +48,7 @@ public static function referenceError(Context $context, StringValue $message): O
4848
*
4949
* @return \V8\ObjectValue
5050
*/
51-
public static function syntaxError(Context $context, StringValue $message): ObjectValue
51+
public static function createSyntaxError(Context $context, StringValue $message): ObjectValue
5252
{
5353
}
5454

@@ -58,7 +58,7 @@ public static function syntaxError(Context $context, StringValue $message): Obje
5858
*
5959
* @return \V8\ObjectValue
6060
*/
61-
public static function typeError(Context $context, StringValue $message): ObjectValue
61+
public static function createTypeError(Context $context, StringValue $message): ObjectValue
6262
{
6363
}
6464

@@ -68,7 +68,7 @@ public static function typeError(Context $context, StringValue $message): Object
6868
*
6969
* @return ObjectValue
7070
*/
71-
public static function error(Context $context, StringValue $message): ObjectValue
71+
public static function createError(Context $context, StringValue $message): ObjectValue
7272
{
7373
}
7474

@@ -82,7 +82,7 @@ public static function error(Context $context, StringValue $message): ObjectValu
8282
*
8383
* @return Message
8484
*/
85-
static function createMessage(Context $context, Value $exception): Message
85+
public static function createMessage(Context $context, Value $exception): Message
8686
{
8787
}
8888

tests/001-verify_extension_entities.phpt

+6-6
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,12 @@ final class V8\ScriptCompiler\CompileOptions
408408
const PRODUCE_CODE_CACHE = 3
409409
const CONSUME_CODE_CACHE = 4
410410

411-
class V8\Exception
412-
public static function rangeError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
413-
public static function referenceError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
414-
public static function syntaxError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
415-
public static function typeError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
416-
public static function error(V8\Context $context, V8\StringValue $message): V8\ObjectValue
411+
class V8\ExceptionManager
412+
public static function createRangeError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
413+
public static function createReferenceError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
414+
public static function createSyntaxError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
415+
public static function createTypeError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
416+
public static function createError(V8\Context $context, V8\StringValue $message): V8\ObjectValue
417417
public static function createMessage(V8\Context $context, V8\Value $exception): V8\Message
418418
public static function getStackTrace(V8\Context $context, V8\Value $exception): ?V8\StackTrace
419419

tests/Exception_createMessage.phpt tests/ExceptionManager_createCreateMessage.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
V8\Exception::createMessage()
2+
V8\ExceptionManager::createCreateMessage()
33
--SKIPIF--
44
<?php if (!extension_loaded("v8")) print "skip"; ?>
55
--FILE--
@@ -13,7 +13,7 @@ $isolate = new \V8\Isolate();
1313
$context = new \V8\Context($isolate);
1414

1515
try {
16-
$message = V8\Exception::createMessage($context, new \V8\StringValue($isolate, 'test'));
16+
$message = V8\ExceptionManager::createMessage($context, new \V8\StringValue($isolate, 'test'));
1717
$helper->assert('Can create message when out of context', $message instanceof \V8\Message);
1818
} catch (\Exception $e) {
1919
$helper->exception_export($e);
@@ -29,13 +29,13 @@ $func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallba
2929

3030
$exception = $info->arguments()[0];
3131

32-
$message = V8\Exception::createMessage($info->getContext(), $exception);
32+
$message = V8\ExceptionManager::createMessage($info->getContext(), $exception);
3333
$helper->header('Message created from thrown value');
3434
$helper->dump_object_methods($message);
3535
$helper->line();
3636

3737
$exception = new \V8\StringValue($info->getIsolate(), 'test');
38-
$message = V8\Exception::createMessage($info->getContext(), $exception);
38+
$message = V8\ExceptionManager::createMessage($info->getContext(), $exception);
3939
$helper->header('Message created from created value');
4040
$helper->dump_object_methods($message);
4141
$helper->line();

tests/Exception_error.phpt tests/ExceptionManager_createError.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
V8\Exception::error()
2+
V8\ExceptionManager::createError()
33
--SKIPIF--
44
<?php if (!extension_loaded("v8")) print "skip"; ?>
55
--FILE--
@@ -13,7 +13,7 @@ $isolate = new \V8\Isolate();
1313
$context = new \V8\Context($isolate);
1414

1515
try {
16-
$error = V8\Exception::error($context, new \V8\StringValue($isolate, 'test'));
16+
$error = V8\ExceptionManager::createError($context, new \V8\StringValue($isolate, 'test'));
1717
$helper->assert('Can create error when out of context', $error instanceof \V8\Value);
1818
} catch (\Exception $e) {
1919
$helper->exception_export($e);
@@ -24,14 +24,14 @@ $helper->line();
2424
$func_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) {
2525
$value = count($info->arguments()) ? $info->arguments()[0] : new \V8\StringValue($info->getIsolate(), "exception");
2626

27-
$info->getIsolate()->throwException($info->getContext(), V8\Exception::error($info->getContext(), $value));
27+
$info->getIsolate()->throwException($info->getContext(), V8\ExceptionManager::createError($info->getContext(), $value));
2828
});
2929

3030
$func_test_tpl = new \V8\FunctionTemplate($isolate, function (\V8\FunctionCallbackInfo $info) use ($helper, $v8_helper) {
3131

3232
$message = new \V8\StringValue($info->getIsolate(), "test");
33-
$value1 = V8\Exception::error($info->getContext(), $message);
34-
$value2 = V8\Exception::error($info->getContext(), $message);
33+
$value1 = V8\ExceptionManager::createError($info->getContext(), $message);
34+
$value2 = V8\ExceptionManager::createError($info->getContext(), $message);
3535

3636
$context = $info->getContext();
3737

0 commit comments

Comments
 (0)