pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2014-08-18
2014-08-18 15:38:59 by Martin Nilsson <nilsson@opera.com>
68ec3f29a244c8dd4c94d6fde8133d2d5697428c (
46
lines) (+
21
/-
25
)
[
Show
|
Annotate
]
Branch:
8.0
Improved cast.
452:
} PIKEFUN mixed cast( string to )
+
flags ID_PROTECTED;
{
-
struct pike_string *s_string, *s_int;
-
MAKE_CONST_STRING(s_int, "int");
-
MAKE_CONST_STRING(s_string, "string");
-
if( to ==
s
_int )
+
if( to ==
literal
_int
_string
)
{ f_TM_unix_time(0); return; }
-
if( to ==
s
_string )
+
if( to ==
literal
_string
_string
)
{ f_TM_asctime(0); return; }
-
Pike
_
error
(
"Does
not
know
how
to
cast
to
%s\n",
to->str
);
+
pop
_
stack
(
);
+
push_undefined(
);
} /*! @decl string zone
3074:
*! a @expr{string@} and an @expr{int@}. */ PIKEFUN mixed cast( string type )
+
flags ID_PROTECTED;
{
-
struct pike_string *string_t;
-
struct pike_string *int_t;
-
MAKE_CONST_STRING( string_t, "string" );
-
MAKE_CONST_STRING( int_t, "int" );
-
-
if( type == string_
t
)
+
if( type ==
literal_
string_
string
)
{
-
pop_
n_elems
(
args
);
+
pop_
stack
();
if( Pike_fp->current_object->refs != 1 ) f_Buffer_get_copy( 0 ); else
3090:
return; }
-
if( type == int_
t
)
+
if( type ==
literal_
int_
string
)
{ struct Buffer_struct *str = THIS; pop_stack();
3101:
o_cast_to_int( ); return; }
-
Pike
_
error
(
"Cannot
cast
to
%S\n",
type
);
+
+
pop
_
stack
(
);
+
push_undefined(
);
} /*! @decl String.Buffer `+( string|String.Buffer what )
5493:
PIKEFUN mixed cast(string type) flags ID_PROTECTED; {
-
if (
type
==
MK_STRING("array"))
{
-
pop
_
n
_
elems(args
)
;
+
pop_stack();
/*
type
as
at
least one more reference. */
+
if
(type
==
literal
_
array
_
string
)
apply_current(f_List_cq__values_fun_num, 0);
-
}
else if (type ==
MK
_
STRING("
object
")) {
-
pop
_
n_elems(args
)
;
+
else if (type ==
literal
_object_
string
)
ref_push_object(Pike_fp->current_object);
-
}
else
{
-
Pike
_
error
(
"Cannot cast to %o.\n", Pike_sp-1
);
+
else
+
push
_
undefined
();
}
-
}
+
/*! @decl mixed `[](mixed key) */