pike.git
/
src
/
post_modules
/
Nettle
/
hash.H
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/post_modules/Nettle/hash.H:1:
/* -*- C -*- * * Cmod header-file acting as a template for the hash classes. */
-
DOCSTART() @class
cmod_CONCAT_EVAL(
PIKE_NAME
, _Info)
+
DOCSTART() @class PIKE_NAME
*!
-
*!
Internal
mixin
class,
intended
to
be multiply inherited
-
*!
together with HashInfo.
+
*!
Implementation
of
the
PIKE_NAME
hash
algorithm.
+
*!
DOCEND()
-
PIKECLASS
cmod_CONCAT_EVAL(
PIKE_NAME
, _Info)
+
PIKECLASS PIKE_NAME
{
-
+
DOCSTART() @decl inherit Hash
+
DOCEND()
+
INHERIT Hash;
+
INIT {
-
struct
HashInfo
_struct *
HashInfo
-
= (struct
HashInfo
_struct *) get_storage(Pike_fp->current_object,
-
HashInfo
_program);
+
/* FIXME: Ought to traverse the inherit graph for
+
* the current program.
+
*/
+
struct
Hash
_struct *
Hash
+
= (struct
Hash
_struct *) get_storage(Pike_fp->current_object,
+
Hash
_program);
-
werror(cmod_STRFY_EVAL(PIKE_NAME) "
_Info
->INIT\n");
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "->INIT\n");
-
if (
HashInfo
&& !
HashInfo
->meta)
-
HashInfo
->meta = &cmod_CONCAT_EVAL(nettle_, NETTLE_NAME);
+
if (
Hash
&& !
Hash
->meta)
+
Hash
->meta = &cmod_CONCAT_EVAL(nettle_, NETTLE_NAME);
else { /* Can't call Pike_error here. * Pike_error("Can't initialize this object.\n"); */
-
werror(cmod_STRFY_EVAL(PIKE_NAME) "
_Info
->INIT failed\n");
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "->INIT failed\n");
} }
-
}
+
-
DOCSTART()
@endclass
cmod_CONCAT_EVAL(PIKE_NAME, _Info)
-
DOCEND()
-
-
DOCSTART() @class
cmod_CONCAT_EVAL(PIKE_NAME, _
State
)
+
DOCSTART() @class State
*! *! State for PIKE_NAME hashing.
-
+
*!
DOCEND()
-
PIKECLASS
cmod
_
CONCAT
_
EVAL(PIKE
_
NAME,
_
State)
+
PIKECLASS
State
+
program
_
flags PROGRAM
_
NEEDS
_
PARENT|PROGRAM
_
USES_PARENT;
{
-
INHERIT
cmod
_
CONCAT
_
EVAL
(
PIKE
_
NAME
, _
Info
);
-
INHERIT
HashState
;
+
EXTRA
+
{
+
/* Perform an inherit of the HashState class that our parent
+
* contains via its inherit of HashInfo.
+
*/
+
struct program *parent
_
prog = Pike
_
compiler->previous->new_program;
+
struct object *parent_obj = Pike_compiler->previous->fake_object;
+
int parent_State_fun_num =
+
really_low_find_shared_string_identifier
(
MK
_
STRING("State")
,
+
parent
_
prog,
+
SEE_PROTECTED|SEE_PRIVATE
);
+
if (parent_State_fun_num >= 0) {
+
struct program *parent_State_prog =
+
low_program_from_function(parent_obj, parent_State_fun_num)
;
+
if (parent_State_prog) {
+
DOCSTART() @decl inherit Hash::State
+
*!
+
*! Inherits @[Nettle.Hash.State] via
+
*! the inherit of @[Nettle.Hash] in our
+
*! parent (@[Hash]).
+
DOCEND()
+
low_inherit(parent_State_prog, 0,
+
parent_State_fun_num +
+
parent_prog->inherits[1].identifier_level,
+
1 + 42, 0, NULL);
+
}
+
}
+
}
+
CVAR struct cmod_CONCAT_EVAL(NETTLE_NAME, _ctx) NETTLE_NAME; INIT {
-
struct HashState_struct
*
instance
-
=
(struct
HashState_struct
*)
get_storage(Pike_fp->current_object,
-
HashState
_program);
-
werror(cmod_STRFY_EVAL(PIKE_NAME) "
_
State->INIT\n");
+
/
*
FIXME:
Ought
to
traverse
the
inherit
graph
for
+
*
the
current
program.
+
*/
+
struct
Hash_State_struct
*instance
+
=
(struct
Hash_State_struct
*)
+
get_storage(Pike_fp->current_object,
Hash
_
State_
program);
+
werror(cmod_STRFY_EVAL(PIKE_NAME) "
.
State->INIT\n");
assert(instance); cmod_CONCAT_EVAL(NETTLE_NAME, _init)(&THIS->NETTLE_NAME); instance->ctx = &THIS->NETTLE_NAME; } }
-
DOCSTART() @endclass
cmod_CONCAT_EVAL(PIKE_NAME, _
State
)
+
DOCSTART() @endclass State
DOCEND()
-
+
+
}
+
DOCSTART() @endclass PIKE_NAME
+
DOCEND()
+