Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 82 lines (55 sloc) 2.314 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
/*
instrument-js.h - JavaScript instrumentation routines
Copyright (C) 2007, 2008 siliconforks.com

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef INSTRUMENT_JS_H_
#define INSTRUMENT_JS_H_

/* ISO C99 specifies that C++ code must define this to get UINT16_MAX etc. */
#define __STDC_LIMIT_MACROS
#include <stdint.h>

#include "stream.h"
#include "util.h"

#ifdef __cplusplus
extern "C" {
#endif

enum FileType {
  FILE_TYPE_JS,
  FILE_TYPE_HTML,
  FILE_TYPE_OTHER
};

extern bool jscoverage_mozilla;

void jscoverage_set_js_version(const char * version);

void jscoverage_init(void);

void jscoverage_cleanup(void);

void jscoverage_instrument_js(const char * id, const uint16_t * characters, size_t num_characters, Stream * output);

void jscoverage_copy_resources(const char * destination_directory);

typedef struct Coverage Coverage;

typedef struct FileCoverage {
  char * id;

  int * coverage_lines;
  char ** source_lines;

  /* SpiderMonkey uses uint32 for array lengths */
  uint32_t num_coverage_lines;
  uint32_t num_source_lines;
} FileCoverage;

Coverage * Coverage_new(void);

void Coverage_delete(Coverage * coverage);

typedef void (*CoverageForeachFunction) (const FileCoverage * file_coverage, int i, void * p);

void Coverage_foreach_file(Coverage * coverage, CoverageForeachFunction f, void * p);

int jscoverage_parse_json(Coverage * coverage, const uint8_t * data, size_t length) __attribute__((warn_unused_result));

void jscoverage_write_source(const char * id, const uint16_t * characters, size_t num_characters, Stream * output);

#ifdef __cplusplus
}
#endif

#endif /* INSTRUMENT_JS_H_ */
Something went wrong with that request. Please try again.