/*
* <!--
*
* **************************************************************
* This Java source has been automatically generated.
* MODIFICATIONS TO THIS SOURCE MAY BE OVERWRITTEN - DO NOT MODIFY THIS FILE
* **************************************************************
*
*
* This file (CAL_Encoding.java)
* was generated from CAL module: Cal.Experimental.Utilities.Encoding.
* The constants and methods provided are intended to facilitate accessing the
* Cal.Experimental.Utilities.Encoding module from Java code.
*
* Creation date: Thu Oct 11 13:57:02 PDT 2007
* --!>
*
*/
package org.openquark.cal.module.Cal.Experimental.Utilities;
import org.openquark.cal.compiler.ModuleName;
import org.openquark.cal.compiler.QualifiedName;
import org.openquark.cal.compiler.SourceModel;
/**
* This module implements simple string encoding and decoding based on Java's
* Charset class. It also provides a simple utility for encoding single code
* points in UTF-16.
* @author Malcolm Sharpe
*/
public final class CAL_Encoding {
public static final ModuleName MODULE_NAME =
ModuleName.make("Cal.Experimental.Utilities.Encoding");
/**
* This inner class (Functions) contains constants
* and methods related to binding to CAL functions in the Cal.Experimental.Utilities.Encoding module.
*/
public static final class Functions {
/**
* Convert a code point into a String, which is encoded as UTF-16.
* @param cp (CAL type: <code>Cal.Core.Prelude.Int</code>)
* @return (CAL type: <code>Cal.Core.Prelude.String</code>)
*/
public static final SourceModel.Expr codePointToUTF16(SourceModel.Expr cp) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.codePointToUTF16), cp});
}
/**
* @see #codePointToUTF16(org.openquark.cal.compiler.SourceModel.Expr)
* @param cp
* @return the SourceModel.Expr representing an application of codePointToUTF16
*/
public static final SourceModel.Expr codePointToUTF16(int cp) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.codePointToUTF16), SourceModel.Expr.makeIntValue(cp)});
}
/**
* Name binding for function: codePointToUTF16.
* @see #codePointToUTF16(org.openquark.cal.compiler.SourceModel.Expr)
*/
public static final QualifiedName codePointToUTF16 =
QualifiedName.make(CAL_Encoding.MODULE_NAME, "codePointToUTF16");
/**
* Decodes an array of bytes into a String using the specified character set.
* @param charsetName (CAL type: <code>Cal.Core.Prelude.String</code>)
* the name of the charset, as described in the documentation
* for Java's Charset class.
* @param bytes (CAL type: <code>Cal.Collections.Array.Array Cal.Core.Prelude.Byte</code>)
* the array of bytes to be decoded.
* @return (CAL type: <code>Cal.Core.Prelude.Maybe Cal.Core.Prelude.String</code>)
* Just the decoded String, or Nothing if the input is malformed.
*/
public static final SourceModel.Expr decode(SourceModel.Expr charsetName, SourceModel.Expr bytes) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.decode), charsetName, bytes});
}
/**
* @see #decode(org.openquark.cal.compiler.SourceModel.Expr, org.openquark.cal.compiler.SourceModel.Expr)
* @param charsetName
* @param bytes
* @return the SourceModel.Expr representing an application of decode
*/
public static final SourceModel.Expr decode(java.lang.String charsetName, SourceModel.Expr bytes) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.decode), SourceModel.Expr.makeStringValue(charsetName), bytes});
}
/**
* Name binding for function: decode.
* @see #decode(org.openquark.cal.compiler.SourceModel.Expr, org.openquark.cal.compiler.SourceModel.Expr)
*/
public static final QualifiedName decode =
QualifiedName.make(CAL_Encoding.MODULE_NAME, "decode");
/**
* Encodes a String into an array of bytes using the specified character set.
* @param charsetName (CAL type: <code>Cal.Core.Prelude.String</code>)
* the name of the charset, as described in the documentation
* for Java's Charset class.
* @param s (CAL type: <code>Cal.Core.Prelude.String</code>)
* the string to be encoded.
* @return (CAL type: <code>Cal.Collections.Array.Array Cal.Core.Prelude.Byte</code>)
* the bytes generated by encoding <code>s</code>.
*/
public static final SourceModel.Expr encode(SourceModel.Expr charsetName, SourceModel.Expr s) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.encode), charsetName, s});
}
/**
* @see #encode(org.openquark.cal.compiler.SourceModel.Expr, org.openquark.cal.compiler.SourceModel.Expr)
* @param charsetName
* @param s
* @return the SourceModel.Expr representing an application of encode
*/
public static final SourceModel.Expr encode(java.lang.String charsetName, java.lang.String s) {
return
SourceModel.Expr.Application.make(
new SourceModel.Expr[] {SourceModel.Expr.Var.make(Functions.encode), SourceModel.Expr.makeStringValue(charsetName), SourceModel.Expr.makeStringValue(s)});
}
/**
* Name binding for function: encode.
* @see #encode(org.openquark.cal.compiler.SourceModel.Expr, org.openquark.cal.compiler.SourceModel.Expr)
*/
public static final QualifiedName encode =
QualifiedName.make(CAL_Encoding.MODULE_NAME, "encode");
}
/**
* A hash of the concatenated JavaDoc for this class (including inner classes).
* This value is used when checking for changes to generated binding classes.
*/
public static final int javaDocHash = -180018033;
}