Implement UConverter::getStandardName()
Making ucnv_getStandardName() available as UConverter::getStandardName().
Esse commit está contido em:
@@ -633,4 +633,47 @@ DefineFunction(
|
||||
)
|
||||
);
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "getStandardName",
|
||||
'desc' => "Returns a standard name for a given converter name.",
|
||||
'flags' => HasDocComment|IsStatic,
|
||||
'return' => array(
|
||||
'type' => String,
|
||||
'desc' => "Standard name of converter",
|
||||
),
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "name",
|
||||
'type' => String,
|
||||
'desc' => "Original converter name",
|
||||
),
|
||||
array(
|
||||
'name' => "standard",
|
||||
'type' => String,
|
||||
'desc' => "Name of the standard governing the names, e.g. 'MIME' or 'IANA'",
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
DefineFunction(
|
||||
array(
|
||||
'name' => "getMIMEName",
|
||||
'desc' => "Returns the MIME name for a given converter name.",
|
||||
'flags' => HasDocComment|IsStatic,
|
||||
'return' => array(
|
||||
'type' => String,
|
||||
'desc' => "Converter's MIME name",
|
||||
),
|
||||
'args' => array(
|
||||
array(
|
||||
'name' => "name",
|
||||
'type' => String,
|
||||
'desc' => "Original converter name",
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
EndClass();
|
||||
|
||||
@@ -569,5 +569,25 @@ Array c_UConverter::ti_getstandards(const char* cls ) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
String c_UConverter::ti_getstandardname(const char* cls,
|
||||
CStrRef name,
|
||||
CStrRef standard) {
|
||||
UErrorCode error = U_ZERO_ERROR;
|
||||
const char *standard_name = ucnv_getStandardName(name.data(),
|
||||
standard.data(),
|
||||
&error);
|
||||
|
||||
if (U_FAILURE(error)) {
|
||||
THROW_UFAILURE(ucnv_getStandardName, error, s_intl_error->m_error);
|
||||
return uninit_null();
|
||||
}
|
||||
|
||||
return String(standard_name, CopyString);
|
||||
}
|
||||
|
||||
String c_UConverter::ti_getmimename(const char* cls, CStrRef name) {
|
||||
return ti_getstandardname(cls, name, "MIME");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
@@ -995,6 +995,114 @@ TypedValue* tg_10UConverter_getStandards(HPHP::VM::ActRec *ar) {
|
||||
return &ar->m_r;
|
||||
}
|
||||
|
||||
/*
|
||||
HPHP::String HPHP::c_UConverter::ti_getstandardname(char const*, HPHP::String const&, HPHP::String const&)
|
||||
_ZN4HPHP12c_UConverter18ti_getstandardnameEPKcRKNS_6StringES5_
|
||||
|
||||
(return value) => rax
|
||||
_rv => rdi
|
||||
cls_ => rsi
|
||||
name => rdx
|
||||
standard => rcx
|
||||
*/
|
||||
|
||||
Value* th_10UConverter_getStandardName(Value* _rv, char const* cls_, Value* name, Value* standard) asm("_ZN4HPHP12c_UConverter18ti_getstandardnameEPKcRKNS_6StringES5_");
|
||||
|
||||
TypedValue* tg1_10UConverter_getStandardName(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
||||
TypedValue* tg1_10UConverter_getStandardName(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
rv->m_type = KindOfString;
|
||||
if (!IS_STRING_TYPE((args-1)->m_type)) {
|
||||
tvCastToStringInPlace(args-1);
|
||||
}
|
||||
if (!IS_STRING_TYPE((args-0)->m_type)) {
|
||||
tvCastToStringInPlace(args-0);
|
||||
}
|
||||
th_10UConverter_getStandardName((Value*)(rv), ("UConverter"), (Value*)(args-0), (Value*)(args-1));
|
||||
if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
TypedValue* tg_10UConverter_getStandardName(HPHP::VM::ActRec *ar) {
|
||||
TypedValue rv;
|
||||
int64_t count = ar->numArgs();
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
if (count == 2LL) {
|
||||
if (IS_STRING_TYPE((args-1)->m_type) && IS_STRING_TYPE((args-0)->m_type)) {
|
||||
rv.m_type = KindOfString;
|
||||
th_10UConverter_getStandardName((Value*)(&(rv)), ("UConverter"), (Value*)(args-0), (Value*)(args-1));
|
||||
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
|
||||
frame_free_locals_no_this_inl(ar, 2);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
tg1_10UConverter_getStandardName(&rv, ar, count );
|
||||
frame_free_locals_no_this_inl(ar, 2);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
}
|
||||
} else {
|
||||
throw_wrong_arguments_nr("UConverter::getStandardName", count, 2, 2, 1);
|
||||
}
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
frame_free_locals_no_this_inl(ar, 2);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
return &ar->m_r;
|
||||
}
|
||||
|
||||
/*
|
||||
HPHP::String HPHP::c_UConverter::ti_getmimename(char const*, HPHP::String const&)
|
||||
_ZN4HPHP12c_UConverter14ti_getmimenameEPKcRKNS_6StringE
|
||||
|
||||
(return value) => rax
|
||||
_rv => rdi
|
||||
cls_ => rsi
|
||||
name => rdx
|
||||
*/
|
||||
|
||||
Value* th_10UConverter_getMIMEName(Value* _rv, char const* cls_, Value* name) asm("_ZN4HPHP12c_UConverter14ti_getmimenameEPKcRKNS_6StringE");
|
||||
|
||||
TypedValue* tg1_10UConverter_getMIMEName(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) __attribute__((noinline,cold));
|
||||
TypedValue* tg1_10UConverter_getMIMEName(TypedValue* rv, HPHP::VM::ActRec* ar, int64_t count) {
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
rv->m_type = KindOfString;
|
||||
tvCastToStringInPlace(args-0);
|
||||
th_10UConverter_getMIMEName((Value*)(rv), ("UConverter"), (Value*)(args-0));
|
||||
if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
TypedValue* tg_10UConverter_getMIMEName(HPHP::VM::ActRec *ar) {
|
||||
TypedValue rv;
|
||||
int64_t count = ar->numArgs();
|
||||
TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
|
||||
if (count == 1LL) {
|
||||
if (IS_STRING_TYPE((args-0)->m_type)) {
|
||||
rv.m_type = KindOfString;
|
||||
th_10UConverter_getMIMEName((Value*)(&(rv)), ("UConverter"), (Value*)(args-0));
|
||||
if (rv.m_data.num == 0LL) rv.m_type = KindOfNull;
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
} else {
|
||||
tg1_10UConverter_getMIMEName(&rv, ar, count );
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
}
|
||||
} else {
|
||||
throw_wrong_arguments_nr("UConverter::getMIMEName", count, 1, 1, 1);
|
||||
}
|
||||
rv.m_data.num = 0LL;
|
||||
rv.m_type = KindOfNull;
|
||||
frame_free_locals_no_this_inl(ar, 1);
|
||||
memcpy(&ar->m_r, &rv, sizeof(TypedValue));
|
||||
return &ar->m_r;
|
||||
return &ar->m_r;
|
||||
}
|
||||
|
||||
|
||||
} // !HPHP
|
||||
|
||||
|
||||
@@ -129,6 +129,16 @@ class c_UConverter : public ExtObjectData {
|
||||
public: static Array t_getstandards() {
|
||||
return ti_getstandards("uconverter");
|
||||
}
|
||||
public: static String ti_getstandardname(const char* cls,
|
||||
CStrRef name,
|
||||
CStrRef standard);
|
||||
public: static String t_getstandardname(CStrRef name, CStrRef standard) {
|
||||
return ti_getstandardname("uconverter", name, standard);
|
||||
}
|
||||
public: static String ti_getmimename(const char* cls, CStrRef name);
|
||||
public: static String t_getmimename(CStrRef name) {
|
||||
return ti_getmimename("uconverter", name);
|
||||
}
|
||||
|
||||
private:
|
||||
static void throwFailure(UErrorCode error, const char *fname,
|
||||
|
||||
@@ -2686,6 +2686,8 @@ TypedValue* tg_10UConverter_reasonText(VM::ActRec *ar);
|
||||
TypedValue* tg_10UConverter_getAvailable(VM::ActRec *ar);
|
||||
TypedValue* tg_10UConverter_getAliases(VM::ActRec *ar);
|
||||
TypedValue* tg_10UConverter_getStandards(VM::ActRec *ar);
|
||||
TypedValue* tg_10UConverter_getStandardName(VM::ActRec *ar);
|
||||
TypedValue* tg_10UConverter_getMIMEName(VM::ActRec *ar);
|
||||
VM::Instance* new_EncodingDetector_Instance(VM::Class*);
|
||||
TypedValue* tg_16EncodingDetector___construct(VM::ActRec *ar);
|
||||
TypedValue* tg_16EncodingDetector_setText(VM::ActRec *ar);
|
||||
@@ -5813,7 +5815,7 @@ static const HhbcExtMethodInfo hhbc_ext_methods_DOMXPath[] = {
|
||||
{ "__isset", tg_8DOMXPath___isset }
|
||||
};
|
||||
|
||||
static const long long hhbc_ext_method_count_UConverter = 20;
|
||||
static const long long hhbc_ext_method_count_UConverter = 22;
|
||||
static const HhbcExtMethodInfo hhbc_ext_methods_UConverter[] = {
|
||||
{ "__construct", tg_10UConverter___construct },
|
||||
{ "__destruct", tg_10UConverter___destruct },
|
||||
@@ -5834,7 +5836,9 @@ static const HhbcExtMethodInfo hhbc_ext_methods_UConverter[] = {
|
||||
{ "reasonText", tg_10UConverter_reasonText },
|
||||
{ "getAvailable", tg_10UConverter_getAvailable },
|
||||
{ "getAliases", tg_10UConverter_getAliases },
|
||||
{ "getStandards", tg_10UConverter_getStandards }
|
||||
{ "getStandards", tg_10UConverter_getStandards },
|
||||
{ "getStandardName", tg_10UConverter_getStandardName },
|
||||
{ "getMIMEName", tg_10UConverter_getMIMEName }
|
||||
};
|
||||
|
||||
static const long long hhbc_ext_method_count_EncodingDetector = 5;
|
||||
|
||||
@@ -21680,6 +21680,19 @@ const char *g_class_map[] = {
|
||||
(const char *)0x20, NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006240, "getStandardName", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/uconverter.getstandardname.php )\n *\n * Returns a standard name for a given converter name.\n *\n * @name string Original converter name\n * @standard string Name of the standard governing the names, e.g.\n * 'MIME' or 'IANA'\n *\n * @return string Standard name of converter\n */",
|
||||
(const char *)0x14, (const char *)0x2000, "name", "", (const char *)0x14, "", "", NULL,
|
||||
(const char *)0x2000, "standard", "", (const char *)0x14, "", "", NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
(const char *)0x10006240, "getMIMEName", "", (const char*)0, (const char*)0,
|
||||
"/**\n * ( excerpt from http://php.net/manual/en/uconverter.getmimename.php )\n *\n * Returns the MIME name for a given converter name.\n *\n * @name string Original converter name\n *\n * @return string Converter's MIME name\n */",
|
||||
(const char *)0x14, (const char *)0x2000, "name", "", (const char *)0x14, "", "", NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
"REASON_UNASSIGNED", (const char*)&q_UConverter$$REASON_UNASSIGNED, (const char *)0xc,
|
||||
|
||||
@@ -34666,6 +34666,33 @@ bool TestCodeRun::TestUConverter() {
|
||||
"**Disallowed\n"
|
||||
);
|
||||
|
||||
MVCRO("<?php "
|
||||
"$standards = UConverter::getStandards();"
|
||||
"var_dump(in_array('IANA', $standards));"
|
||||
"var_dump(in_array('MIME', $standards));"
|
||||
,
|
||||
"bool(true)\n"
|
||||
"bool(true)\n"
|
||||
);
|
||||
|
||||
MVCRO("<?php "
|
||||
"var_dump(UConverter::getStandardName('latin1', 'MIME'));"
|
||||
"var_dump(UConverter::getStandardName('latin1', 'IANA'));"
|
||||
"var_dump(UConverter::getStandardName('blergh', 'blergh'));"
|
||||
,
|
||||
"string(10) \"ISO-8859-1\"\n"
|
||||
"string(15) \"ISO_8859-1:1987\"\n"
|
||||
"NULL\n"
|
||||
);
|
||||
|
||||
MVCRO("<?php "
|
||||
"var_dump(UConverter::getMIMEName('latin1'));"
|
||||
"var_dump(UConverter::getMIMEName('blergh'));"
|
||||
,
|
||||
"string(10) \"ISO-8859-1\"\n"
|
||||
"NULL\n"
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário