Skip to content

Commit

Permalink
intellisense: Convert to *mut ComPtr<> and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Oct 28, 2020
1 parent 54cf0c5 commit b7e97cc
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 136 deletions.
90 changes: 45 additions & 45 deletions src/intellisense/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::os::{BSTR, HRESULT, LPCSTR, LPSTR};
pub(crate) use crate::unknown::IDxcUnknownShim;
use bitflags::bitflags;
use com_rs::{com_interface, iid, IUnknown};
use com_rs::{com_interface, iid, ComPtr, IUnknown};

bitflags! {
pub struct DxcGlobalOptions : u32 {
Expand Down Expand Up @@ -364,13 +364,13 @@ com_interface! {
vtable: IDxcDiagnosticVtbl,
fn format_diagnostic(options: DxcDiagnosticDisplayOptions, result: *mut LPSTR) -> HRESULT;
fn get_severity(result: *mut DxcDiagnosticSeverity) -> HRESULT;
fn get_location(result: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_location(result: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_spelling(result: *mut LPSTR) -> HRESULT;
fn get_category_text(result: *mut LPSTR) -> HRESULT;
fn get_num_ranges(result: *mut u32) -> HRESULT;
fn get_range_at(index: u32, result: *mut *mut IDxcSourceRange) -> HRESULT;
fn get_range_at(index: u32, result: *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_num_fix_its(result: *mut u32) -> HRESULT;
fn get_fix_it_at(index: u32, replacement_range: *mut *mut IDxcSourceRange, text: *mut LPSTR) -> HRESULT;
fn get_fix_it_at(index: u32, replacement_range: *mut ComPtr<IDxcSourceRange>, text: *mut LPSTR) -> HRESULT;
}
}

Expand All @@ -379,9 +379,9 @@ com_interface! {
interface IDxcInclusion: IDxcUnknownShim, IUnknown {
iid: IID_IDxcInclusion,
vtable: IDxcInclusionVtbl,
fn get_included_file(result: *mut *mut IDxcFile) -> HRESULT;
fn get_included_file(result: *mut ComPtr<IDxcFile>) -> HRESULT;
fn get_stack_length(result: *mut u32) -> HRESULT;
fn get_stack_item(index: u32, result: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_stack_item(index: u32, result: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
}
}

Expand All @@ -391,8 +391,8 @@ com_interface! {
iid: IID_IDxcToken,
vtable: IDxcTokenVtbl,
fn get_kind(value: *mut DxcTokenKind) -> HRESULT;
fn get_location(value: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_extent(value: *mut *mut IDxcSourceRange) -> HRESULT;
fn get_location(value: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_extent(value: *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_spelling(value: *mut LPSTR) -> HRESULT;
}
}
Expand All @@ -414,7 +414,7 @@ com_interface! {
iid: IID_IDxcSourceLocation,
vtable: IDxcSourceLocationVtbl,
fn is_equal_to(other: *const IDxcSourceLocation, result: *mut bool) -> HRESULT;
fn get_spelling_location(file: *mut *mut IDxcFile, line: *mut u32, col: *mut u32, offset: *mut u32) -> HRESULT;
fn get_spelling_location(file: *mut ComPtr<IDxcFile>, line: *mut u32, col: *mut u32, offset: *mut u32) -> HRESULT;
fn is_null(result: *mut bool) -> HRESULT;
}
}
Expand All @@ -425,8 +425,8 @@ com_interface! {
iid: IID_IDxcSourceRange,
vtable: IDxcSourceRangeVtbl,
fn is_null(value: *mut bool) -> HRESULT;
fn get_start(value: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_end(value: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_start(value: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_end(value: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_offsets(start_offset: *mut u32, end_offset: *mut u32) -> HRESULT;
}
}
Expand All @@ -436,27 +436,27 @@ com_interface! {
interface IDxcCursor: IDxcUnknownShim, IUnknown {
iid: IID_IDxcCursor,
vtable: IDxcCursorVtbl,
fn get_extent(range: *mut *mut IDxcSourceRange) -> HRESULT;
fn get_location(result: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_extent(range: *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_location(result: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_kind(result: *mut DxcCursorKind) -> HRESULT;
fn get_kind_flags(result: *mut DxcCursorKindFlags) -> HRESULT;
fn get_semantic_parent(result: *mut*mut IDxcCursor) -> HRESULT;
fn get_lexical_parent(result:*mut*mut IDxcCursor) -> HRESULT;
fn get_cursor_type(result:*mut*mut IDxcType) -> HRESULT;
fn get_num_arguments(result:*mut i32) -> HRESULT;
fn get_argument_at(index: i32, result: *mut *mut IDxcCursor) -> HRESULT;
fn get_referenced_cursor(result:*mut *mut IDxcCursor) -> HRESULT;
fn get_definition_cursor(result:*mut *mut IDxcCursor) -> HRESULT;
fn find_references_in_file(file: *const IDxcFile, skip: u32, top:u32, result_length: *mut u32, result: *mut *mut *mut IDxcCursor) -> HRESULT;
fn get_semantic_parent(result: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_lexical_parent(result: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_cursor_type(result: *mut ComPtr<IDxcType>) -> HRESULT;
fn get_num_arguments(result: *mut i32) -> HRESULT;
fn get_argument_at(index: i32, result: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_referenced_cursor(result: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_definition_cursor(result: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn find_references_in_file(file: *const IDxcFile, skip: u32, top:u32, result_length: *mut u32, result: *mut *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_spelling(result: *mut LPSTR) -> HRESULT;
fn is_equal_to(other: *const IDxcCursor, result:*mut bool) -> HRESULT;
fn is_null(result:*mut bool) -> HRESULT;
fn is_definition(result:*mut bool) -> HRESULT;
fn get_display_name(result:*mut BSTR) -> HRESULT;
fn get_qualified_name(include_template_args:bool, result:*mut BSTR) -> HRESULT;
fn get_formatted_name(formatting: DxcCursorFormatting, result:*mut BSTR) -> HRESULT;
fn get_children(skip: u32, top: u32, result_length:*mut u32, result:*mut*mut*mut IDxcCursor) -> HRESULT;
fn get_snapped_child(location: *const IDxcSourceLocation, result:*mut*mut IDxcCursor) -> HRESULT;
fn is_equal_to(other: *const IDxcCursor, result: *mut bool) -> HRESULT;
fn is_null(result: *mut bool) -> HRESULT;
fn is_definition(result: *mut bool) -> HRESULT;
fn get_display_name(result: *mut BSTR) -> HRESULT;
fn get_qualified_name(include_template_args:bool, result: *mut BSTR) -> HRESULT;
fn get_formatted_name(formatting: DxcCursorFormatting, result: *mut BSTR) -> HRESULT;
fn get_children(skip: u32, top: u32, result_length: *mut u32, result: *mut *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_snapped_child(location: *const IDxcSourceLocation, result: *mut ComPtr<IDxcCursor>) -> HRESULT;
}
}

Expand Down Expand Up @@ -486,21 +486,21 @@ com_interface! {
interface IDxcTranslationUnit: IDxcUnknownShim, IUnknown {
iid: IID_IDxcTranslationUnit,
vtable: IDxcTranslationUnitVtbl,
fn get_cursor(cursor: *mut *mut IDxcCursor) -> HRESULT;
fn tokenize(range: *const IDxcSourceRange, tokens: *mut *mut *mut IDxcToken, token_count: *mut u32) -> HRESULT;
fn get_location( file: *mut IDxcFile, line: u32, column: u32, result: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_cursor(cursor: *mut ComPtr<IDxcCursor>) -> HRESULT;
fn tokenize(range: *const IDxcSourceRange, tokens: *mut *mut ComPtr<IDxcToken>, token_count: *mut u32) -> HRESULT;
fn get_location( file: *mut IDxcFile, line: u32, column: u32, result: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_num_diagnostics(value : *mut u32) -> HRESULT;
fn get_diagnostic(index: u32, value: *mut *mut IDxcDiagnostic) -> HRESULT;
fn get_file(name : *const u8, result : *mut *mut IDxcFile) -> HRESULT;
fn get_diagnostic(index: u32, value: *mut ComPtr<IDxcDiagnostic>) -> HRESULT;
fn get_file(name : *const u8, result : *mut ComPtr<IDxcFile>) -> HRESULT;
fn get_file_name(result : *mut LPSTR) -> HRESULT;
fn reparse(unsaved_files : *mut *mut IDxcUnsavedFile, num_unsaved_files: u32) -> HRESULT;
fn get_cursor_for_location(location: *const IDxcSourceLocation, result : *mut *mut IDxcCursor) -> HRESULT;
fn get_location_for_offset(file : *const IDxcFile, offset: u32, result: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_skipped_ranges(file: *const IDxcFile, result_count: *mut u32, result: *mut *mut *mut IDxcSourceRange) -> HRESULT;
fn reparse(unsaved_files : *mut ComPtr<IDxcUnsavedFile>, num_unsaved_files: u32) -> HRESULT;
fn get_cursor_for_location(location: *const IDxcSourceLocation, result : *mut ComPtr<IDxcCursor>) -> HRESULT;
fn get_location_for_offset(file : *const IDxcFile, offset: u32, result: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_skipped_ranges(file: *const IDxcFile, result_count: *mut u32, result: *mut *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_diagnostic_details(
index: u32, options: DxcDiagnosticDisplayOptions, error_code: *mut u32, error_line: *mut u32, error_column: *mut u32,
error_file: *mut BSTR, error_offset: *mut u32, error_length: *mut u32, error_message: *mut BSTR) -> HRESULT;
fn get_inclusion_list(result_count: *mut u32, result: *mut *mut *mut IDxcInclusion) -> HRESULT;
fn get_inclusion_list(result_count: *mut u32, result: *mut *mut ComPtr<IDxcInclusion>) -> HRESULT;
}
}

Expand All @@ -518,7 +518,7 @@ com_interface! {
unsaved_files: *const *const IDxcUnsavedFile,
num_unsaved_files: u32,
options: DxcTranslationUnitFlags,
translation_unit: *mut *mut IDxcTranslationUnit) -> HRESULT;
translation_unit: *mut ComPtr<IDxcTranslationUnit>) -> HRESULT;
}
}

Expand All @@ -527,13 +527,13 @@ com_interface! {
interface IDxcIntelliSense: IDxcUnknownShim, IUnknown {
iid: IID_IDxcIntelliSense,
vtable: IDxcIntelliSenseVtbl,
fn create_index(index: *mut *mut IDxcIndex) -> HRESULT;
fn get_null_location(location: *mut *mut IDxcSourceLocation) -> HRESULT;
fn get_null_range(location: *mut *mut IDxcSourceRange) -> HRESULT;
fn get_range( start: *const IDxcSourceLocation, end: *const IDxcSourceLocation, location: *mut *mut IDxcSourceRange) -> HRESULT;
fn create_index(index: *mut ComPtr<IDxcIndex>) -> HRESULT;
fn get_null_location(location: *mut ComPtr<IDxcSourceLocation>) -> HRESULT;
fn get_null_range(location: *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_range( start: *const IDxcSourceLocation, end: *const IDxcSourceLocation, location: *mut ComPtr<IDxcSourceRange>) -> HRESULT;
fn get_default_diagnostic_display_options(value: *mut DxcDiagnosticDisplayOptions) -> HRESULT;
fn get_default_editing_tu_options(value: *mut DxcTranslationUnitFlags) -> HRESULT;
fn create_unsaved_file(file_name: LPCSTR, contents: LPCSTR, content_length: u32 , result: *mut *mut IDxcUnsavedFile) -> HRESULT;
fn create_unsaved_file(file_name: LPCSTR, contents: LPCSTR, content_length: u32 , result: *mut ComPtr<IDxcUnsavedFile>) -> HRESULT;
}
}

Expand Down
Loading

0 comments on commit b7e97cc

Please sign in to comment.