mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
interrogate supports wstring
This commit is contained in:
parent
ebfc35f0de
commit
01c82da5df
@ -239,6 +239,7 @@ pop_struct() {
|
|||||||
%token KW_BOOL
|
%token KW_BOOL
|
||||||
%token KW_CATCH
|
%token KW_CATCH
|
||||||
%token KW_CHAR
|
%token KW_CHAR
|
||||||
|
%token KW_WCHAR_T
|
||||||
%token KW_CLASS
|
%token KW_CLASS
|
||||||
%token KW_CONST
|
%token KW_CONST
|
||||||
%token KW_DELETE
|
%token KW_DELETE
|
||||||
@ -346,7 +347,7 @@ pop_struct() {
|
|||||||
|
|
||||||
/* Precedence rules. */
|
/* Precedence rules. */
|
||||||
|
|
||||||
%left IDENTIFIER TYPENAME_IDENTIFIER TYPEDEFNAME KW_ENUM ELLIPSIS KW_OPERATOR KW_TYPENAME KW_INT KW_SHORT KW_UNSIGNED KW_SIGNED KW_LONG KW_FLOAT KW_DOUBLE KW_CHAR KW_BOOL
|
%left IDENTIFIER TYPENAME_IDENTIFIER TYPEDEFNAME KW_ENUM ELLIPSIS KW_OPERATOR KW_TYPENAME KW_INT KW_SHORT KW_UNSIGNED KW_SIGNED KW_LONG KW_FLOAT KW_DOUBLE KW_CHAR KW_WCHAR_T KW_BOOL
|
||||||
|
|
||||||
%left '{' ',' ';'
|
%left '{' ',' ';'
|
||||||
|
|
||||||
@ -1908,6 +1909,10 @@ simple_int_type:
|
|||||||
| KW_CHAR
|
| KW_CHAR
|
||||||
{
|
{
|
||||||
$$ = new CPPSimpleType(CPPSimpleType::T_char);
|
$$ = new CPPSimpleType(CPPSimpleType::T_char);
|
||||||
|
}
|
||||||
|
| KW_WCHAR_T
|
||||||
|
{
|
||||||
|
$$ = new CPPSimpleType(CPPSimpleType::T_wchar_t);
|
||||||
}
|
}
|
||||||
| KW_SHORT
|
| KW_SHORT
|
||||||
{
|
{
|
||||||
@ -2046,7 +2051,7 @@ element:
|
|||||||
| SCOPE | PLUSPLUS | MINUSMINUS
|
| SCOPE | PLUSPLUS | MINUSMINUS
|
||||||
| TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL
|
| TIMESEQUAL | DIVIDEEQUAL | MODEQUAL | PLUSEQUAL | MINUSEQUAL
|
||||||
| OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL
|
| OREQUAL | ANDEQUAL | XOREQUAL | LSHIFTEQUAL | RSHIFTEQUAL
|
||||||
| KW_BOOL | KW_CATCH | KW_CHAR | KW_CLASS | KW_CONST
|
| KW_BOOL | KW_CATCH | KW_CHAR | KW_WCHAR_T | KW_CLASS | KW_CONST
|
||||||
| KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM
|
| KW_DELETE | KW_DOUBLE | KW_DYNAMIC_CAST | KW_ELSE | KW_ENUM
|
||||||
| KW_EXTERN | KW_EXPLICIT | KW_FALSE
|
| KW_EXTERN | KW_EXPLICIT | KW_FALSE
|
||||||
| KW_FLOAT | KW_FRIEND | KW_FOR | KW_GOTO
|
| KW_FLOAT | KW_FRIEND | KW_FOR | KW_GOTO
|
||||||
@ -2273,6 +2278,12 @@ const_expr:
|
|||||||
CPPType *type =
|
CPPType *type =
|
||||||
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char));
|
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_char));
|
||||||
$$ = new CPPExpression(CPPExpression::construct_op(type, $3));
|
$$ = new CPPExpression(CPPExpression::construct_op(type, $3));
|
||||||
|
}
|
||||||
|
| KW_WCHAR_T '(' optional_const_expr_comma ')'
|
||||||
|
{
|
||||||
|
CPPType *type =
|
||||||
|
CPPType::new_type(new CPPSimpleType(CPPSimpleType::T_wchar_t));
|
||||||
|
$$ = new CPPExpression(CPPExpression::construct_op(type, $3));
|
||||||
}
|
}
|
||||||
| KW_BOOL '(' optional_const_expr_comma ')'
|
| KW_BOOL '(' optional_const_expr_comma ')'
|
||||||
{
|
{
|
||||||
|
@ -1911,6 +1911,7 @@ check_keyword(const string &name) {
|
|||||||
if (name == "bool") return KW_BOOL;
|
if (name == "bool") return KW_BOOL;
|
||||||
if (name == "catch") return KW_CATCH;
|
if (name == "catch") return KW_CATCH;
|
||||||
if (name == "char") return KW_CHAR;
|
if (name == "char") return KW_CHAR;
|
||||||
|
if (name == "wchar_t") return KW_WCHAR_T;
|
||||||
if (name == "class") return KW_CLASS;
|
if (name == "class") return KW_CLASS;
|
||||||
if (name == "const") return KW_CONST;
|
if (name == "const") return KW_CONST;
|
||||||
if (name == "delete") return KW_DELETE;
|
if (name == "delete") return KW_DELETE;
|
||||||
|
@ -111,6 +111,10 @@ output(ostream &out, int, CPPScope *, bool) const {
|
|||||||
out << "char";
|
out << "char";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_wchar_t:
|
||||||
|
out << "wchar_t";
|
||||||
|
break;
|
||||||
|
|
||||||
case T_int:
|
case T_int:
|
||||||
out << "int";
|
out << "int";
|
||||||
break;
|
break;
|
||||||
|
@ -32,6 +32,7 @@ public:
|
|||||||
enum Type {
|
enum Type {
|
||||||
T_bool,
|
T_bool,
|
||||||
T_char,
|
T_char,
|
||||||
|
T_wchar_t, // Not strictly a builtin type, but we pretend.
|
||||||
T_int,
|
T_int,
|
||||||
T_float,
|
T_float,
|
||||||
T_double,
|
T_double,
|
||||||
|
@ -283,12 +283,19 @@ remap_parameter(CPPType *struct_type, CPPType *param_type) {
|
|||||||
// convert basic_string<char>'s to atomic strings.
|
// convert basic_string<char>'s to atomic strings.
|
||||||
|
|
||||||
if (struct_type == (CPPType *)NULL ||
|
if (struct_type == (CPPType *)NULL ||
|
||||||
!TypeManager::is_basic_string_char(struct_type)) {
|
!(TypeManager::is_basic_string_char(struct_type) ||
|
||||||
|
TypeManager::is_basic_string_wchar(struct_type))) {
|
||||||
if (TypeManager::is_basic_string_char(param_type)) {
|
if (TypeManager::is_basic_string_char(param_type)) {
|
||||||
return new ParameterRemapBasicStringToString(param_type);
|
return new ParameterRemapBasicStringToString(param_type);
|
||||||
|
|
||||||
} else if (TypeManager::is_const_ref_to_basic_string_char(param_type)) {
|
} else if (TypeManager::is_const_ref_to_basic_string_char(param_type)) {
|
||||||
return new ParameterRemapBasicStringRefToString(param_type);
|
return new ParameterRemapBasicStringRefToString(param_type);
|
||||||
|
|
||||||
|
} else if (TypeManager::is_basic_string_wchar(param_type)) {
|
||||||
|
return new ParameterRemapBasicWStringToWString(param_type);
|
||||||
|
|
||||||
|
} else if (TypeManager::is_const_ref_to_basic_string_wchar(param_type)) {
|
||||||
|
return new ParameterRemapBasicWStringRefToWString(param_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1826,7 +1826,8 @@ int GetParnetDepth(CPPType *type)
|
|||||||
int answer = 0;
|
int answer = 0;
|
||||||
// printf(" %s\n",type->get_local_name().c_str());
|
// printf(" %s\n",type->get_local_name().c_str());
|
||||||
|
|
||||||
if (TypeManager::is_basic_string_char(type)) {
|
if (TypeManager::is_basic_string_char(type)) {
|
||||||
|
} else if (TypeManager::is_basic_string_wchar(type)) {
|
||||||
} else if (TypeManager::is_bool(type)) {
|
} else if (TypeManager::is_bool(type)) {
|
||||||
} else if (TypeManager::is_unsigned_longlong(type)) {
|
} else if (TypeManager::is_unsigned_longlong(type)) {
|
||||||
} else if (TypeManager::is_longlong(type)) {
|
} else if (TypeManager::is_longlong(type)) {
|
||||||
@ -2011,9 +2012,18 @@ void InterfaceMakerPythonNative::write_function_instance(ostream &out, Interface
|
|||||||
indent(out,indent_level+4)<< "char *" << param_name;
|
indent(out,indent_level+4)<< "char *" << param_name;
|
||||||
format_specifiers += "s";
|
format_specifiers += "s";
|
||||||
parameter_list += ", &" + param_name;
|
parameter_list += ", &" + param_name;
|
||||||
}
|
|
||||||
else
|
} else if (TypeManager::is_wstring(orig_type)) {
|
||||||
{
|
indent(out,indent_level+4) << "Py_UNICODE *" << param_name
|
||||||
|
<< "_str; int " << param_name << "_len";
|
||||||
|
format_specifiers += "u#";
|
||||||
|
parameter_list += ", &" + param_name
|
||||||
|
+ "_str, &" + param_name + "_len";
|
||||||
|
pexpr_string = "basic_string<wchar_t>(" +
|
||||||
|
param_name + "_str, " +
|
||||||
|
param_name + "_len)";
|
||||||
|
|
||||||
|
} else {
|
||||||
indent(out,indent_level+4) << "char *" << param_name
|
indent(out,indent_level+4) << "char *" << param_name
|
||||||
<< "_str; int " << param_name << "_len";
|
<< "_str; int " << param_name << "_len";
|
||||||
format_specifiers += "s#";
|
format_specifiers += "s#";
|
||||||
@ -2284,6 +2294,11 @@ void InterfaceMakerPythonNative::pack_return_value(ostream &out, int indent_leve
|
|||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "return PyString_FromString(" << return_expr << ");\n";
|
<< "return PyString_FromString(" << return_expr << ");\n";
|
||||||
|
|
||||||
|
} else if (TypeManager::is_wstring(orig_type)) {
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< "return PyUnicode_FromWideChar("
|
||||||
|
<< return_expr << ".data(), (int)" << return_expr << ".length());\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "return PyString_FromStringAndSize("
|
<< "return PyString_FromStringAndSize("
|
||||||
@ -2669,6 +2684,10 @@ bool InterfaceMakerPythonNative::isCppTypeLegal(CPPType *in_ctype)
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if(TypeManager::is_basic_string_wchar(type))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
else if(TypeManager::is_simple(type))
|
else if(TypeManager::is_simple(type))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -268,6 +268,16 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface
|
|||||||
format_specifiers += "s";
|
format_specifiers += "s";
|
||||||
parameter_list += ", &" + param_name;
|
parameter_list += ", &" + param_name;
|
||||||
|
|
||||||
|
} else if (TypeManager::is_wstring(orig_type)) {
|
||||||
|
out << "Py_UNICODE *" << param_name
|
||||||
|
<< "_str; int " << param_name << "_len";
|
||||||
|
format_specifiers += "u#";
|
||||||
|
parameter_list += ", &" + param_name
|
||||||
|
+ "_str, &" + param_name + "_len";
|
||||||
|
pexpr_string = "basic_string<wchar_t>(" +
|
||||||
|
param_name + "_str, " +
|
||||||
|
param_name + "_len)";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
out << "char *" << param_name
|
out << "char *" << param_name
|
||||||
<< "_str; int " << param_name << "_len";
|
<< "_str; int " << param_name << "_len";
|
||||||
@ -449,6 +459,11 @@ pack_return_value(ostream &out, int indent_level,
|
|||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "return PyString_FromString(" << return_expr << ");\n";
|
<< "return PyString_FromString(" << return_expr << ");\n";
|
||||||
|
|
||||||
|
} else if (TypeManager::is_wstring(orig_type)) {
|
||||||
|
indent(out, indent_level)
|
||||||
|
<< "return PyUnicode_FromWideChar("
|
||||||
|
<< return_expr << ".data(), (int)" << return_expr << ".length());\n";
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
indent(out, indent_level)
|
indent(out, indent_level)
|
||||||
<< "return PyString_FromStringAndSize("
|
<< "return PyString_FromStringAndSize("
|
||||||
|
@ -1737,6 +1737,7 @@ get_type(CPPType *type, bool global) {
|
|||||||
if (global) {
|
if (global) {
|
||||||
itype._flags |= InterrogateType::F_global;
|
itype._flags |= InterrogateType::F_global;
|
||||||
}
|
}
|
||||||
|
|
||||||
InterrogateDatabase::get_ptr()->add_type(index, itype);
|
InterrogateDatabase::get_ptr()->add_type(index, itype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1840,6 +1841,10 @@ define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype) {
|
|||||||
itype._atomic_token = AT_char;
|
itype._atomic_token = AT_char;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CPPSimpleType::T_wchar_t:
|
||||||
|
itype._atomic_token = AT_int;
|
||||||
|
break;
|
||||||
|
|
||||||
case CPPSimpleType::T_int:
|
case CPPSimpleType::T_int:
|
||||||
if ((cpptype->_flags & CPPSimpleType::F_longlong) != 0) {
|
if ((cpptype->_flags & CPPSimpleType::F_longlong) != 0) {
|
||||||
itype._atomic_token = AT_longlong;
|
itype._atomic_token = AT_longlong;
|
||||||
|
@ -52,3 +52,38 @@ string ParameterRemapBasicStringRefToString::
|
|||||||
get_return_expr(const string &expression) {
|
get_return_expr(const string &expression) {
|
||||||
return "(" + expression + ").c_str()";
|
return "(" + expression + ").c_str()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringRefToWString::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
ParameterRemapBasicWStringRefToWString::
|
||||||
|
ParameterRemapBasicWStringRefToWString(CPPType *orig_type) :
|
||||||
|
ParameterRemapToWString(orig_type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringRefToWString::pass_parameter
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Outputs an expression that converts the indicated
|
||||||
|
// variable from the original type to the new type, for
|
||||||
|
// passing into the actual C++ function.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void ParameterRemapBasicWStringRefToWString::
|
||||||
|
pass_parameter(ostream &out, const string &variable_name) {
|
||||||
|
out << variable_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringRefToWString::get_return_expr
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns an expression that evalutes to the
|
||||||
|
// appropriate value type for returning from the
|
||||||
|
// function, given an expression of the original type.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string ParameterRemapBasicWStringRefToWString::
|
||||||
|
get_return_expr(const string &expression) {
|
||||||
|
return "(" + expression + ").c_str()";
|
||||||
|
}
|
||||||
|
@ -36,4 +36,17 @@ public:
|
|||||||
virtual string get_return_expr(const string &expression);
|
virtual string get_return_expr(const string &expression);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : ParameterRemapBasicWStringRefToWString
|
||||||
|
// Description : Maps a const reference to a basic_string<wchar_t> to an
|
||||||
|
// atomic string.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class ParameterRemapBasicWStringRefToWString : public ParameterRemapToWString {
|
||||||
|
public:
|
||||||
|
ParameterRemapBasicWStringRefToWString(CPPType *orig_type);
|
||||||
|
|
||||||
|
virtual void pass_parameter(ostream &out, const string &variable_name);
|
||||||
|
virtual string get_return_expr(const string &expression);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,3 +69,54 @@ string ParameterRemapBasicStringToString::
|
|||||||
get_return_expr(const string &expression) {
|
get_return_expr(const string &expression) {
|
||||||
return "string_holder.c_str()";
|
return "string_holder.c_str()";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringToWString::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
ParameterRemapBasicWStringToWString::
|
||||||
|
ParameterRemapBasicWStringToWString(CPPType *orig_type) :
|
||||||
|
ParameterRemapToString(orig_type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringToWString::pass_parameter
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Outputs an expression that converts the indicated
|
||||||
|
// variable from the original type to the new type, for
|
||||||
|
// passing into the actual C++ function.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void ParameterRemapBasicWStringToWString::
|
||||||
|
pass_parameter(ostream &out, const string &variable_name) {
|
||||||
|
out << variable_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringToWString::prepare_return_expr
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: This will be called immediately before
|
||||||
|
// get_return_expr(). It outputs whatever lines the
|
||||||
|
// remapper needs to the function to set up its return
|
||||||
|
// value, e.g. to declare a temporary variable or
|
||||||
|
// something. It should return the modified expression.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string ParameterRemapBasicWStringToWString::
|
||||||
|
prepare_return_expr(ostream &out, int indent_level, const string &expression) {
|
||||||
|
InterfaceMaker::indent(out, indent_level)
|
||||||
|
<< "static wstring string_holder = " << expression << ";\n";
|
||||||
|
return "string_holder";
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapBasicWStringToWString::get_return_expr
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns an expression that evalutes to the
|
||||||
|
// appropriate value type for returning from the
|
||||||
|
// function, given an expression of the original type.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string ParameterRemapBasicWStringToWString::
|
||||||
|
get_return_expr(const string &expression) {
|
||||||
|
return "string_holder.c_str()";
|
||||||
|
}
|
||||||
|
@ -38,4 +38,19 @@ public:
|
|||||||
virtual string get_return_expr(const string &expression);
|
virtual string get_return_expr(const string &expression);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : ParameterRemapBasicWStringToWString
|
||||||
|
// Description : Maps a concrete basic_string<wchar_t> to an atomic
|
||||||
|
// string.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class ParameterRemapBasicWStringToWString : public ParameterRemapToString {
|
||||||
|
public:
|
||||||
|
ParameterRemapBasicWStringToWString(CPPType *orig_type);
|
||||||
|
|
||||||
|
virtual void pass_parameter(ostream &out, const string &variable_name);
|
||||||
|
virtual string prepare_return_expr(ostream &out, int indent_level,
|
||||||
|
const string &expression);
|
||||||
|
virtual string get_return_expr(const string &expression);
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,3 +73,58 @@ bool ParameterRemapToString::
|
|||||||
new_type_is_atomic_string() {
|
new_type_is_atomic_string() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapToWString::Constructor
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
ParameterRemapToWString::
|
||||||
|
ParameterRemapToWString(CPPType *orig_type) :
|
||||||
|
ParameterRemap(orig_type)
|
||||||
|
{
|
||||||
|
static CPPType *char_star_type = (CPPType *)NULL;
|
||||||
|
if (char_star_type == (CPPType *)NULL) {
|
||||||
|
char_star_type = parser.parse_type("const wchar_t *");
|
||||||
|
}
|
||||||
|
|
||||||
|
_new_type = char_star_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapToWString::pass_parameter
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Outputs an expression that converts the indicated
|
||||||
|
// variable from the original type to the new type, for
|
||||||
|
// passing into the actual C++ function.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void ParameterRemapToWString::
|
||||||
|
pass_parameter(ostream &out, const string &variable_name) {
|
||||||
|
out << variable_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapToWString::get_return_expr
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns an expression that evalutes to the
|
||||||
|
// appropriate value type for returning from the
|
||||||
|
// function, given an expression of the original type.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
string ParameterRemapToWString::
|
||||||
|
get_return_expr(const string &expression) {
|
||||||
|
return expression;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ParameterRemapToWString::new_type_is_atomic_string
|
||||||
|
// Access: Public, Virtual
|
||||||
|
// Description: Returns true if the type represented by the
|
||||||
|
// conversion is now the atomic string type. We have to
|
||||||
|
// have this crazy method for representing atomic
|
||||||
|
// string, because there's no such type in C (and hence
|
||||||
|
// no corresponding CPPType *).
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool ParameterRemapToWString::
|
||||||
|
new_type_is_atomic_string() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -43,4 +43,24 @@ public:
|
|||||||
virtual bool new_type_is_atomic_string();
|
virtual bool new_type_is_atomic_string();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : ParameterRemapToWString
|
||||||
|
// Description : A base class for several different remapping types
|
||||||
|
// that convert to an atomic string class.
|
||||||
|
//
|
||||||
|
// The atomic string class is represented in the C
|
||||||
|
// interface as a (const wchar_t *). Other interfaces
|
||||||
|
// may be able to represent it differently, subverting
|
||||||
|
// the code defined here.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class ParameterRemapToWString : public ParameterRemap {
|
||||||
|
public:
|
||||||
|
ParameterRemapToWString(CPPType *orig_type);
|
||||||
|
|
||||||
|
virtual void pass_parameter(ostream &out, const string &variable_name);
|
||||||
|
virtual string get_return_expr(const string &expression);
|
||||||
|
|
||||||
|
virtual bool new_type_is_atomic_string();
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,9 +91,9 @@ is_assignable(CPPType *type) {
|
|||||||
// don't get setters synthesized for them. If you want a setter,
|
// don't get setters synthesized for them. If you want a setter,
|
||||||
// write it yourself.
|
// write it yourself.
|
||||||
|
|
||||||
// We'll make an exception for basic_string<char>, however, since
|
// We'll make an exception for the string types, however, since
|
||||||
// this is nearly an atomic type.
|
// these are nearly an atomic type.
|
||||||
if (is_basic_string_char(type)) {
|
if (is_basic_string_char(type) || is_basic_string_wchar(type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,6 +472,84 @@ is_const_ref_to_basic_string_char(CPPType *type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TypeManager::is_basic_string_wchar
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Returns true if the type is basic_string<wchar_t>. This
|
||||||
|
// is the standard C++ wide string class.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TypeManager::
|
||||||
|
is_basic_string_wchar(CPPType *type) {
|
||||||
|
CPPType *string_type = get_basic_string_wchar_type();
|
||||||
|
if (string_type != (CPPType *)NULL &&
|
||||||
|
string_type->get_local_name(&parser) == type->get_local_name(&parser)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type->get_subtype()) {
|
||||||
|
case CPPDeclaration::ST_const:
|
||||||
|
return is_basic_string_wchar(type->as_const_type()->_wrapped_around);
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TypeManager::is_const_basic_string_wchar
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Returns true if the indicated type is a const wrapper
|
||||||
|
// around basic_string<wchar_t>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TypeManager::
|
||||||
|
is_const_basic_string_wchar(CPPType *type) {
|
||||||
|
switch (type->get_subtype()) {
|
||||||
|
case CPPDeclaration::ST_const:
|
||||||
|
return is_basic_string_wchar(type->as_const_type()->_wrapped_around);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TypeManager::is_const_ref_to_basic_string_wchar
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Returns true if the indicated type is a const
|
||||||
|
// reference to basic_string<wchar_t>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TypeManager::
|
||||||
|
is_const_ref_to_basic_string_wchar(CPPType *type) {
|
||||||
|
switch (type->get_subtype()) {
|
||||||
|
case CPPDeclaration::ST_reference:
|
||||||
|
return is_const_basic_string_wchar(type->as_reference_type()->_pointing_at);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TypeManager::is_wstring
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Returns true if the type is basic_string<wchar_t>, or
|
||||||
|
// a const reference to it.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
bool TypeManager::
|
||||||
|
is_wstring(CPPType *type) {
|
||||||
|
switch (type->get_subtype()) {
|
||||||
|
case CPPDeclaration::ST_reference:
|
||||||
|
return is_const_basic_string_wchar(type->as_reference_type()->_pointing_at);
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_basic_string_wchar(type);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TypeManager::is_bool
|
// Function: TypeManager::is_bool
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
@ -524,6 +602,7 @@ is_integer(CPPType *type) {
|
|||||||
return
|
return
|
||||||
(simple_type->_type == CPPSimpleType::T_bool ||
|
(simple_type->_type == CPPSimpleType::T_bool ||
|
||||||
simple_type->_type == CPPSimpleType::T_char ||
|
simple_type->_type == CPPSimpleType::T_char ||
|
||||||
|
simple_type->_type == CPPSimpleType::T_wchar_t ||
|
||||||
simple_type->_type == CPPSimpleType::T_int);
|
simple_type->_type == CPPSimpleType::T_int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,6 +634,7 @@ is_unsigned_integer(CPPType *type) {
|
|||||||
return
|
return
|
||||||
((simple_type->_type == CPPSimpleType::T_bool ||
|
((simple_type->_type == CPPSimpleType::T_bool ||
|
||||||
simple_type->_type == CPPSimpleType::T_char ||
|
simple_type->_type == CPPSimpleType::T_char ||
|
||||||
|
simple_type->_type == CPPSimpleType::T_wchar_t ||
|
||||||
simple_type->_type == CPPSimpleType::T_int) &&
|
simple_type->_type == CPPSimpleType::T_int) &&
|
||||||
(simple_type->_flags & CPPSimpleType::F_unsigned) != 0);
|
(simple_type->_flags & CPPSimpleType::F_unsigned) != 0);
|
||||||
}
|
}
|
||||||
@ -1217,6 +1297,23 @@ get_basic_string_char_type() {
|
|||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TypeManager::get_basic_string_wchar_type
|
||||||
|
// Access: Public, Static
|
||||||
|
// Description: Returns a CPPType that represents basic_string<wchar_t>,
|
||||||
|
// or NULL if the type is unknown.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
CPPType *TypeManager::
|
||||||
|
get_basic_string_wchar_type() {
|
||||||
|
static bool got_type = false;
|
||||||
|
static CPPType *type = (CPPType *)NULL;
|
||||||
|
if (!got_type) {
|
||||||
|
type = parser.parse_type("basic_string<wchar_t>");
|
||||||
|
got_type = true;
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TypeManager::get_reference_count_type
|
// Function: TypeManager::get_reference_count_type
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
|
@ -68,6 +68,10 @@ public:
|
|||||||
static bool is_basic_string_char(CPPType *type);
|
static bool is_basic_string_char(CPPType *type);
|
||||||
static bool is_const_basic_string_char(CPPType *type);
|
static bool is_const_basic_string_char(CPPType *type);
|
||||||
static bool is_const_ref_to_basic_string_char(CPPType *type);
|
static bool is_const_ref_to_basic_string_char(CPPType *type);
|
||||||
|
static bool is_basic_string_wchar(CPPType *type);
|
||||||
|
static bool is_const_basic_string_wchar(CPPType *type);
|
||||||
|
static bool is_const_ref_to_basic_string_wchar(CPPType *type);
|
||||||
|
static bool is_wstring(CPPType *type);
|
||||||
static bool is_bool(CPPType *type);
|
static bool is_bool(CPPType *type);
|
||||||
static bool is_integer(CPPType *type);
|
static bool is_integer(CPPType *type);
|
||||||
static bool is_unsigned_integer(CPPType *type);
|
static bool is_unsigned_integer(CPPType *type);
|
||||||
@ -101,6 +105,7 @@ public:
|
|||||||
static CPPType *wrap_const_reference(CPPType *type);
|
static CPPType *wrap_const_reference(CPPType *type);
|
||||||
|
|
||||||
static CPPType *get_basic_string_char_type();
|
static CPPType *get_basic_string_char_type();
|
||||||
|
static CPPType *get_basic_string_wchar_type();
|
||||||
static CPPType *get_reference_count_type();
|
static CPPType *get_reference_count_type();
|
||||||
static CPPType *get_void_type();
|
static CPPType *get_void_type();
|
||||||
static CPPType *get_int_type();
|
static CPPType *get_int_type();
|
||||||
|
@ -35,7 +35,6 @@ namespace std {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
typedef int ptrdiff_t;
|
typedef int ptrdiff_t;
|
||||||
typedef int wchar_t;
|
|
||||||
|
|
||||||
typedef unsigned int uint;
|
typedef unsigned int uint;
|
||||||
typedef unsigned long ulong;
|
typedef unsigned long ulong;
|
||||||
|
@ -473,7 +473,7 @@ lower(const string &source, TextEncoder::Encoding encoding) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::set_wtext
|
// Function: TextEncoder::set_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Changes the text that is stored in the encoder.
|
// Description: Changes the text that is stored in the encoder.
|
||||||
// Subsequent calls to get_wtext() will return this same
|
// Subsequent calls to get_wtext() will return this same
|
||||||
// string, while get_text() will return the encoded
|
// string, while get_text() will return the encoded
|
||||||
@ -489,7 +489,7 @@ set_wtext(const wstring &wtext) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::get_wtext
|
// Function: TextEncoder::get_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Returns the text associated with the TextEncoder, as
|
// Description: Returns the text associated with the TextEncoder, as
|
||||||
// a wide-character string.
|
// a wide-character string.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -504,7 +504,7 @@ get_wtext() const {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::append_wtext
|
// Function: TextEncoder::append_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Appends the indicates string to the end of the stored
|
// Description: Appends the indicates string to the end of the stored
|
||||||
// wide-character text.
|
// wide-character text.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -516,7 +516,7 @@ append_wtext(const wstring &wtext) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::encode_wtext
|
// Function: TextEncoder::encode_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Encodes a wide-text string into a single-char string,
|
// Description: Encodes a wide-text string into a single-char string,
|
||||||
// according to the current encoding.
|
// according to the current encoding.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -527,7 +527,7 @@ encode_wtext(const wstring &wtext) const {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::decode_text
|
// Function: TextEncoder::decode_text
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Returns the given wstring decoded to a single-byte
|
// Description: Returns the given wstring decoded to a single-byte
|
||||||
// string, via the current encoding system.
|
// string, via the current encoding system.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -62,7 +62,7 @@ make_lower() {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::get_wtext_as_ascii
|
// Function: TextEncoder::get_wtext_as_ascii
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Returns the text associated with the node, converted
|
// Description: Returns the text associated with the node, converted
|
||||||
// as nearly as possible to a fully-ASCII
|
// as nearly as possible to a fully-ASCII
|
||||||
// representation. This means replacing accented
|
// representation. This means replacing accented
|
||||||
@ -105,7 +105,7 @@ get_wtext_as_ascii() const {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::encode_wchar
|
// Function: TextEncoder::encode_wchar
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Encodes a single wide char into a one-, two-, or
|
// Description: Encodes a single wide char into a one-, two-, or
|
||||||
// three-byte string, according to the given encoding
|
// three-byte string, according to the given encoding
|
||||||
// system.
|
// system.
|
||||||
@ -161,7 +161,7 @@ encode_wchar(wchar_t ch, TextEncoder::Encoding encoding) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::encode_wtext
|
// Function: TextEncoder::encode_wtext
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Encodes a wide-text string into a single-char string,
|
// Description: Encodes a wide-text string into a single-char string,
|
||||||
// according to the given encoding.
|
// according to the given encoding.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -178,7 +178,7 @@ encode_wtext(const wstring &wtext, TextEncoder::Encoding encoding) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextEncoder::decode_text
|
// Function: TextEncoder::decode_text
|
||||||
// Access: Public, Static
|
// Access: Published, Static
|
||||||
// Description: Returns the given wstring decoded to a single-byte
|
// Description: Returns the given wstring decoded to a single-byte
|
||||||
// string, via the given encoding system.
|
// string, via the given encoding system.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -87,9 +87,8 @@ PUBLISHED:
|
|||||||
INLINE static string lower(const string &source);
|
INLINE static string lower(const string &source);
|
||||||
INLINE static string lower(const string &source, Encoding encoding);
|
INLINE static string lower(const string &source, Encoding encoding);
|
||||||
|
|
||||||
public:
|
// Direct support for wide-character strings. Now publishable with
|
||||||
// Direct support for wide-character strings. Not publishable for
|
// the new wstring support in interrogate.
|
||||||
// now (until we add support for wstring to interrogate).
|
|
||||||
INLINE void set_wtext(const wstring &wtext);
|
INLINE void set_wtext(const wstring &wtext);
|
||||||
INLINE const wstring &get_wtext() const;
|
INLINE const wstring &get_wtext() const;
|
||||||
INLINE void append_wtext(const wstring &text);
|
INLINE void append_wtext(const wstring &text);
|
||||||
|
@ -425,7 +425,7 @@ get_erase_event() const {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PGEntry::set_wtext
|
// Function: PGEntry::set_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Changes the text currently displayed within the
|
// Description: Changes the text currently displayed within the
|
||||||
// entry.
|
// entry.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -439,7 +439,7 @@ set_wtext(const wstring &wtext) {
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: PGEntry::get_wtext
|
// Function: PGEntry::get_wtext
|
||||||
// Access: Public
|
// Access: Published
|
||||||
// Description: Returns the text currently displayed within the
|
// Description: Returns the text currently displayed within the
|
||||||
// entry.
|
// entry.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
|
@ -120,7 +120,6 @@ PUBLISHED:
|
|||||||
INLINE string get_type_event() const;
|
INLINE string get_type_event() const;
|
||||||
INLINE string get_erase_event() const;
|
INLINE string get_erase_event() const;
|
||||||
|
|
||||||
public:
|
|
||||||
INLINE void set_wtext(const wstring &wtext);
|
INLINE void set_wtext(const wstring &wtext);
|
||||||
INLINE const wstring &get_wtext() const;
|
INLINE const wstring &get_wtext() const;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef TEXTASSEMBLER_H
|
#ifndef TEXTASSEMBLER_H
|
||||||
#define TEXTASSEMBLER_H
|
#define TEXTASSEMBLER_H
|
||||||
|
|
||||||
#ifndef CPPPARSER // interrogate has a bit of trouble with wstring.
|
#ifndef CPPPARSER // interrogate has a bit of trouble with wstring iterators.
|
||||||
|
|
||||||
#include "pandabase.h"
|
#include "pandabase.h"
|
||||||
|
|
||||||
|
@ -56,9 +56,6 @@ PUBLISHED:
|
|||||||
virtual void write(ostream &out, int indent_level) const;
|
virtual void write(ostream &out, int indent_level) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wstring wordwrap_to(const wstring &text, float wordwrap_width,
|
|
||||||
bool preserve_trailing_whitespace);
|
|
||||||
|
|
||||||
virtual bool get_glyph(int character, const TextGlyph *&glyph)=0;
|
virtual bool get_glyph(int character, const TextGlyph *&glyph)=0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1202,6 +1202,46 @@ calc_width(const string &line) const {
|
|||||||
return calc_width(decode_text(line));
|
return calc_width(decode_text(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::set_wtext
|
||||||
|
// Access: Published
|
||||||
|
// Description: Changes the text that is displayed under the
|
||||||
|
// TextNode, with a wide text. This automatically sets
|
||||||
|
// the string reported by get_text() to the 8-bit
|
||||||
|
// encoded version of the same string.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void TextNode::
|
||||||
|
set_wtext(const wstring &wtext) {
|
||||||
|
TextEncoder::set_wtext(wtext);
|
||||||
|
invalidate_with_measure();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::append_wtext
|
||||||
|
// Access: Published
|
||||||
|
// Description: Appends the indicates string to the end of the stored
|
||||||
|
// wide-character text.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void TextNode::
|
||||||
|
append_wtext(const wstring &wtext) {
|
||||||
|
TextEncoder::append_wtext(wtext);
|
||||||
|
invalidate_with_measure();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::get_wordwrapped_wtext
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns a wstring that represents the contents of the
|
||||||
|
// text, as it has been formatted by wordwrap rules.
|
||||||
|
// This will not contain any embedded special characters
|
||||||
|
// like \1 or \3.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE wstring TextNode::
|
||||||
|
get_wordwrapped_wtext() const {
|
||||||
|
check_measure();
|
||||||
|
return _assembler.get_wordwrapped_wtext();
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextNode::get_left
|
// Function: TextNode::get_left
|
||||||
// Access: Published
|
// Access: Published
|
||||||
@ -1345,46 +1385,6 @@ force_update() {
|
|||||||
check_rebuild();
|
check_rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: TextNode::set_wtext
|
|
||||||
// Access: Public
|
|
||||||
// Description: Changes the text that is displayed under the
|
|
||||||
// TextNode, with a wide text. This automatically sets
|
|
||||||
// the string reported by get_text() to the 8-bit
|
|
||||||
// encoded version of the same string.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void TextNode::
|
|
||||||
set_wtext(const wstring &wtext) {
|
|
||||||
TextEncoder::set_wtext(wtext);
|
|
||||||
invalidate_with_measure();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: TextNode::append_wtext
|
|
||||||
// Access: Public
|
|
||||||
// Description: Appends the indicates string to the end of the stored
|
|
||||||
// wide-character text.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE void TextNode::
|
|
||||||
append_wtext(const wstring &wtext) {
|
|
||||||
TextEncoder::append_wtext(wtext);
|
|
||||||
invalidate_with_measure();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: TextNode::get_wordwrapped_wtext
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns a wstring that represents the contents of the
|
|
||||||
// text, as it has been formatted by wordwrap rules.
|
|
||||||
// This will not contain any embedded special characters
|
|
||||||
// like \1 or \3.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE wstring TextNode::
|
|
||||||
get_wordwrapped_wtext() const {
|
|
||||||
check_measure();
|
|
||||||
return _assembler.get_wordwrapped_wtext();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextNode::invalidate_no_measure
|
// Function: TextNode::invalidate_no_measure
|
||||||
// Access: Private
|
// Access: Private
|
||||||
|
@ -146,6 +146,26 @@ calc_width(int character) const {
|
|||||||
return _assembler.calc_width(character, *this);
|
return _assembler.calc_width(character, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: TextNode::calc_width
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the width of a line of text of arbitrary
|
||||||
|
// characters. The line should not include the newline
|
||||||
|
// character or any embedded control characters like \1
|
||||||
|
// or \3.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
float TextNode::
|
||||||
|
calc_width(const wstring &line) const {
|
||||||
|
float width = 0.0f;
|
||||||
|
|
||||||
|
wstring::const_iterator si;
|
||||||
|
for (si = line.begin(); si != line.end(); ++si) {
|
||||||
|
width += calc_width(*si);
|
||||||
|
}
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextNode::output
|
// Function: TextNode::output
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -346,26 +366,6 @@ generate() {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: TextNode::calc_width
|
|
||||||
// Access: Public
|
|
||||||
// Description: Returns the width of a line of text of arbitrary
|
|
||||||
// characters. The line should not include the newline
|
|
||||||
// character or any embedded control characters like \1
|
|
||||||
// or \3.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
float TextNode::
|
|
||||||
calc_width(const wstring &line) const {
|
|
||||||
float width = 0.0f;
|
|
||||||
|
|
||||||
wstring::const_iterator si;
|
|
||||||
for (si = line.begin(); si != line.end(); ++si) {
|
|
||||||
width += calc_width(*si);
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: TextNode::get_unsafe_to_apply_attribs
|
// Function: TextNode::get_unsafe_to_apply_attribs
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -193,6 +193,13 @@ PUBLISHED:
|
|||||||
float calc_width(int character) const;
|
float calc_width(int character) const;
|
||||||
INLINE float calc_width(const string &line) const;
|
INLINE float calc_width(const string &line) const;
|
||||||
|
|
||||||
|
// Direct support for wide-character strings.
|
||||||
|
INLINE void set_wtext(const wstring &wtext);
|
||||||
|
INLINE void append_wtext(const wstring &text);
|
||||||
|
|
||||||
|
INLINE wstring get_wordwrapped_wtext() const;
|
||||||
|
float calc_width(const wstring &line) const;
|
||||||
|
|
||||||
virtual void output(ostream &out) const;
|
virtual void output(ostream &out) const;
|
||||||
virtual void write(ostream &out, int indent_level = 0) const;
|
virtual void write(ostream &out, int indent_level = 0) const;
|
||||||
|
|
||||||
@ -215,13 +222,6 @@ PUBLISHED:
|
|||||||
INLINE void force_update();
|
INLINE void force_update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Direct support for wide-character strings.
|
|
||||||
INLINE void set_wtext(const wstring &wtext);
|
|
||||||
INLINE void append_wtext(const wstring &text);
|
|
||||||
|
|
||||||
INLINE wstring get_wordwrapped_wtext() const;
|
|
||||||
float calc_width(const wstring &line) const;
|
|
||||||
|
|
||||||
// From parent class PandaNode
|
// From parent class PandaNode
|
||||||
virtual int get_unsafe_to_apply_attribs() const;
|
virtual int get_unsafe_to_apply_attribs() const;
|
||||||
virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs,
|
virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user