_gaq.push(['_trackEvent', 'Bug', 'No Webworkers', $("#console").text()])
Module = Pep8Module
try {
- run_analysis = Module.cwrap('pep8analysis_web___NativeString_run_analysis', null, ['string'])
+ run_analysis = Module.cwrap('pep8analysis_web___CString_run_analysis', null, ['string'])
run_analysis(input)
complete()
'TOTAL_MEMORY': 512000000
}
importScripts("pep8analysis.js")
-run_analysis = Module.cwrap('pep8analysis_web___NativeString_run_analysis', null, ['string'])
+run_analysis = Module.cwrap('pep8analysis_web___CString_run_analysis', null, ['string'])
function show_graph(data) {
postMessage({'type':"show_graph", 'data': data})
private fun kind_char: Byte do return 0x06u8
private fun kind_float: Byte do return 0x07u8
private fun kind_string: Byte do return 0x08u8
-private fun kind_native_string: Byte do return 0x09u8
+private fun kind_c_string: Byte do return 0x09u8
private fun kind_flat_array: Byte do return 0x0Au8
private fun new_object_end: Byte do return 0x00u8
return bf.to_s_with_length(ln)[0]
end
if kind == kind_string then return stream.read_block
- if kind == kind_native_string then return stream.read_block.to_cstring
+ if kind == kind_c_string then return stream.read_block.to_cstring
if kind == kind_flat_array then
# An array
redef class CString
redef fun serialize_to_binary(v)
do
- v.stream.write_byte kind_native_string
+ v.stream.write_byte kind_c_string
v.stream.write_block to_s
end
end
end
redef fun to_s do
- var ns = native.to_native_string
+ var ns = native.to_c_string
var res = ns.to_s_with_copy
ns.free # manual free of gc allocated CString
return res
# The `bson_as_json()` function shall encode bson as a JSON encoded UTF-8 string.
# The caller is responsible for freeing the resulting UTF-8 encoded string
# by calling `bson_free()` with the result.
- fun to_native_string: CString `{ return bson_as_json(self, NULL); `}
+ fun to_c_string: CString `{ return bson_as_json(self, NULL); `}
# Wrapper for `bson_destroy()`.
#
do
assert statement_closed: statement.is_open
- var native_string = statement.native_statement.column_text(index)
- if native_string.address_is_null then return ""
- return native_string.to_s_with_copy
+ var c_string = statement.native_statement.column_text(index)
+ if c_string.address_is_null then return ""
+ return c_string.to_s_with_copy
end
# Get this entry as `Blob`
end
# Generates a CString instance fully escaped in C-style \xHH fashion
- fun native_string_instance(ns: CString, len: Int): RuntimeVariable do
- var mtype = mmodule.native_string_type
+ fun c_string_instance(ns: CString, len: Int): RuntimeVariable do
+ var mtype = mmodule.c_string_type
var nat = new_var(mtype)
var byte_esc = new Buffer.with_cap(len * 4)
for i in [0 .. len[ do
self.add("if (likely({name}!=NULL)) \{")
self.add("{res} = {name};")
self.add("\} else \{")
- var native_mtype = mmodule.native_string_type
+ var native_mtype = mmodule.c_string_type
var nat = self.new_var(native_mtype)
self.add("{nat} = \"{string.escape_to_c}\";")
var byte_length = self.int_instance(string.byte_length)
var s = v.string_instance(value)
if is_string then return s
if is_bytestring then
- var ns = v.native_string_instance(bytes.items, bytes.length)
+ var ns = v.c_string_instance(bytes.items, bytes.length)
var ln = v.int_instance(bytes.length)
var cs = to_bytes_with_copy
assert cs != null
v.native_array_set(a, i, e)
end
- # Fast join the native string to get the result
+ # Fast join the C string to get the result
var res = v.send(v.get_property("native_to_s", a.mtype), [a])
assert res != null
fun instance=(value: Instance) is light_ffi `{ self->value_Pointer = value; `}
# The `CString` held by this cell
- fun native_string: CString `{ return (char*)self->value_Pointer; `}
+ fun c_string: CString `{ return (char*)self->value_Pointer; `}
# Set the content of this cell according to `static_type`
#
else if name == "Float" then
return v.float_instance(self.float)
else if name == "CString" then
- var instance = new PrimitiveInstance[CString](static_type, self.native_string)
+ var instance = new PrimitiveInstance[CString](static_type, self.c_string)
v.init_instance_primitive instance
return instance
else if static_type isa MClassType and static_type.mclass.kind == extern_kind then
end
end
- # Return a new native string initialized with `txt`
- fun native_string_instance(txt: String): Instance
+ # Return a new C string initialized with `txt`
+ fun c_string_instance(txt: String): Instance
do
- var instance = native_string_instance_len(txt.byte_length+1)
+ var instance = c_string_instance_len(txt.byte_length+1)
var val = instance.val
val[txt.byte_length] = 0u8
txt.to_cstring.copy_to(val, txt.byte_length, 0, 0)
return instance
end
- # Return a new native string initialized with `txt`
- fun native_string_instance_from_ns(txt: CString, len: Int): Instance
+ # Return a new C string initialized with `txt`
+ fun c_string_instance_from_ns(txt: CString, len: Int): Instance
do
- var instance = native_string_instance_len(len)
+ var instance = c_string_instance_len(len)
var val = instance.val
txt.copy_to(val, len, 0, 0)
return instance
end
- # Return a new native string initialized of `length`
- fun native_string_instance_len(length: Int): PrimitiveInstance[CString]
+ # Return a new C string initialized of `length`
+ fun c_string_instance_len(length: Int): PrimitiveInstance[CString]
do
var val = new CString(length)
- var t = mainmodule.native_string_type
+ var t = mainmodule.c_string_type
var instance = new PrimitiveInstance[CString](t, val)
init_instance_primitive(instance)
return instance
# Return a new String instance for `txt`
fun string_instance(txt: String): Instance
do
- var nat = native_string_instance(txt)
+ var nat = c_string_instance(txt)
var res = self.send(self.force_get_primitive_method("to_s_full", nat.mtype), [nat, self.int_instance(txt.byte_length), self.int_instance(txt.length)])
assert res != null
return res
else if pname == "native_class_name" then
var recv = args.first
var txt = recv.mtype.to_s
- return v.native_string_instance(txt)
+ return v.c_string_instance(txt)
else if pname == "==" then
# == is correctly redefined for instances
return v.bool_instance(args[0] == args[1])
else if pname == "is_same_instance" then
return v.bool_instance(args[0].eq_is(args[1]))
else if pname == "class_inheritance_metamodel_json" then
- return v.native_string_instance(v.mainmodule.flatten_mclass_hierarchy.to_thin_json)
+ return v.c_string_instance(v.mainmodule.flatten_mclass_hierarchy.to_thin_json)
else if pname == "exit" then
exit(args[1].to_i)
abort
end
else if cname == "CString" then
if pname == "new" then
- return v.native_string_instance_len(args[1].to_i)
+ return v.c_string_instance_len(args[1].to_i)
end
var recvval = args.first.val.as(CString)
if pname == "[]" then
return v.int_instance(recvval.atoi)
else if pname == "fast_cstring" then
var ns = recvval.fast_cstring(args[1].to_i)
- return v.native_string_instance(ns.to_s)
+ return v.c_string_instance(ns.to_s)
else if pname == "fetch_4_chars" then
return v.int_instance(args[0].val.as(CString).fetch_4_chars(args[1].to_i))
else if pname == "fetch_4_hchars" then
return v.int_instance(v.arguments.length)
else if pname == "native_argv" then
var txt = v.arguments[args[1].to_i]
- return v.native_string_instance(txt)
+ return v.c_string_instance(txt)
else if pname == "lexer_goto" then
return v.int_instance(lexer_goto(args[1].to_i, args[2].to_i))
else if pname == "lexer_accept" then
var s = v.string_instance(value)
if is_string then return s
if is_bytestring then
- var ns = v.native_string_instance_from_ns(bytes.items, bytes.length)
+ var ns = v.c_string_instance_from_ns(bytes.items, bytes.length)
var ln = v.int_instance(bytes.length)
var prop = to_bytes_with_copy
assert prop != null
var string_type: MClassType = self.get_primitive_class("String").mclass_type is lazy
# The primitive type `CString`
- var native_string_type: MClassType = self.get_primitive_class("CString").mclass_type is lazy
+ var c_string_type: MClassType = self.get_primitive_class("CString").mclass_type is lazy
# A primitive type of `Array`
fun array_type(elt_type: MType): MClassType do return array_class.get_mtype([elt_type])
redef class AStringFormExpr
redef fun accept_rapid_type_visitor(v)
do
- var native = v.analysis.mainmodule.native_string_type
+ var native = v.analysis.mainmodule.c_string_type
v.add_type(native)
var prop = v.get_method(native, "to_s_full")
v.add_monomorphic_send(native, prop)
var mclass = v.get_mclass(self, "String")
if mclass == null then return # Forward error
if is_bytestring then
- to_bytes_with_copy = v.get_method(self, v.mmodule.native_string_type, "to_bytes_with_copy", false)
+ to_bytes_with_copy = v.get_method(self, v.mmodule.c_string_type, "to_bytes_with_copy", false)
mclass = v.get_mclass(self, "Bytes")
else if is_re then
to_re = v.get_method(self, mclass.mclass_type, "to_re", false)