Main Page | Namespace List | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

nts.c File Reference


Detailed Description

Manipulate null-terminated (rchar) character strings.

There are three character string types in this program: null-terminated (rchar) strings ala 'C' language, UTF-8 (CONSTANT_Utf8_info) strings, and Unicode (jchar)[] strings.

Control

$URL: https://svn.apache.org/path/name/nts.c $ $Id: nts.c 0 09/28/2005 dlydick $

Copyright 2005 The Apache Software Foundation or its licensors, as applicable.

Licensed under the Apache License, Version 2.0 ("the License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.

Version:
$LastChangedRevision: 0 $
Date:
$LastChangedDate: 09/28/2005 $
Author:
$LastChangedBy: dlydick $ Original code contributed by Daniel Lydick on 09/28/2005.

Reference

Definition in file nts.c.

#include "arch.h"
#include <string.h>
#include "jvmcfg.h"
#include "cfmacros.h"
#include "classfile.h"
#include "nts.h"

Go to the source code of this file.

Functions

static void nts_c_dummy (void)
jvm_array_dim nts_get_prchar_arraydims (rchar *inbfr)
 Report the number of array dimensions prefixing a Java type string.
rcharnts_prchar2prchar_unformatted_classname (rchar *inbfr)
 Strip a null-terminated string of any class formatting it contains and return result in a heap-allocated buffer. When done with this result, perform HEAP_DATA_FREE(result) to return buffer to heap.
jshort nts_prchar2unicode (rchar *inbfr, jchar *outbfr)
 Convert null-terminated string into Unicode buffer.
cp_info_dupnts_prchar2utf (rchar *inbfr)
 Convert null-terminated string buffer into UTF8 buffer.
cp_info_dupnts_prchar2utf_classname (rchar *inbfr, jvm_array_dim arraydims)
 Format a string buffer into UTF8 buffer with Java class information, including number of array dimensions.
rboolean nts_prchar_isarray (rchar *inbfr)
 Test whether or not a Java type string is an array or not.
rboolean nts_prchar_isclassformatted (rchar *src)
 Verify if a null-terminated string contains CLASS formatting or not.
rboolean nts_prchar_isprimativeformatted (rchar *src)
 Verify if a null-terminated string contains PRIMATIVE formatting or not. May be prefixed with array specifiers. Everything after the base type character is ignored.

Variables

static char * nts_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/nts.c $ $Id: nts.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable."


Function Documentation

static void nts_c_dummy void   )  [static]
 

Definition at line 47 of file nts.c.

cp_info_dup* nts_prchar2utf rchar inbfr  ) 
 

Convert null-terminated string buffer into UTF8 buffer.

Parameters:
inbfr String (rchar *) string
Returns:
UTF8 structure containing length and rchar bfr (plus tag), but return in (cp_info_dup) for full proper word alignment. When done with the data, call HEAP_FREE_DATA() on it.
rc->bytes UTF8 version of inbfr string

rc->length Number of UTF8 bytes in rc->bytes

Definition at line 75 of file nts.c.

References CONSTANT_Utf8_info::bytes, CONSTANT_Utf8, cp_info_dup::empty, FILL_INFO_DUP0, FILL_INFO_DUP1, FILL_INFO_DUP2, HEAP_GET_DATA, CONSTANT_Utf8_info::length, PTR_THIS_CP_Utf8, rfalse, and CONSTANT_Utf8_info::tag.

Referenced by class_find_by_cp_entry(), and method_find_by_prchar().

jshort nts_prchar2unicode rchar inbfr,
jchar outbfr
 

Convert null-terminated string into Unicode buffer.

Parameters:
[in] inbfr Null-terminated string
[out] outbfr Buffer for resulting Unicode character string. This buffer will need to be the same size in Unicode (jchar) characters as inbfr is in native characters (rchar) since the conversion is simply putting the ASCII into the LS byte of the Unicode character.
Returns:
Two returns, one a buffer, the other a count:
*outbfr Unicode version of inbfr string in outbfr

charcnvcount (Return value of function) Number of Unicode characters in outbfr.

Definition at line 132 of file nts.c.

cp_info_dup* nts_prchar2utf_classname rchar inbfr,
jvm_array_dim  arraydims
 

Format a string buffer into UTF8 buffer with Java class information, including number of array dimensions.

