mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
make V.js compile
This commit is contained in:
parent
3e52984e88
commit
c76d09f9a5
@ -46,6 +46,11 @@ fn types_to_c(types []Type, table &Table) string {
|
||||
sb.write(field.name)
|
||||
sb.writeln('; // $field.typ')
|
||||
}
|
||||
sb.writeln('
|
||||
constructor(obj) {
|
||||
obj && Object.assign(this, obj);
|
||||
}
|
||||
')
|
||||
sb.writeln('}\n')
|
||||
}
|
||||
return sb.str()
|
||||
|
@ -258,8 +258,9 @@ fn (v mut V) compile() {
|
||||
// TODO
|
||||
//cgen.genln('i64 total_m = 0; // For counting total RAM allocated')
|
||||
//if v.pref.is_test {
|
||||
$if !js {
|
||||
cgen.genln('int g_test_ok = 1; ')
|
||||
//}
|
||||
}
|
||||
if 'json' in v.table.imports {
|
||||
cgen.genln('
|
||||
#define js_get(object, key) cJSON_GetObjectItemCaseSensitive((object), (key))
|
||||
@ -474,7 +475,7 @@ fn (v &V) v_files_from_dir(dir string) []string {
|
||||
if file.ends_with('_mac.v') && v.os != .mac {
|
||||
continue
|
||||
}
|
||||
if file.ends_with('_js.v') {
|
||||
if file.ends_with('_js.v') && v.os != .js {
|
||||
continue
|
||||
}
|
||||
if file.ends_with('_nix.v') && (v.os == .windows || v.os == .msvc) {
|
||||
|
@ -309,10 +309,5 @@ pub fn (s string) hash() int {
|
||||
}
|
||||
|
||||
pub fn (s string) bytes() []byte {
|
||||
if s.len == 0 {
|
||||
return []byte
|
||||
}
|
||||
mut buf := [byte(0)].repeat2(s.len)
|
||||
C.memcpy(buf.data, s.str, s.len)
|
||||
return buf
|
||||
return []byte
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user