Skip to content

Commit

Permalink
Merge pull request #2102 from Shopify/templated-code-gen2
Browse files Browse the repository at this point in the history
Clean up temporary workarounds from templated code
  • Loading branch information
soutaro authored Nov 28, 2024
2 parents 7c561d0 + d56b699 commit 6c77c6b
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 1,571 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ lib/**/*.bundle
lib/**/*.so
lib/**/*.dll
doc/

include/rbs/constants.h
include/rbs/ruby_objs.h
src/constants.c
src/ruby_objs.c

**/*.gem
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ task :confirm_annotation do
end

task :templates do
sh "bundle exec ruby templates/template.rb ext/rbs_extension/constants.h"
sh "bundle exec ruby templates/template.rb ext/rbs_extension/ruby_objs.h"
sh "bundle exec ruby templates/template.rb ext/rbs_extension/constants.c"
sh "bundle exec ruby templates/template.rb ext/rbs_extension/ruby_objs.c"
sh "bundle exec ruby templates/template.rb include/rbs/constants.h"
sh "bundle exec ruby templates/template.rb include/rbs/ruby_objs.h"
sh "bundle exec ruby templates/template.rb src/constants.c"
sh "bundle exec ruby templates/template.rb src/ruby_objs.c"
end

task :compile => "ext/rbs_extension/lexer.c"
Expand Down
12 changes: 0 additions & 12 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ nodes:
- name: RBS::Types::Alias
fields:
- name: name
c_name: typename # Temporary name to match existing C code. Will be removed in next PR.
- name: args
- name: location
- name: RBS::Types::Bases::Any
Expand Down Expand Up @@ -247,25 +246,18 @@ nodes:
- name: RBS::Types::ClassInstance
fields:
- name: name
c_name: typename # Temporary name to match existing C code. Will be removed in next PR.
- name: args
c_name: type_args # Temporary name to match existing C code. Will be removed in next PR.
- name: location
- name: RBS::Types::ClassSingleton
fields:
- name: name
c_name: typename # Temporary name to match existing C code. Will be removed in next PR.
- name: location
- name: RBS::Types::Function
fields:
- name: required_positionals
c_name: required_positional_params # Temporary name to match existing C code. Will be removed in next PR.
- name: optional_positionals
c_name: optional_positional_params # Temporary name to match existing C code. Will be removed in next PR.
- name: rest_positionals
c_name: rest_positional_params # Temporary name to match existing C code. Will be removed in next PR.
- name: trailing_positionals
c_name: trailing_positional_params # Temporary name to match existing C code. Will be removed in next PR.
- name: required_keywords
- name: optional_keywords
- name: rest_keywords
Expand All @@ -278,9 +270,7 @@ nodes:
- name: RBS::Types::Interface
fields:
- name: name
c_name: typename # Temporary name to match existing C code. Will be removed in next PR.
- name: args
c_name: type_args # Temporary name to match existing C code. Will be removed in next PR.
- name: location
- name: RBS::Types::Intersection
fields:
Expand All @@ -297,14 +287,12 @@ nodes:
- name: RBS::Types::Proc
fields:
- name: type
c_name: function # Temporary name to match existing C code. Will be removed in next PR.
- name: block
- name: location
- name: self_type
- name: RBS::Types::Record
fields:
- name: all_fields
c_name: fields # Temporary name to match existing C code. Will be removed in next PR.
- name: location
- name: RBS::Types::Tuple
fields:
Expand Down
155 changes: 0 additions & 155 deletions ext/rbs_extension/constants.c

This file was deleted.

82 changes: 0 additions & 82 deletions ext/rbs_extension/constants.h

This file was deleted.

10 changes: 10 additions & 0 deletions ext/rbs_extension/extconf.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
require 'mkmf'

$INCFLAGS << " -I$(top_srcdir)" if $extmk
$INCFLAGS << " -I$(srcdir)/../../include"

$VPATH << "$(srcdir)/../../src"
$VPATH << "$(srcdir)/ext/rbs_extension"

root_dir = File.expand_path('../../../', __FILE__)
$srcs = Dir.glob("#{root_dir}/src/*.c") +
Dir.glob("#{root_dir}/ext/rbs_extension/*.c")

append_cflags ['-std=gnu99']
create_makefile 'rbs_extension'
3 changes: 1 addition & 2 deletions ext/rbs_extension/rbs_extension.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include "ruby/re.h"
#include "ruby/encoding.h"

#include "rbs.h"
#include "lexer.h"
#include "parser.h"
#include "constants.h"
#include "ruby_objs.h"

/**
* Receives `parserstate` and `range`, which represents a string token or symbol token, and returns a string VALUE.
Expand Down
Loading

0 comments on commit 6c77c6b

Please sign in to comment.