Skip to content

Conversation

@shrestha-das
Copy link

Description

Summary

Moved the runtime-only __internal_CppInterOp::function template from the interpreter-injected string in CppInterOp.cpp into its own header file CppInterOpRuntime.h.

This makes the code cleaner, easier to maintain, and aligns with the reviewer suggestion from https://github.com/compiler-research/CppInterOp/pull/678/files#r2242837167 .

Changes

  • Added lib/CppInterOp/CppInterOpRuntime.h with the template definition.
  • Removed the I->declare(...) runtime template block from CppInterOp.cpp.
  • Included the new header in CppInterOp.cpp.

Motivation

Previously, the template code was injected into the interpreter at startup using a string. Moving it to a proper header:

  • Improves readability and maintainability.
  • Avoids duplication of template logic.

Fixes issue #697

Type of change

Please tick all options which are relevant.

  • Bug fix
  • New feature
  • Requires documentation updates

Checklist

  • I have read the contribution guide recently

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

#include "CppInterOp/CppInterOp.h"

#include "CppInterOpRuntime.h"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: included header CppInterOpRuntime.h is not used directly [misc-include-cleaner]

Suggested change

@@ -0,0 +1,19 @@
#ifndef CPPINTEROP_RUNTIME_H
#define CPPINTEROP_RUNTIME_H
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: header guard does not follow preferred style [llvm-header-guard]

Suggested change
#define CPPINTEROP_RUNTIME_H
#ifndef GITHUB_WORKSPACE_LIB_CPPINTEROP_CPPINTEROPRUNTIME_H
#define GITHUB_WORKSPACE_LIB_CPPINTEROP_CPPINTEROPRUNTIME_H

lib/CppInterOp/CppInterOpRuntime.h:18:

- #endif // CPPINTEROP_RUNTIME_H
+ #endif // GITHUB_WORKSPACE_LIB_CPPINTEROP_CPPINTEROPRUNTIME_H

// interpreter using I->declare(). It is now provided as a real header so that
// the interpreter can load it on startup.

namespace __internal_CppInterOp {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: declaration uses identifier '__internal_CppInterOp', which is a reserved identifier [bugprone-reserved-identifier]

Suggested change
namespace __internal_CppInterOp {
namespace internal_CppInterOp {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant