Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem "test-unit"
gem "rspec"
gem "rubocop"
gem "rubocop-rubycw"
gem "rubocop-on-rbs"
gem "rubocop-on-rbs", platform: :ruby # zlib transitive dep
gem "json"
gem "json-schema"
gem "goodcheck"
Expand All @@ -28,15 +28,15 @@ group :libs do
gem "abbrev"
gem "base64"
gem "bigdecimal"
gem "dbm"
gem "dbm", platform: :ruby
gem "mutex_m"
gem "nkf"
end

group :profilers do
# Performance profiling and benchmarking
gem 'stackprof'
gem 'memory_profiler'
gem 'stackprof', platform: :ruby
gem 'memory_profiler', platform: :ruby
gem 'benchmark-ips'
gem "ruby_memcheck", platform: :ruby
end
Expand Down
15 changes: 15 additions & 0 deletions include/rbs/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,19 @@
#define RBS_ATTRIBUTE_UNUSED
#endif

/***********************************************************************************************************************
* Exported functions from dynamic lib *
**********************************************************************************************************************/
#ifndef RBS_EXPORTED_FUNCTION
# ifdef RBS_EXPORT_SYMBOLS
# ifdef _WIN32
# define RBS_EXPORTED_FUNCTION __declspec(dllexport) extern
# else
# define RBS_EXPORTED_FUNCTION __attribute__((__visibility__("default"))) extern
# endif
# else
# define RBS_EXPORTED_FUNCTION
# endif
#endif

#endif
4 changes: 4 additions & 0 deletions include/rbs/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ rbs_lexer_t *rbs_lexer_new(rbs_allocator_t *, rbs_string_t string, const rbs_enc
* rbs_parser_new(buffer, string, encoding, 0, 1);
* ```
* */
RBS_EXPORTED_FUNCTION
rbs_parser_t *rbs_parser_new(rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
RBS_EXPORTED_FUNCTION
void rbs_parser_free(rbs_parser_t *parser);

/**
Expand All @@ -126,8 +128,10 @@ rbs_ast_comment_t *rbs_parser_get_comment(rbs_parser_t *parser, int subject_line

void rbs_parser_set_error(rbs_parser_t *parser, rbs_token_t tok, bool syntax_error, const char *fmt, ...) RBS_ATTRIBUTE_FORMAT(4, 5);

RBS_EXPORTED_FUNCTION
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type, bool void_allowed, bool self_allowed, bool classish_allowed);
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type, bool require_eof, bool classish_allowed);
RBS_EXPORTED_FUNCTION
bool rbs_parse_signature(rbs_parser_t *parser, rbs_signature_t **signature);

bool rbs_parse_type_params(rbs_parser_t *parser, bool module_type_params, rbs_node_list_t **params);
Expand Down
2 changes: 2 additions & 0 deletions include/rbs/util/rbs_constant_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef struct {
} rbs_constant_pool_t;

// A global constant pool for storing permenant keywords, such as the names of location children in `parser.c`.
RBS_EXPORTED_FUNCTION
extern rbs_constant_pool_t *RBS_GLOBAL_CONSTANT_POOL;

/**
Expand All @@ -91,6 +92,7 @@ extern rbs_constant_pool_t *RBS_GLOBAL_CONSTANT_POOL;
* @param capacity The initial capacity of the pool.
* @return Whether the initialization succeeded.
*/
RBS_EXPORTED_FUNCTION
bool rbs_constant_pool_init(rbs_constant_pool_t *pool, uint32_t capacity);

/**
Expand Down
1 change: 1 addition & 0 deletions include/rbs/util/rbs_encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ extern const rbs_encoding_t rbs_encodings[RBS_ENCODING_MAXIMUM];
* @param end A pointer to the last byte of the name.
* @returns A pointer to the encoding struct if one is found, otherwise NULL.
*/
RBS_EXPORTED_FUNCTION
const rbs_encoding_t *rbs_encoding_find(const uint8_t *start, const uint8_t *end);

#endif
7 changes: 6 additions & 1 deletion lib/rbs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
require "rbs/type_alias_regularity"
require "rbs/collection"

require "rbs_extension"
begin
require "rbs_extension"
rescue LoadError
require "rbs/ffi/parser"
require "rbs/ffi/location"
end
require "rbs/parser_aux"
require "rbs/location_aux"

Expand Down
49 changes: 49 additions & 0 deletions lib/rbs/ffi/location.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# frozen_string_literal: true

module RBS
class Location
def initialize(buffer, start_pos, end_pos)

end

def initialize_copy(other)

end

def buffer

end

def _start_pos

end

def _end_pos

end

def _add_required_child(name, start, end_pos)

end

def _add_optional_child(name, start, end_pos)

end

def _add_optional_no_child(name)

end

def _optional_keys

end

def _required_keys

end

def [](name)

end
end
end
Loading
Loading