Parameters:
inbfr String (rchar *) string
arraydims Number of array dimensions
Returns:
UTF8 structure containing length and rchar bfr (plus tag), but return in (cp_info_dup) for full proper word alignment. When done with the data, call HEAP_FREE_DATA() on it. With inbfr of some/path/name/filename, the result will be, with 3 array dimensions:
                 [[[Lsome/path/name/filename;\0

   

The string then has a \0 NUL character appended to it for strfn() convenience, but this is not reported in the UTF8 string length.

rc->bytes UTF8 version of inbfr string

rc->length Number of UTF8 bytes in rc->bytes < Reference to one array dimension

< an instance of class '/class/name'

< terminator for instance of class

Definition at line 193 of file nts.c.

References BASETYPE_CHAR_ARRAY, BASETYPE_CHAR_L, BASETYPE_CHAR_L_TERM, CONSTANT_Utf8_info::bytes, CONSTANT_Utf8, cp_info_dup::empty, FILL_INFO_DUP0, FILL_INFO_DUP1, FILL_INFO_DUP2, HEAP_GET_DATA, CONSTANT_Utf8_info::length, PTR_THIS_CP_Utf8, rfalse, and CONSTANT_Utf8_info::tag.

jvm_array_dim nts_get_prchar_arraydims rchar inbfr  ) 
 

Report the number of array dimensions prefixing a Java type string.

No overflow condition is reported since it is assumed that inbfr is a valid (rchar *) string. Notice that because this logic checks only for array specifiers and does not care about the rest of the string, it may be used to evaluate field descriptions, which will not contain any class formatting information.

If there is even a remote possibility that more than CONSTANT_MAX_ARRAY_DIMS dimensions will be found, compare the result of this function with the result of nts_prchar_isarray(). If there is a discrepancy, then there was an overflow here. Properly formatted class files will never contain code with this condition.

Note:
This function is identical to nts_get_prchararraydims() except that it works on (rchar *) instead of (CONSTANT_Utf8_info *).
Parameters:
inbfr (rchar *) string.
Returns:
Number of array dimensions in string. For example, this string contains three array dimensions:
                 [[[Lsome/path/name/filename;

   

The string does not have a \0 NUL character appended in this instance. If more than CONSTANT_MAX_ARRAY_DIMS are located, the result is zero-- no other error is reported.

< Reference to one array dimension

< Highest number of array dimensions

< Not stated in spec, but implied

Definition at line 293 of file nts.c.

Referenced by nts_prchar_isarray().

rboolean nts_prchar_isarray rchar inbfr  ) 
 

Test whether or not a Java type string is an array or not.

Parameters:
inbfr (rchar *) string.
Returns:
rtrue if this is an array specfication, else rfalse.
< Reference to one array dimension

Definition at line 336 of file nts.c.

References nts_get_prchar_arraydims().

rboolean nts_prchar_isprimativeformatted rchar src  ) 
 

Verify if a null-terminated string contains PRIMATIVE formatting or not. May be prefixed with array specifiers. Everything after the base type character is ignored.

Parameters:
src Pointer to null-terminated string.
Returns:
rtrue if string is formtted as LClassName; but rfalse otherwise, may also have array descriptor prefixed, thus [[LClassName;
rtrue if string is formatted as @ (where @ is any BASETYPE_CHAR_x character), rfalse otherwise. May also have array descriptor prefixed, thus [[@, eg, [[I or [[[[D

< Signed byte

< Unicode character

< Double-precision floating-point value

< Single-precision floating-point value

< Integer

< Long integer

< Signed short

< Boolean, true or false

Definition at line 368 of file nts.c.

References BASETYPE_CHAR_B, BASETYPE_CHAR_C, BASETYPE_CHAR_D, BASETYPE_CHAR_F, BASETYPE_CHAR_I, BASETYPE_CHAR_J, BASETYPE_CHAR_S, BASETYPE_CHAR_Z, rfalse, and rtrue.

rboolean nts_prchar_isclassformatted rchar src  ) 
 

Verify if a null-terminated string contains CLASS formatting or not.

Parameters:
src Pointer to null-terminated string.
Returns:
rtrue if string is formatted as LClasSName; but rfalse otherwise. May also have array descriptor prefixed, thus [[LClassName;
Note:
This function works just like utf_isclassformatted() except that it works on (rchar *) strings rather than on (CONSTANT_Utf8_info) strings.
< Reference to one array dimension

< an instance of class '/class/name'

< terminator for instance of class

< an instance of class '/class/name'

Definition at line 416 of file nts.c.

Referenced by utf_isarray(), and utf_pcfs_strcmp().

rchar* nts_prchar2prchar_unformatted_classname rchar inbfr  ) 
 

Strip a null-terminated string of any class formatting it contains and return result in a heap-allocated buffer. When done with this result, perform HEAP_DATA_FREE(result) to return buffer to heap.

Parameters:
inbfr Pointer to null-terminated string that is potentially formatted as LClassName; and which may also have array descriptor prefixed, thus [[LClassName;
Returns:
heap-allocated buffer containing ClassName with no formatting, regardless of input formatting or lack thereof.
Note:
This function works just like utf_utf2utf_unformatted_classname() except that it takes a (rchar *) string rather than a (CONSTANT_Utf8_info) string and returns a (rchar *).
< terminator for instance of class

Definition at line 498 of file nts.c.

References BASETYPE_CHAR_L_TERM.


Variable Documentation

char* nts_c_copyright = "\0" "$URL: https://svn.apache.org/path/name/nts.c $ $Id: nts.c 0 09/28/2005 dlydick $" " " "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." [static]
 

Definition at line 47 of file nts.c.


Generated on Fri Sep 30 18:50:11 2005 by  doxygen 1.4.4